Set the playback RingBuffer latency appropriately for seeking

This commit is contained in:
Paul Licameli 2018-08-20 11:47:25 -04:00
parent 111d2c8673
commit 5cfbfd364e
1 changed files with 10 additions and 1 deletions

View File

@ -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 );