From eac6f98cbf97d9cdb240da978581ce21ec0d6f9c Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Mon, 16 May 2016 17:54:54 -0400 Subject: [PATCH] Avoid deadlocks that sometimes happened when starting a scrub... ... as a consequence of commit 52910f4f07d41904e5f8cc5fdc5e7f8484468a00 --- src/AudioIO.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/AudioIO.cpp b/src/AudioIO.cpp index 6ba2dc7fa..4ece76a9a 100644 --- a/src/AudioIO.cpp +++ b/src/AudioIO.cpp @@ -410,6 +410,14 @@ struct AudioIO::ScrubQueue return previous.mS1 / mRate; } + // This is for avoiding deadlocks while starting a scrub: + // Audio stream needs to be unblocked + void Nudge() + { + wxMutexLocker locker(mUpdating); + mAvailable.Signal(); + } + void PoisonPill() { // Main thread is shutting down the scrubbing @@ -478,8 +486,7 @@ struct AudioIO::ScrubQueue } else { - wxASSERT(mPoisoned); - // We got the shut-down signal + // We got the shut-down signal, or we got nudged startSample = endSample = duration = -1L; } } @@ -1874,8 +1881,11 @@ int AudioIO::StartStream(const WaveTrackArray &playbackTracks, // FillBuffers will ALWAYS get called from the Audio thread. mAudioThreadShouldCallFillBuffersOnce = true; - while( mAudioThreadShouldCallFillBuffersOnce == true ) + while( mAudioThreadShouldCallFillBuffersOnce == true ) { + if (mScrubQueue) + mScrubQueue->Nudge(); wxMilliSleep( 50 ); + } #ifdef EXPERIMENTAL_MIDI_OUT // if no playback, reset the midi time to zero to roughly sync