From 5cfbfd364ead2d93c2d68934c3e49b96099adc7b Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Mon, 20 Aug 2018 11:47:25 -0400 Subject: [PATCH] Set the playback RingBuffer latency appropriately for seeking --- src/AudioIO.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/AudioIO.cpp b/src/AudioIO.cpp index 8561e3b79..f71cae387 100644 --- a/src/AudioIO.cpp +++ b/src/AudioIO.cpp @@ -2254,8 +2254,10 @@ bool AudioIO::AllocateBuffers( // thread, in many smaller pieces. double playbackTime = 4.0; if (scrubbing) + // Specify a very short minimum batch for non-seek scrubbing, to allow + // more frequent polling of the mouse playbackTime = - lrint(options.pScrubbingOptions->delay * mRate) / mRate; + lrint(options.pScrubbingOptions->delay * mRate) / mRate; wxASSERT( playbackTime >= 0 ); mPlaybackSamplesToCopy = playbackTime * mRate; @@ -2294,6 +2296,13 @@ bool AudioIO::AllocateBuffers( Mixer::WarpOptions(mPlaybackSchedule.mTimeTrack); mPlaybackQueueMinimum = mPlaybackSamplesToCopy; + if (scrubbing) + // Specify enough playback RingBuffer latency so we can refill + // once every seek stutter without falling behind the demand. + // (Scrub might switch in and out of seeking with left mouse + // presses in the ruler) + mPlaybackQueueMinimum = lrint( + 2 * options.pScrubbingOptions->minStutterTime * mRate ); mPlaybackQueueMinimum = std::min( mPlaybackQueueMinimum, playbackBufferSize );