Move AudioIOBase::mPlaybackSchedule up into AudioIoCallback

This commit is contained in:
Paul Licameli 2020-12-17 11:27:54 -05:00
parent d92a68f076
commit 9a66255013
13 changed files with 35 additions and 33 deletions

View File

@ -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();
}
//////////////////////////////////////////////////////////////////////
//

View File

@ -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;

View File

@ -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<long> AudioIOBase::GetSupportedPlaybackRates(int devIndex, double rate)
{
if (devIndex == -1)

View File

@ -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.

View File

@ -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

View File

@ -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()

View File

@ -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() ||

View File

@ -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(

View File

@ -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();

View File

@ -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();

View File

@ -51,7 +51,7 @@ with changes in the SelectionBar.
#include <wx/statline.h>
#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 {

View File

@ -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 {

View File

@ -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;