diff --git a/src/AudioIO.cpp b/src/AudioIO.cpp index 44707949e..13a8aa1c0 100644 --- a/src/AudioIO.cpp +++ b/src/AudioIO.cpp @@ -2587,6 +2587,16 @@ finished: return retval; } +double AudioIO::GetStreamTime() +{ + // Track time readout for the main thread + + if( !IsStreamActive() ) + return BAD_STREAM_TIME; + + return mPlaybackSchedule.NormalizeTrackTime(); +} + ////////////////////////////////////////////////////////////////////// // diff --git a/src/AudioIO.h b/src/AudioIO.h index 6bc4a7185..7cb6a0260 100644 --- a/src/AudioIO.h +++ b/src/AudioIO.h @@ -576,6 +576,7 @@ protected: double Consumer( size_t nSamples, double rate ); } mTimeQueue; + PlaybackSchedule mPlaybackSchedule; }; class AUDACITY_DLL_API AudioIO final @@ -715,6 +716,14 @@ public: * and playing is true if one or more channels are being played. */ double GetBestRate(bool capturing, bool playing, double sampleRate); + /** \brief During playback, the track time most recently played + * + * When playing looped, this will start from t0 again, + * too. So the returned time should be always between + * t0 and t1 + */ + double GetStreamTime(); + friend class AudioThread; #ifdef EXPERIMENTAL_MIDI_OUT friend class MidiThread; diff --git a/src/AudioIOBase.cpp b/src/AudioIOBase.cpp index b3920f538..b0e7610a2 100644 --- a/src/AudioIOBase.cpp +++ b/src/AudioIOBase.cpp @@ -500,16 +500,6 @@ double AudioIOBase::PlaybackSchedule::NormalizeTrackTime() const return absoluteTime; } -double AudioIOBase::GetStreamTime() -{ - // Track time readout for the main thread - - if( !IsStreamActive() ) - return BAD_STREAM_TIME; - - return mPlaybackSchedule.NormalizeTrackTime(); -} - std::vector AudioIOBase::GetSupportedPlaybackRates(int devIndex, double rate) { if (devIndex == -1) diff --git a/src/AudioIOBase.h b/src/AudioIOBase.h index 2cbd95b8e..3268a72c1 100644 --- a/src/AudioIOBase.h +++ b/src/AudioIOBase.h @@ -195,14 +195,6 @@ public: */ static int GetOptimalSupportedSampleRate(); - /** \brief During playback, the track time most recently played - * - * When playing looped, this will start from t0 again, - * too. So the returned time should be always between - * t0 and t1 - */ - double GetStreamTime(); - /** \brief Array of common audio sample rates * * These are the rates we will always support, regardless of hardware support @@ -454,7 +446,7 @@ protected: void RealTimeRestart(); - } mPlaybackSchedule; + }; /** \brief get the index of the supplied (named) recording device, or the * device selected in the preferences if none given. diff --git a/src/LyricsWindow.cpp b/src/LyricsWindow.cpp index 00dad0735..4df43a270 100644 --- a/src/LyricsWindow.cpp +++ b/src/LyricsWindow.cpp @@ -11,7 +11,7 @@ #include "LyricsWindow.h" #include "Lyrics.h" -#include "AudioIOBase.h" +#include "AudioIO.h" #include "CommonCommandFlags.h" #include "prefs/GUISettings.h" // for RTL_WORKAROUND #include "Project.h" @@ -160,7 +160,7 @@ void LyricsWindow::OnTimer(wxCommandEvent &event) { if (ProjectAudioIO::Get( *mProject ).IsAudioActive()) { - auto gAudioIO = AudioIOBase::Get(); + auto gAudioIO = AudioIO::Get(); GetLyricsPanel()->Update(gAudioIO->GetStreamTime()); } else diff --git a/src/MixerBoard.cpp b/src/MixerBoard.cpp index b283a12d0..4ea01f77f 100644 --- a/src/MixerBoard.cpp +++ b/src/MixerBoard.cpp @@ -1353,7 +1353,7 @@ void MixerBoard::OnTimer(wxCommandEvent &event) // audacityAudioCallback where it calls gAudioIO->mOutputMeter->UpdateDisplay(). if (ProjectAudioIO::Get( *mProject ).IsAudioActive()) { - auto gAudioIO = AudioIOBase::Get(); + auto gAudioIO = AudioIO::Get(); UpdateMeters( gAudioIO->GetStreamTime(), (ProjectAudioManager::Get( *mProject ).GetLastPlayMode() diff --git a/src/ProjectAudioManager.cpp b/src/ProjectAudioManager.cpp index 84b62646e..61cd1cc7f 100644 --- a/src/ProjectAudioManager.cpp +++ b/src/ProjectAudioManager.cpp @@ -1075,7 +1075,7 @@ bool ProjectAudioManager::DoPlayStopSelect( bool click, bool shift ) auto token = ProjectAudioIO::Get( project ).GetAudioIOToken(); auto &viewInfo = ViewInfo::Get( project ); auto &selection = viewInfo.selectedRegion; - auto gAudioIO = AudioIOBase::Get(); + auto gAudioIO = AudioIO::Get(); //If busy, stop playing, make sure everything is unpaused. if (scrubber.HasMark() || diff --git a/src/ProjectWindow.cpp b/src/ProjectWindow.cpp index 8484efb8b..99b7cf91a 100644 --- a/src/ProjectWindow.cpp +++ b/src/ProjectWindow.cpp @@ -13,6 +13,7 @@ Paul Licameli split from AudacityProject.cpp #include "AllThemeResources.h" +#include "AudioIO.h" #include "Menus.h" #include "Project.h" #include "ProjectAudioIO.h" @@ -1670,7 +1671,7 @@ void ProjectWindow::PlaybackScroller::OnTimer(wxCommandEvent &event) // Let other listeners get the notification event.Skip(); - auto gAudioIO = AudioIOBase::Get(); + auto gAudioIO = AudioIO::Get(); mRecentStreamTime = gAudioIO->GetStreamTime(); auto cleanup = finally([&]{ @@ -1724,7 +1725,7 @@ void ProjectWindow::ZoomInByFactor( double ZoomFactor ) auto &project = mProject; auto &viewInfo = ViewInfo::Get( project ); - auto gAudioIO = AudioIOBase::Get(); + auto gAudioIO = AudioIO::Get(); // LLL: Handling positioning differently when audio is // actively playing. Don't do this if paused. if (gAudioIO->IsStreamActive( diff --git a/src/menus/LabelMenus.cpp b/src/menus/LabelMenus.cpp index 2dd8d759d..a1f61a826 100644 --- a/src/menus/LabelMenus.cpp +++ b/src/menus/LabelMenus.cpp @@ -1,4 +1,4 @@ -#include "../AudioIOBase.h" +#include "../AudioIO.h" #include "../Clipboard.h" #include "../CommonCommandFlags.h" #include "../LabelTrack.h" @@ -302,7 +302,7 @@ void OnAddLabelPlaying(const CommandContext &context) auto &project = context.project; auto token = ProjectAudioIO::Get( project ).GetAudioIOToken(); - auto gAudioIO = AudioIOBase::Get(); + auto gAudioIO = AudioIO::Get(); if (token > 0 && gAudioIO->IsStreamActive(token)) { double indicator = gAudioIO->GetStreamTime(); diff --git a/src/menus/SelectMenus.cpp b/src/menus/SelectMenus.cpp index 4ee711a26..6e3d428cd 100644 --- a/src/menus/SelectMenus.cpp +++ b/src/menus/SelectMenus.cpp @@ -504,7 +504,7 @@ void OnSetLeftSelection(const CommandContext &context) auto &window = GetProjectFrame( project ); bool bSelChanged = false; - auto gAudioIO = AudioIOBase::Get(); + auto gAudioIO = AudioIO::Get(); if ((token > 0) && gAudioIO->IsStreamActive(token)) { double indicator = gAudioIO->GetStreamTime(); @@ -543,7 +543,7 @@ void OnSetRightSelection(const CommandContext &context) auto &window = GetProjectFrame( project ); bool bSelChanged = false; - auto gAudioIO = AudioIOBase::Get(); + auto gAudioIO = AudioIO::Get(); if ((token > 0) && gAudioIO->IsStreamActive(token)) { double indicator = gAudioIO->GetStreamTime(); diff --git a/src/toolbars/SelectionBar.cpp b/src/toolbars/SelectionBar.cpp index 6406c8f40..ab6944897 100644 --- a/src/toolbars/SelectionBar.cpp +++ b/src/toolbars/SelectionBar.cpp @@ -51,7 +51,7 @@ with changes in the SelectionBar. #include -#include "../AudioIOBase.h" +#include "../AudioIO.h" #include "../AColor.h" #include "../KeyboardCapture.h" #include "../Prefs.h" @@ -599,7 +599,7 @@ void SelectionBar::OnIdle( wxIdleEvent &evt ) auto &projectAudioIO = ProjectAudioIO::Get( project ); if ( projectAudioIO.IsAudioActive() ){ - auto gAudioIO = AudioIOBase::Get(); + auto gAudioIO = AudioIO::Get(); audioTime = gAudioIO->GetStreamTime(); } else { diff --git a/src/toolbars/TimeToolBar.cpp b/src/toolbars/TimeToolBar.cpp index 59401d884..0e7baa134 100644 --- a/src/toolbars/TimeToolBar.cpp +++ b/src/toolbars/TimeToolBar.cpp @@ -362,7 +362,7 @@ void TimeToolBar::OnIdle(wxIdleEvent &evt) auto &projectAudioIO = ProjectAudioIO::Get(mProject); if (projectAudioIO.IsAudioActive()) { - auto gAudioIO = AudioIOBase::Get(); + auto gAudioIO = AudioIO::Get(); audioTime = gAudioIO->GetStreamTime(); } else { diff --git a/src/tracks/ui/Scrubbing.cpp b/src/tracks/ui/Scrubbing.cpp index f5887d393..08772f5dd 100644 --- a/src/tracks/ui/Scrubbing.cpp +++ b/src/tracks/ui/Scrubbing.cpp @@ -1139,7 +1139,7 @@ void Scrubber::DoKeyboardScrub(bool backwards, bool keyUp) if (keyUp) { auto &scrubber = Scrubber::Get(project); if (scrubber.IsKeyboardScrubbing() && scrubber.IsBackwards() == backwards) { - auto gAudioIO = AudioIOBase::Get(); + auto gAudioIO = AudioIO::Get(); auto time = gAudioIO->GetStreamTime(); auto &viewInfo = ViewInfo::Get(project); auto &selection = viewInfo.selectedRegion;