Skip to content

Commit

Permalink
Producer enqueues zeros when paused; consumer keeps consuming
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul-Licameli committed May 24, 2024
1 parent 4611b5c commit eb0b0a5
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions libraries/lib-audio-io/AudioIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2013,8 +2013,10 @@ bool AudioIO::ProcessPlaybackSlices(
bool progress = false;
size_t allProduced = 0;
do {
const auto slice =
policy.GetPlaybackSlice(mPlaybackSchedule, available);
const bool paused = IsPaused();
const auto slice = paused
? PlaybackSlice{ available, available, 0 } // produce all zeroes
: policy.GetPlaybackSlice(mPlaybackSchedule, available);
const auto &[frames, toProduce] = slice;
progress = progress || toProduce > 0;

Expand Down Expand Up @@ -2058,8 +2060,9 @@ bool AudioIO::ProcessPlaybackSlices(
available -= frames;
// wxASSERT(available >= 0); // don't assert on this thread

done = policy.RepositionPlayback( mPlaybackSchedule, mPlaybackMixers,
frames, available );
done = !paused &&
policy.RepositionPlayback( mPlaybackSchedule, mPlaybackMixers,
frames, available );
} while (available && !done);

// Do any realtime effect processing, more efficiently in at most
Expand Down Expand Up @@ -3115,11 +3118,6 @@ int AudioIoCallback::AudioCallback(
framesPerBuffer,
outputMeterFloats);

// Test for no sequence audio to play (because we are paused and have faded
// out)
if (paused && (!mbMicroFades || mOldMasterGain == 0.0f))
return callbackReturn;

// To add sequence output to output (to play sound on speaker)
// possible exit, if we were seeking.

Expand Down

0 comments on commit eb0b0a5

Please sign in to comment.