Remove dependency of AudioIO on Scrubbing.cpp ...

... though the demotion of the constant into AudioIO.h isn't wholly satisfactory
and there is still the scrubbing queue in AudioIO
This commit is contained in:
Paul Licameli 2019-06-24 12:18:50 -04:00
parent d9b780b067
commit 5627620b78
5 changed files with 35 additions and 18 deletions

View File

@ -518,8 +518,6 @@ constexpr size_t TimeQueueGrainSize = 2000;
#ifdef EXPERIMENTAL_SCRUBBING_SUPPORT
#include "tracks/ui/Scrubbing.h"
#ifdef __WXGTK__
// Might #define this for a useful thing on Linux
#undef REALTIME_ALSA_THREAD
@ -1704,17 +1702,11 @@ int AudioIO::StartStream(const TransportTracks &tracks,
mAudioThreadShouldCallFillBuffersOnce = true;
while( mAudioThreadShouldCallFillBuffersOnce ) {
#ifndef USE_SCRUB_THREAD
// Yuck, we either have to poll "by hand" when scrub polling doesn't
// work with a thread, or else yield to timer messages, but that would
// execute too much else
if (mScrubState) {
Scrubber::Get( *mOwningProject ).ContinueScrubbingPoll();
wxMilliSleep( Scrubber::ScrubPollInterval_ms * 0.9 );
auto interval = 50ull;
if (options.playbackStreamPrimer) {
interval = options.playbackStreamPrimer();
}
else
#endif
wxMilliSleep( 50 );
wxMilliSleep( interval );
}
if(mNumPlaybackChannels > 0 || mNumCaptureChannels > 0) {
@ -2544,7 +2536,7 @@ AudioThread::ExitCode AudioThread::Entry()
{
using Clock = std::chrono::steady_clock;
auto loopPassStart = Clock::now();
const auto interval = Scrubber::ScrubPollInterval_ms;
const auto interval = ScrubPollInterval_ms;
// Set LoopActive outside the tests to avoid race condition
gAudioIO->mAudioThreadFillBuffersLoopActive = true;

View File

@ -789,4 +789,6 @@ private:
void StartStreamCleanup(bool bOnlyBuffers = false);
};
static constexpr unsigned ScrubPollInterval_ms = 50;
#endif

View File

@ -16,6 +16,7 @@ Paul Licameli split from AudioIO.h
#include <atomic>
#include <cfloat>
#include <functional>
#include <memory>
#include <vector>
#include <wx/string.h>
@ -102,6 +103,11 @@ struct AudioIOStartStreamOptions
// contents may get swapped with empty vector
PRCrossfadeData *pCrossfadeData{};
// An unfortunate thing needed just to make scrubbing work on Linux when
// we can't use a separate polling thread.
// The return value is a number of milliseconds to sleep before calling again
std::function< unsigned long() > playbackStreamPrimer;
};
///\brief A singleton object supporting queries of the state of any active

View File

@ -56,8 +56,6 @@ enum {
ScrubSpeedStepsPerOctave = 4,
#endif
ScrubPollInterval_ms = 50,
kOneSecondCountdown = 1000 / ScrubPollInterval_ms,
};
@ -386,6 +384,16 @@ bool Scrubber::MaybeStartScrubbing(wxCoord xx)
mSpeedPlaying = false;
auto options =
DefaultPlayOptions( *mProject );
#ifndef USE_SCRUB_THREAD
// Yuck, we either have to poll "by hand" when scrub polling doesn't
// work with a thread, or else yield to timer messages, but that would
// execute too much else
options.playbackStreamPrimer = [this](){
ContinueScrubbingPoll();
return ScrubPollInterval_ms;
};
#endif
options.pScrubbingOptions = &mOptions;
options.envelope = nullptr;
mOptions.delay = (ScrubPollInterval_ms / 1000.0);
@ -487,6 +495,17 @@ bool Scrubber::StartSpeedPlay(double speed, double time0, double time1)
mDragging = false;
auto options = DefaultSpeedPlayOptions( *mProject );
#ifndef USE_SCRUB_THREAD
// Yuck, we either have to poll "by hand" when scrub polling doesn't
// work with a thread, or else yield to timer messages, but that would
// execute too much else
options.playbackStreamPrimer = [this](){
ContinueScrubbingPoll();
return ScrubPollInterval_ms;
};
#endif
options.pScrubbingOptions = &mOptions;
options.envelope = nullptr;
mOptions.delay = (ScrubPollInterval_ms / 1000.0);

View File

@ -40,9 +40,7 @@ class Scrubber final
: public wxEvtHandler
, public ClientData::Base
{
public:
static constexpr unsigned ScrubPollInterval_ms = 50;
public:
static Scrubber &Get( AudacityProject &project );
static const Scrubber &Get( const AudacityProject &project );