1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-18 17:10:05 +02:00

Make the 'wait for fade out' latency dependent.

This gives time for the fading out to clear the sound card, OR if
we would wait around too long, just close down the stream without waiting.
This commit is contained in:
James Crook 2018-09-01 10:24:50 +01:00
parent 9b728cfec8
commit 3f7c639c3f

View File

@ -2467,10 +2467,13 @@ void AudioIO::StopStream()
// PortAudio callback can use the information that we are stopping to fade // PortAudio callback can use the information that we are stopping to fade
// out the audio. Give PortAudio callback a chance to do so. // out the audio. Give PortAudio callback a chance to do so.
mAudioThreadFillBuffersLoopRunning = false; mAudioThreadFillBuffersLoopRunning = false;
// IF we were being more careful, we would loop and test for the fade out long latency;
// having been done. But 200ms is the max we can reasonably wait here gPrefs->Read( wxT("/AudioIO/LatencyDuration"), &latency, DEFAULT_LATENCY_DURATION );
// in any case, so we should not wait longer. // If we can gracefully fade out in 200ms, with the faded-out play buffers making it through
wxMilliSleep(200); // the sound card, then do so. If we can't, don't wait around. Just stop quickly and accept
// there will be a click.
if( latency < 150 )
wxMilliSleep( latency + 50);
} }
wxMutexLocker locker(mSuspendAudioThread); wxMutexLocker locker(mSuspendAudioThread);