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

Revert "Fix the hiccup at the start of scrub or play at speed..."

(It didn't really achieve what that commit comment said)

This reverts commit 26f72b110ceb07bc837eec5450084c6f5421ebb7.
This commit is contained in:
Paul Licameli 2018-08-25 19:42:12 -04:00
parent d79c071d6d
commit eeb5f1ec20
3 changed files with 25 additions and 50 deletions

View File

@ -2282,12 +2282,7 @@ int AudioIO::StartStream(const TransportTracks &tracks,
while( mAudioThreadShouldCallFillBuffersOnce ) {
if (mScrubQueue)
// If not using a scrub thread, then we need to let the mouse polling
// in the main thread deliver its messages to ScrubQueue, so that
// FillBuffers() can progress in priming the RingBuffer. Else we would
// deadlock here. If not using the scrub thread, this should be
// harmless.
wxEventLoopBase::GetActive()->YieldFor( wxEVT_CATEGORY_TIMER );
mScrubQueue->Nudge();
wxMilliSleep( 50 );
}

View File

@ -336,7 +336,8 @@ bool Scrubber::MaybeStartScrubbing(wxCoord xx)
double time1 = std::min(maxTime,
viewInfo.PositionToTime(position, leftOffset)
);
if (time1 != time0) {
if (time1 != time0)
{
if (busy) {
auto position = mScrubStartPosition;
ctb->StopPlaying();
@ -402,15 +403,6 @@ bool Scrubber::MaybeStartScrubbing(wxCoord xx)
);
#endif
mScrubSpeedDisplayCountdown = 0;
// Must start the thread and poller first or else PlayPlayRegion
// will deadlock
StartPolling();
auto cleanup = finally([this]{
if (mScrubToken < 0)
StopPolling();
});
mScrubToken =
ctb->PlayPlayRegion(SelectedRegion(time0, time1), options,
PlayMode::normalPlay, appearance, backwards);
@ -429,7 +421,17 @@ bool Scrubber::MaybeStartScrubbing(wxCoord xx)
mOptions.startClockTimeMillis = ::wxGetLocalTimeMillis();
if (IsScrubbing()) {
mPaused = false;
mLastScrubPosition = xx;
#ifdef USE_SCRUB_THREAD
// Detached thread is self-deleting, after it receives the Delete() message
mpThread = safenew ScrubPollerThread{ *this };
mpThread->Create(4096);
mpThread->Run();
#endif
mPoller->Start(ScrubPollInterval_ms);
}
// Return true whether we started scrub, or are still waiting to decide.
@ -489,14 +491,6 @@ bool Scrubber::StartSpeedPlay(double speed, double time0, double time1)
);
#endif
// Must start the thread and poller first or else PlayPlayRegion
// will deadlock
StartPolling();
auto cleanup = finally([this]{
if (mScrubToken < 0)
StopPolling();
});
mScrubSpeedDisplayCountdown = 0;
// Aim to stop within 20 samples of correct position.
double stopTolerance = 20.0 / options.rate;
@ -506,9 +500,18 @@ bool Scrubber::StartSpeedPlay(double speed, double time0, double time1)
PlayMode::normalPlay, appearance, backwards);
if (mScrubToken >= 0) {
mPaused = false;
mLastScrubPosition = 0;
}
#ifdef USE_SCRUB_THREAD
// Detached thread is self-deleting, after it receives the Delete() message
mpThread = safenew ScrubPollerThread{ *this };
mpThread->Create(4096);
mpThread->Run();
#endif
mPoller->Start(ScrubPollInterval_ms);
}
return true;
}
@ -627,37 +630,16 @@ void Scrubber::ContinueScrubbingUI()
}
}
void Scrubber::StartPolling()
void Scrubber::StopScrubbing()
{
mPaused = false;
#ifdef USE_SCRUB_THREAD
// Detached thread is self-deleting, after it receives the Delete() message
mpThread = safenew ScrubPollerThread{ *this };
mpThread->Create(4096);
mpThread->Run();
#endif
mPoller->Start(ScrubPollInterval_ms);
}
void Scrubber::StopPolling()
{
mPaused = true;
#ifdef USE_SCRUB_THREAD
if (mpThread) {
mpThread->Delete();
mpThread = nullptr;
}
#endif
mPoller->Stop();
}
void Scrubber::StopScrubbing()
{
StopPolling();
mPoller->Stop();
if (HasMark() && !mCancelled) {
const wxMouseState state(::wxGetMouseState());

View File

@ -154,8 +154,6 @@ public:
void CheckMenuItems();
private:
void StartPolling();
void StopPolling();
void DoScrub(bool seek);
void OnActivateOrDeactivateApp(wxActivateEvent & event);