mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-23 15:50:05 +02:00
Start scrub polling before the PortAudio stream...
... A part, but only a part, of the fix for "bounce" at start of scrub
This commit is contained in:
parent
27ede251d5
commit
303ac9367a
@ -336,8 +336,7 @@ bool Scrubber::MaybeStartScrubbing(wxCoord xx)
|
|||||||
double time1 = std::min(maxTime,
|
double time1 = std::min(maxTime,
|
||||||
viewInfo.PositionToTime(position, leftOffset)
|
viewInfo.PositionToTime(position, leftOffset)
|
||||||
);
|
);
|
||||||
if (time1 != time0)
|
if (time1 != time0) {
|
||||||
{
|
|
||||||
if (busy) {
|
if (busy) {
|
||||||
auto position = mScrubStartPosition;
|
auto position = mScrubStartPosition;
|
||||||
ctb->StopPlaying();
|
ctb->StopPlaying();
|
||||||
@ -403,6 +402,15 @@ bool Scrubber::MaybeStartScrubbing(wxCoord xx)
|
|||||||
);
|
);
|
||||||
#endif
|
#endif
|
||||||
mScrubSpeedDisplayCountdown = 0;
|
mScrubSpeedDisplayCountdown = 0;
|
||||||
|
|
||||||
|
// Must start the thread and poller first or else PlayPlayRegion
|
||||||
|
// will insert some silence
|
||||||
|
StartPolling();
|
||||||
|
auto cleanup = finally([this]{
|
||||||
|
if (mScrubToken < 0)
|
||||||
|
StopPolling();
|
||||||
|
});
|
||||||
|
|
||||||
mScrubToken =
|
mScrubToken =
|
||||||
ctb->PlayPlayRegion(SelectedRegion(time0, time1), options,
|
ctb->PlayPlayRegion(SelectedRegion(time0, time1), options,
|
||||||
PlayMode::normalPlay, appearance, backwards);
|
PlayMode::normalPlay, appearance, backwards);
|
||||||
@ -421,17 +429,7 @@ bool Scrubber::MaybeStartScrubbing(wxCoord xx)
|
|||||||
mOptions.startClockTimeMillis = ::wxGetLocalTimeMillis();
|
mOptions.startClockTimeMillis = ::wxGetLocalTimeMillis();
|
||||||
|
|
||||||
if (IsScrubbing()) {
|
if (IsScrubbing()) {
|
||||||
mPaused = false;
|
|
||||||
mLastScrubPosition = xx;
|
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.
|
// Return true whether we started scrub, or are still waiting to decide.
|
||||||
@ -491,6 +489,14 @@ bool Scrubber::StartSpeedPlay(double speed, double time0, double time1)
|
|||||||
);
|
);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Must start the thread and poller first or else PlayPlayRegion
|
||||||
|
// will insert some silence
|
||||||
|
StartPolling();
|
||||||
|
auto cleanup = finally([this]{
|
||||||
|
if (mScrubToken < 0)
|
||||||
|
StopPolling();
|
||||||
|
});
|
||||||
|
|
||||||
mScrubSpeedDisplayCountdown = 0;
|
mScrubSpeedDisplayCountdown = 0;
|
||||||
// Aim to stop within 20 samples of correct position.
|
// Aim to stop within 20 samples of correct position.
|
||||||
double stopTolerance = 20.0 / options.rate;
|
double stopTolerance = 20.0 / options.rate;
|
||||||
@ -500,18 +506,9 @@ bool Scrubber::StartSpeedPlay(double speed, double time0, double time1)
|
|||||||
PlayMode::normalPlay, appearance, backwards);
|
PlayMode::normalPlay, appearance, backwards);
|
||||||
|
|
||||||
if (mScrubToken >= 0) {
|
if (mScrubToken >= 0) {
|
||||||
mPaused = false;
|
|
||||||
mLastScrubPosition = 0;
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -630,16 +627,37 @@ void Scrubber::ContinueScrubbingUI()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scrubber::StopScrubbing()
|
void Scrubber::StartPolling()
|
||||||
{
|
{
|
||||||
|
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
|
#ifdef USE_SCRUB_THREAD
|
||||||
if (mpThread) {
|
if (mpThread) {
|
||||||
mpThread->Delete();
|
mpThread->Delete();
|
||||||
mpThread = nullptr;
|
mpThread = nullptr;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
mPoller->Stop();
|
mPoller->Stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Scrubber::StopScrubbing()
|
||||||
|
{
|
||||||
|
StopPolling();
|
||||||
|
|
||||||
if (HasMark() && !mCancelled) {
|
if (HasMark() && !mCancelled) {
|
||||||
const wxMouseState state(::wxGetMouseState());
|
const wxMouseState state(::wxGetMouseState());
|
||||||
|
@ -154,6 +154,8 @@ public:
|
|||||||
void CheckMenuItems();
|
void CheckMenuItems();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void StartPolling();
|
||||||
|
void StopPolling();
|
||||||
void DoScrub(bool seek);
|
void DoScrub(bool seek);
|
||||||
void OnActivateOrDeactivateApp(wxActivateEvent & event);
|
void OnActivateOrDeactivateApp(wxActivateEvent & event);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user