Skip to content

Commit

Permalink
provide IsRecording flag (AUv2) (#251)
Browse files Browse the repository at this point in the history
* provide IsRecording flag (AUv2)

why ever apple decided not to pass the isRecording flag, it is possible to retrieve the host callback structure and get it ourselves.

* Update wrapasauv2.cpp

of course _isRecording must be initialized
  • Loading branch information
defiantnerd committed May 8, 2024
1 parent 2e2c69d commit d747520
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/detail/auv2/process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ void ProcessAdapter::process(ProcessData& data)
{
// TODO: transportchanged flag?
_transport.flags |= data._isPlaying ? CLAP_TRANSPORT_IS_PLAYING : 0;
_transport.flags |= data._isRecording ? CLAP_TRANSPORT_IS_RECORDING : 0;
// CLAP_TRANSPORT_IS_RECORDING can not be retrieved from this data block
_transport.flags |= data._isLooping ? CLAP_TRANSPORT_IS_LOOP_ACTIVE : 0;
// CLAP_TRANSPORT_IS_RECORDING can not be retrieved from the AudioUnit API
Expand Down
1 change: 1 addition & 0 deletions src/detail/auv2/process.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ struct ProcessData
Boolean _isPlaying;
Boolean _transportChanged;
Boolean _isLooping;
Boolean _isRecording;

// --------------
bool _AUbeatAndTempoValid; // true if:
Expand Down
26 changes: 18 additions & 8 deletions src/wrapasauv2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -920,19 +920,29 @@ OSStatus WrapAsAUV2::Render(AudioUnitRenderActionFlags& inFlags, const AudioTime

// retrieve musical information for this render block

// TODO: clarify how we can get transportStateProc2
// mHostCallbackInfo.transportStateProc2
#if 1
data._AUtransportValid =
(noErr == CallHostTransportState(&data._isPlaying, &data._transportChanged,
&data._currentSongPosInSeconds, &data._isLooping,
&data._cycleStart, &data._cycleEnd));
auto hcb = GetHostCallbackInfo();
if (hcb.transportStateProc2)
{
data._AUtransportValid =
(noErr == (hcb.transportStateProc2)(hcb.hostUserData, &data._isPlaying, &data._isRecording,
&data._transportChanged, &data._currentSongPosInSeconds,
&data._isLooping, &data._cycleStart, &data._cycleEnd));
}
else
{
data._isRecording = FALSE;

data._AUtransportValid =
(noErr == CallHostTransportState(&data._isPlaying, &data._transportChanged,
&data._currentSongPosInSeconds, &data._isLooping,
&data._cycleStart, &data._cycleEnd));
}

data._currentSongPosInSeconds /= std::max(_plugin->getSampleRate(), 1.0); // just in case
data._AUbeatAndTempoValid = (noErr == CallHostBeatAndTempo(&data._beat, &data._tempo));
data._AUmusicalTimeValid =
(noErr == CallHostMusicalTimeLocation(&data._offsetToNextBeat, &data._musicalNumerator,
&data._musicalDenominator, &data._currentDownBeat));
#endif
// Get output buffer list and extract the i/o buffer pointers.
// The loop is done so that an arbitrary number of output busses
// with an arbitrary number of output channels is mapped onto a
Expand Down

0 comments on commit d747520

Please sign in to comment.