From 42a4f55ffed297ff50586ba001f2c8a0c2b8b559 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Mon, 10 Jun 2019 14:25:50 -0400 Subject: [PATCH] Prepare to split AudioIOBase from AudioIO... ... New files, but (almost) empty; don't use the global variable gAudioIO, but use one of two accessor function names (which are the same function for now). AudioIOBase will have fewer dependencies than AudioIO -- in particular, no dependency on tracks. It won't include StartStream. It will contain functions to query the present state of streams, and device capabilities. --- lib-src/mod-nyq-bench/NyqBench.cpp | 3 ++- locale/POTFILES.in | 2 ++ mac/Audacity.xcodeproj/project.pbxproj | 6 +++++ src/AdornedRulerPanel.cpp | 1 + src/AudacityApp.cpp | 1 + src/AudioIO.cpp | 5 ++++ src/AudioIO.h | 4 +++ src/AudioIOBase.cpp | 0 src/AudioIOBase.h | 16 +++++++++++ src/CrashReport.cpp | 3 ++- src/DeviceManager.cpp | 1 + src/LabelTrack.cpp | 1 + src/Lyrics.cpp | 1 + src/LyricsWindow.cpp | 3 ++- src/Makefile.am | 2 ++ src/Makefile.in | 27 +++++++++++++++---- src/Menus.cpp | 1 + src/MixerBoard.cpp | 1 + src/ProjectAudioIO.cpp | 5 +++- src/ProjectAudioManager.cpp | 2 ++ src/ProjectManager.cpp | 3 +++ src/ProjectSettings.cpp | 6 ++--- src/ProjectWindow.cpp | 4 ++- src/TrackPanel.cpp | 1 + src/ViewInfo.cpp | 3 ++- src/effects/Effect.cpp | 5 ++++ src/menus/HelpMenus.cpp | 4 ++- src/menus/LabelMenus.cpp | 3 ++- src/menus/PluginMenus.cpp | 3 +++ src/menus/SelectMenus.cpp | 6 +++++ src/menus/TransportMenus.cpp | 8 +++++- src/prefs/PrefsDialog.cpp | 1 + src/prefs/QualityPrefs.cpp | 10 +++---- src/toolbars/ControlToolBar.cpp | 15 ++++++++++- src/toolbars/DeviceToolBar.cpp | 2 ++ src/toolbars/MixerToolBar.cpp | 5 ++++ src/toolbars/SelectionBar.cpp | 9 ++++--- src/toolbars/TranscriptionToolBar.cpp | 13 ++++++++- .../wavetrack/ui/WaveTrackControls.cpp | 4 ++- src/tracks/ui/PlayIndicatorOverlay.cpp | 3 +++ src/tracks/ui/Scrubbing.cpp | 4 +++ src/widgets/Meter.cpp | 4 +++ win/Projects/Audacity/Audacity.vcxproj | 2 ++ .../Audacity/Audacity.vcxproj.filters | 6 +++++ 44 files changed, 180 insertions(+), 29 deletions(-) create mode 100644 src/AudioIOBase.cpp create mode 100644 src/AudioIOBase.h diff --git a/lib-src/mod-nyq-bench/NyqBench.cpp b/lib-src/mod-nyq-bench/NyqBench.cpp index 1e8f5aeea..26c7ebb70 100755 --- a/lib-src/mod-nyq-bench/NyqBench.cpp +++ b/lib-src/mod-nyq-bench/NyqBench.cpp @@ -23,7 +23,7 @@ #include #include -#include "AudioIO.h" +#include "AudioIOBase.h" #include "LabelTrack.h" #include "Menus.h" #include "ModuleManager.h" @@ -1590,6 +1590,7 @@ void NyqBench::OnRunUpdate(wxUpdateUIEvent & e) wxToolBar *tbar = GetToolBar(); wxMenuBar *mbar = GetMenuBar(); + auto gAudioIO = AudioIOBase::Get(); if (p && gAudioIO->IsBusy()) { mbar->Enable(ID_GO, false); mbar->Enable(ID_STOP, false); diff --git a/locale/POTFILES.in b/locale/POTFILES.in index d899a1978..8928869e1 100644 --- a/locale/POTFILES.in +++ b/locale/POTFILES.in @@ -41,6 +41,8 @@ src/AudacityLogger.cpp src/AudacityLogger.h src/AudioIO.cpp src/AudioIO.h +src/AudioIOBase.cpp +src/AudioIOBase.h src/AudioIOListener.h src/AutoRecovery.cpp src/AutoRecovery.h diff --git a/mac/Audacity.xcodeproj/project.pbxproj b/mac/Audacity.xcodeproj/project.pbxproj index 4c88e63be..be2b27e6a 100644 --- a/mac/Audacity.xcodeproj/project.pbxproj +++ b/mac/Audacity.xcodeproj/project.pbxproj @@ -1217,6 +1217,7 @@ 5E135A45229EE4DE0076E983 /* ProjectFileIO.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5E135A43229EE4DE0076E983 /* ProjectFileIO.cpp */; }; 5E135A48229EE5530076E983 /* ProjectWindow.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5E135A46229EE5530076E983 /* ProjectWindow.cpp */; }; 5E135A5122A93DC60076E983 /* ProjectAudioManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5E135A4F22A93DC60076E983 /* ProjectAudioManager.cpp */; }; + 5E135A4B22A5F7560076E983 /* AudioIOBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5E135A4922A5F7560076E983 /* AudioIOBase.cpp */; }; 5E15123D1DB000C000702E29 /* UIHandle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5E15123B1DB000C000702E29 /* UIHandle.cpp */; }; 5E15125A1DB000DC00702E29 /* LabelTrackControls.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5E1512401DB000DC00702E29 /* LabelTrackControls.cpp */; }; 5E15125B1DB000DC00702E29 /* LabelTrackUI.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5E1512421DB000DC00702E29 /* LabelTrackUI.cpp */; }; @@ -3191,6 +3192,8 @@ 5E135A47229EE5530076E983 /* ProjectWindow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProjectWindow.h; sourceTree = ""; }; 5E135A4F22A93DC60076E983 /* ProjectAudioManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ProjectAudioManager.cpp; sourceTree = ""; }; 5E135A5022A93DC60076E983 /* ProjectAudioManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProjectAudioManager.h; sourceTree = ""; }; + 5E135A4922A5F7560076E983 /* AudioIOBase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AudioIOBase.cpp; sourceTree = ""; }; + 5E135A4A22A5F7560076E983 /* AudioIOBase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AudioIOBase.h; sourceTree = ""; }; 5E1512381DB000C000702E29 /* HitTestResult.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HitTestResult.h; sourceTree = ""; }; 5E1512391DB000C000702E29 /* RefreshCode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RefreshCode.h; sourceTree = ""; }; 5E15123A1DB000C000702E29 /* TrackPanelMouseEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TrackPanelMouseEvent.h; sourceTree = ""; }; @@ -4331,6 +4334,7 @@ 5E78388D1DE4995E003270C0 /* AudacityException.cpp */, 28C3946B1818356800FDDAC9 /* AudacityLogger.cpp */, 1790AFD209883BFD008A330A /* AudioIO.cpp */, + 5E135A4922A5F7560076E983 /* AudioIOBase.cpp */, 28560C8F0A75E40F00A3429E /* AutoRecovery.cpp */, 5E19F59722A9665500E3F88E /* AutoRecoveryDialog.cpp */, 1790AFD409883BFD008A330A /* BatchCommandDialog.cpp */, @@ -4443,6 +4447,7 @@ 1790AFD009883BFD008A330A /* AudacityHeaders.h */, 28C3946C1818356800FDDAC9 /* AudacityLogger.h */, 1790AFD309883BFD008A330A /* AudioIO.h */, + 5E135A4A22A5F7560076E983 /* AudioIOBase.h */, 28F996D91A2A9261008FEEF3 /* AudioIOListener.h */, 28560C900A75E40F00A3429E /* AutoRecovery.h */, 5E19F59822A9665500E3F88E /* AutoRecoveryDialog.h */, @@ -8710,6 +8715,7 @@ 28001B3E1A0F0E5D007DD161 /* NumericTextCtrl.cpp in Sources */, 28001B4B1A0F0EB6007DD161 /* SpectralSelectionBar.cpp in Sources */, 28BB98051A15BE6800D1CC80 /* NoiseReduction.cpp in Sources */, + 5E135A4B22A5F7560076E983 /* AudioIOBase.cpp in Sources */, 5E74D2E41CC4429700D88B0B /* PlayIndicatorOverlay.cpp in Sources */, 5E73965C1DAFDAA400BA0A4D /* BackgroundCell.cpp in Sources */, 28D000A51A32920C00367B21 /* DeviceChange.cpp in Sources */, diff --git a/src/AdornedRulerPanel.cpp b/src/AdornedRulerPanel.cpp index 88bbd0899..c9ee75b6e 100644 --- a/src/AdornedRulerPanel.cpp +++ b/src/AdornedRulerPanel.cpp @@ -1695,6 +1695,7 @@ void AdornedRulerPanel::UpdateButtonStates() pinButton->PopUp(); else pinButton->PushDown(); + auto gAudioIO = AudioIO::Get(); pinButton->SetAlternateIdx( (gAudioIO->IsCapturing() ? 2 : 0) + (state ? 0 : 1)); // Bug 1584: Toltip now shows what clicking will do. diff --git a/src/AudacityApp.cpp b/src/AudacityApp.cpp index 20f63cd4b..2ee231faa 100644 --- a/src/AudacityApp.cpp +++ b/src/AudacityApp.cpp @@ -1619,6 +1619,7 @@ void AudacityApp::OnKeyDown(wxKeyEvent &event) auto scrubbing = scrubber.HasMark(); if (scrubbing) scrubber.Cancel(); + auto gAudioIO = AudioIO::Get(); if((token > 0 && gAudioIO->IsAudioTokenActive(token) && gAudioIO->GetNumCaptureChannels() == 0) || diff --git a/src/AudioIO.cpp b/src/AudioIO.cpp index 3522903bf..98d18735a 100644 --- a/src/AudioIO.cpp +++ b/src/AudioIO.cpp @@ -1155,6 +1155,11 @@ AudioIO::~AudioIO() gAudioIO = nullptr; } +AudioIO *AudioIO::Get() +{ + return gAudioIO; +} + void AudioIO::SetMixer(int inputSource) { #if defined(USE_PORTMIXER) diff --git a/src/AudioIO.h b/src/AudioIO.h index 93af97fc4..247b6fd64 100644 --- a/src/AudioIO.h +++ b/src/AudioIO.h @@ -800,6 +800,8 @@ class AUDACITY_DLL_API AudioIO final : public AudioIoCallback { AudioIO(); ~AudioIO(); + // This might return null during application startup or shutdown + static AudioIO *Get(); public: @@ -1189,4 +1191,6 @@ private: void StartStreamCleanup(bool bOnlyBuffers = false); }; +using AudioIOBase = AudioIO; + #endif diff --git a/src/AudioIOBase.cpp b/src/AudioIOBase.cpp new file mode 100644 index 000000000..e69de29bb diff --git a/src/AudioIOBase.h b/src/AudioIOBase.h new file mode 100644 index 000000000..d6195b6a1 --- /dev/null +++ b/src/AudioIOBase.h @@ -0,0 +1,16 @@ +/********************************************************************** + +Audacity: A Digital Audio Editor + +AudioIOBase.h + +Paul Licameli split from AudioIO.h + +**********************************************************************/ + +#ifndef __AUDACITY_AUDIO_IO_BASE__ +#define __AUDACITY_AUDIO_IO_BASE__ + +#include "AudioIO.h" + +#endif diff --git a/src/CrashReport.cpp b/src/CrashReport.cpp index e9d2f8d6f..f6294ff1f 100644 --- a/src/CrashReport.cpp +++ b/src/CrashReport.cpp @@ -14,7 +14,7 @@ #include "wxFileNameWrapper.h" #include "AudacityLogger.h" -#include "AudioIO.h" +#include "AudioIOBase.h" #include "FileNames.h" #include "Internat.h" #include "prefs/GUIPrefs.h" @@ -38,6 +38,7 @@ void Generate(wxDebugReport::Context ctx) GUIPrefs::InitLang( wxT("en") ); auto cleanup = finally( [&]{ GUIPrefs::InitLang( saveLang ); } ); + auto gAudioIO = AudioIOBase::Get(); rpt.AddText(wxT("audiodev.txt"), gAudioIO->GetDeviceInfo(), wxT("Audio Device Info")); #ifdef EXPERIMENTAL_MIDI_OUT rpt.AddText(wxT("mididev.txt"), gAudioIO->GetMidiDeviceInfo(), wxT("MIDI Device Info")); diff --git a/src/DeviceManager.cpp b/src/DeviceManager.cpp index 67cea1272..c2143922b 100644 --- a/src/DeviceManager.cpp +++ b/src/DeviceManager.cpp @@ -259,6 +259,7 @@ void DeviceManager::Rescan() if (m_inited) { // check to see if there is a stream open - can happen if monitoring, // but otherwise Rescan() should not be available to the user. + auto gAudioIO = AudioIO::Get(); if (gAudioIO) { if (gAudioIO->IsMonitoring()) { diff --git a/src/LabelTrack.cpp b/src/LabelTrack.cpp index 0057e18ef..f1b872841 100644 --- a/src/LabelTrack.cpp +++ b/src/LabelTrack.cpp @@ -1770,6 +1770,7 @@ bool LabelTrack::DoCaptureKey(wxKeyEvent & event) // If we're playing, don't capture if the selection is the same as the // playback region (this helps prevent label track creation from // stealing unmodified kbd. shortcuts) + auto gAudioIO = AudioIOBase::Get(); if (pProj->GetAudioIOToken() > 0 && gAudioIO->IsStreamActive(pProj->GetAudioIOToken())) { diff --git a/src/Lyrics.cpp b/src/Lyrics.cpp index ee4f607a3..faf62471e 100644 --- a/src/Lyrics.cpp +++ b/src/Lyrics.cpp @@ -480,6 +480,7 @@ void LyricsPanel::UpdateLyrics(wxEvent &e) e.Skip(); // It's crucial to not do that repopulating during playback. + auto gAudioIO = AudioIOBase::Get(); if (gAudioIO->IsStreamActive()) { mDelayedUpdate = true; return; diff --git a/src/LyricsWindow.cpp b/src/LyricsWindow.cpp index 755c492e9..b4e429d2f 100644 --- a/src/LyricsWindow.cpp +++ b/src/LyricsWindow.cpp @@ -11,7 +11,7 @@ #include "LyricsWindow.h" #include "Lyrics.h" -#include "AudioIO.h" +#include "AudioIOBase.h" #include "Prefs.h" // for RTL_WORKAROUND #include "Project.h" #include "ProjectAudioIO.h" @@ -155,6 +155,7 @@ void LyricsWindow::OnTimer(wxCommandEvent &event) { if (ProjectAudioIO::Get( *mProject ).IsAudioActive()) { + auto gAudioIO = AudioIOBase::Get(); GetLyricsPanel()->Update(gAudioIO->GetStreamTime()); } else diff --git a/src/Makefile.am b/src/Makefile.am index 8b0a1e696..b367948af 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -112,6 +112,8 @@ audacity_SOURCES = \ AudacityLogger.h \ AudioIO.cpp \ AudioIO.h \ + AudioIOBase.cpp \ + AudioIOBase.h \ AudioIOListener.h \ AutoRecovery.cpp \ AutoRecovery.h \ diff --git a/src/Makefile.in b/src/Makefile.in index 3cc2ea94d..3bd51ab3a 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -290,8 +290,9 @@ am__audacity_SOURCES_DIST = BlockFile.cpp BlockFile.h DirManager.cpp \ AdornedRulerPanel.h AllThemeResources.h Audacity.h \ AudacityApp.cpp AudacityApp.h AudacityException.cpp \ AudacityException.h AudacityLogger.cpp AudacityLogger.h \ - AudioIO.cpp AudioIO.h AudioIOListener.h AutoRecovery.cpp \ - AutoRecovery.h AutoRecoveryDialog.cpp AutoRecoveryDialog.h \ + AudioIO.cpp AudioIO.h AudioIOBase.cpp AudioIOBase.h \ + AudioIOListener.h AutoRecovery.cpp AutoRecovery.h \ + AutoRecoveryDialog.cpp AutoRecoveryDialog.h \ BatchCommandDialog.cpp BatchCommandDialog.h BatchCommands.cpp \ BatchCommands.h BatchProcessDialog.cpp BatchProcessDialog.h \ Benchmark.cpp Benchmark.h CellularPanel.cpp CellularPanel.h \ @@ -636,7 +637,7 @@ am_audacity_OBJECTS = $(am__objects_1) audacity-AboutDialog.$(OBJEXT) \ audacity-AudacityApp.$(OBJEXT) \ audacity-AudacityException.$(OBJEXT) \ audacity-AudacityLogger.$(OBJEXT) audacity-AudioIO.$(OBJEXT) \ - audacity-AutoRecovery.$(OBJEXT) \ + audacity-AudioIOBase.$(OBJEXT) audacity-AutoRecovery.$(OBJEXT) \ audacity-AutoRecoveryDialog.$(OBJEXT) \ audacity-BatchCommandDialog.$(OBJEXT) \ audacity-BatchCommands.$(OBJEXT) \ @@ -1366,8 +1367,9 @@ audacity_SOURCES = $(libaudacity_la_SOURCES) AboutDialog.cpp \ AdornedRulerPanel.h AllThemeResources.h Audacity.h \ AudacityApp.cpp AudacityApp.h AudacityException.cpp \ AudacityException.h AudacityLogger.cpp AudacityLogger.h \ - AudioIO.cpp AudioIO.h AudioIOListener.h AutoRecovery.cpp \ - AutoRecovery.h AutoRecoveryDialog.cpp AutoRecoveryDialog.h \ + AudioIO.cpp AudioIO.h AudioIOBase.cpp AudioIOBase.h \ + AudioIOListener.h AutoRecovery.cpp AutoRecovery.h \ + AutoRecoveryDialog.cpp AutoRecoveryDialog.h \ BatchCommandDialog.cpp BatchCommandDialog.h BatchCommands.cpp \ BatchCommands.h BatchProcessDialog.cpp BatchProcessDialog.h \ Benchmark.cpp Benchmark.h CellularPanel.cpp CellularPanel.h \ @@ -2522,6 +2524,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/audacity-AudacityException.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/audacity-AudacityLogger.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/audacity-AudioIO.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/audacity-AudioIOBase.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/audacity-AutoRecovery.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/audacity-AutoRecoveryDialog.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/audacity-BatchCommandDialog.Po@am__quote@ @@ -3371,6 +3374,20 @@ audacity-AudioIO.obj: AudioIO.cpp @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(audacity_CPPFLAGS) $(CPPFLAGS) $(audacity_CXXFLAGS) $(CXXFLAGS) -c -o audacity-AudioIO.obj `if test -f 'AudioIO.cpp'; then $(CYGPATH_W) 'AudioIO.cpp'; else $(CYGPATH_W) '$(srcdir)/AudioIO.cpp'; fi` +audacity-AudioIOBase.o: AudioIOBase.cpp +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(audacity_CPPFLAGS) $(CPPFLAGS) $(audacity_CXXFLAGS) $(CXXFLAGS) -MT audacity-AudioIOBase.o -MD -MP -MF $(DEPDIR)/audacity-AudioIOBase.Tpo -c -o audacity-AudioIOBase.o `test -f 'AudioIOBase.cpp' || echo '$(srcdir)/'`AudioIOBase.cpp +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/audacity-AudioIOBase.Tpo $(DEPDIR)/audacity-AudioIOBase.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='AudioIOBase.cpp' object='audacity-AudioIOBase.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(audacity_CPPFLAGS) $(CPPFLAGS) $(audacity_CXXFLAGS) $(CXXFLAGS) -c -o audacity-AudioIOBase.o `test -f 'AudioIOBase.cpp' || echo '$(srcdir)/'`AudioIOBase.cpp + +audacity-AudioIOBase.obj: AudioIOBase.cpp +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(audacity_CPPFLAGS) $(CPPFLAGS) $(audacity_CXXFLAGS) $(CXXFLAGS) -MT audacity-AudioIOBase.obj -MD -MP -MF $(DEPDIR)/audacity-AudioIOBase.Tpo -c -o audacity-AudioIOBase.obj `if test -f 'AudioIOBase.cpp'; then $(CYGPATH_W) 'AudioIOBase.cpp'; else $(CYGPATH_W) '$(srcdir)/AudioIOBase.cpp'; fi` +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/audacity-AudioIOBase.Tpo $(DEPDIR)/audacity-AudioIOBase.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='AudioIOBase.cpp' object='audacity-AudioIOBase.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(audacity_CPPFLAGS) $(CPPFLAGS) $(audacity_CXXFLAGS) $(CXXFLAGS) -c -o audacity-AudioIOBase.obj `if test -f 'AudioIOBase.cpp'; then $(CYGPATH_W) 'AudioIOBase.cpp'; else $(CYGPATH_W) '$(srcdir)/AudioIOBase.cpp'; fi` + audacity-AutoRecovery.o: AutoRecovery.cpp @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(audacity_CPPFLAGS) $(CPPFLAGS) $(audacity_CXXFLAGS) $(CXXFLAGS) -MT audacity-AutoRecovery.o -MD -MP -MF $(DEPDIR)/audacity-AutoRecovery.Tpo -c -o audacity-AutoRecovery.o `test -f 'AutoRecovery.cpp' || echo '$(srcdir)/'`AutoRecovery.cpp @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/audacity-AutoRecovery.Tpo $(DEPDIR)/audacity-AutoRecovery.Po diff --git a/src/Menus.cpp b/src/Menus.cpp index bf7732eab..b235ef5b4 100644 --- a/src/Menus.cpp +++ b/src/Menus.cpp @@ -429,6 +429,7 @@ CommandFlag MenuManager::GetUpdateFlags } // These flags are cheap to calculate. + auto gAudioIO = AudioIO::Get(); if (!gAudioIO->IsAudioTokenActive(ProjectAudioIO::Get( project ) .GetAudioIOToken())) flags |= AudioIONotBusyFlag; diff --git a/src/MixerBoard.cpp b/src/MixerBoard.cpp index e24244b85..6047a5c69 100644 --- a/src/MixerBoard.cpp +++ b/src/MixerBoard.cpp @@ -1350,6 +1350,7 @@ void MixerBoard::OnTimer(wxCommandEvent &event) // audacityAudioCallback where it calls gAudioIO->mOutputMeter->UpdateDisplay(). if (ProjectAudioIO::Get( *mProject ).IsAudioActive()) { + auto gAudioIO = AudioIOBase::Get(); UpdateMeters( gAudioIO->GetStreamTime(), (ControlToolBar::Get( *mProject ).GetLastPlayMode() diff --git a/src/ProjectAudioIO.cpp b/src/ProjectAudioIO.cpp index 564531482..af605f27d 100644 --- a/src/ProjectAudioIO.cpp +++ b/src/ProjectAudioIO.cpp @@ -10,7 +10,7 @@ Paul Licameli split from AudacityProject.cpp #include "ProjectAudioIO.h" -#include "AudioIO.h" +#include "AudioIOBase.h" #include "Project.h" static const AudacityProject::AttachedObjects::RegisteredFactory sAudioIOKey{ @@ -50,6 +50,7 @@ void ProjectAudioIO::SetAudioIOToken(int token) bool ProjectAudioIO::IsAudioActive() const { + auto gAudioIO = AudioIOBase::Get(); return GetAudioIOToken() > 0 && gAudioIO->IsStreamActive(GetAudioIOToken()); } @@ -63,6 +64,7 @@ void ProjectAudioIO::SetPlaybackMeter(MeterPanel *playback) { auto &project = mProject; mPlaybackMeter = playback; + auto gAudioIO = AudioIOBase::Get(); if (gAudioIO) { gAudioIO->SetPlaybackMeter( &project , mPlaybackMeter ); @@ -79,6 +81,7 @@ void ProjectAudioIO::SetCaptureMeter(MeterPanel *capture) auto &project = mProject; mCaptureMeter = capture; + auto gAudioIO = AudioIOBase::Get(); if (gAudioIO) { gAudioIO->SetCaptureMeter( &project, mCaptureMeter ); diff --git a/src/ProjectAudioManager.cpp b/src/ProjectAudioManager.cpp index 9f6e42c39..219ebd47e 100644 --- a/src/ProjectAudioManager.cpp +++ b/src/ProjectAudioManager.cpp @@ -96,6 +96,7 @@ void ProjectAudioManager::OnAudioIOStopRecording() if (projectAudioIO.GetAudioIOToken() > 0) { auto &tracks = TrackList::Get( project ); + auto gAudioIO = AudioIO::Get(); auto &intervals = gAudioIO->LostCaptureIntervals(); if (intervals.size()) { // Make a track with labels for recording errors @@ -185,6 +186,7 @@ AudioIOStartStreamOptions DefaultSpeedPlayOptions( AudacityProject &project ) { auto &projectAudioIO = ProjectAudioIO::Get( project ); + auto gAudioIO = AudioIO::Get(); auto PlayAtSpeedRate = gAudioIO->GetBestRate( false, //not capturing true, //is playing diff --git a/src/ProjectManager.cpp b/src/ProjectManager.cpp index af4c32cb0..a85b85b18 100644 --- a/src/ProjectManager.cpp +++ b/src/ProjectManager.cpp @@ -382,6 +382,7 @@ AudacityProject *ProjectManager::New() } //Initialise the Listeners + auto gAudioIO = AudioIO::Get(); gAudioIO->SetListener( &ProjectAudioManager::Get( project ) ); auto &projectSelectionManager = ProjectSelectionManager::Get( project ); SelectionBar::Get( project ).SetListener( &projectSelectionManager ); @@ -425,6 +426,7 @@ void ProjectManager::OnCloseWindow(wxCloseEvent & event) auto &projectAudioIO = ProjectAudioIO::Get( project ); auto &tracks = TrackList::Get( project ); auto &window = ProjectWindow::Get( project ); + auto gAudioIO = AudioIO::Get(); // We are called for the wxEVT_CLOSE_WINDOW, wxEVT_END_SESSION, and // wxEVT_QUERY_END_SESSION, so we have to protect against multiple @@ -760,6 +762,7 @@ void ProjectManager::OnTimer(wxTimerEvent& WXUNUSED(event)) auto &statusBar = *window.GetStatusBar(); + auto gAudioIO = AudioIO::Get(); // gAudioIO->GetNumCaptureChannels() should only be positive // when we are recording. if (projectAudioIO.GetAudioIOToken() > 0 && gAudioIO->GetNumCaptureChannels() > 0) { diff --git a/src/ProjectSettings.cpp b/src/ProjectSettings.cpp index 27d915730..6228bf37a 100644 --- a/src/ProjectSettings.cpp +++ b/src/ProjectSettings.cpp @@ -12,7 +12,7 @@ Paul Licameli split from AudacityProject.cpp #include "Experimental.h" -#include "AudioIO.h" +#include "AudioIOBase.h" #include "Project.h" #include "Snap.h" #include "prefs/QualityPrefs.h" @@ -65,7 +65,7 @@ ProjectSettings::ProjectSettings( AudacityProject &project ) , mSnapTo( gPrefs->Read(wxT("/SnapTo"), SNAP_OFF) ) { if (!gPrefs->Read(wxT("/SamplingRate/DefaultProjectSampleRate"), &mRate, - AudioIO::GetOptimalSupportedSampleRate())) { + AudioIOBase::GetOptimalSupportedSampleRate())) { // The default given above can vary with host/devices. So unless there is // an entry for the default sample rate in audacity.cfg, Audacity can open // with a rate which is different from the rate with which it closed. @@ -101,7 +101,7 @@ void ProjectSettings::UpdatePrefs() // Do not change this project's rate, unless there are no tracks. if( TrackList::Get( *this ).size() == 0){ gPrefs->Read(wxT("/SamplingRate/DefaultProjectSampleRate"), &mRate, - AudioIO::GetOptimalSupportedSampleRate()); + AudioIOBase::GetOptimalSupportedSampleRate()); // If necessary, we change this rate in the selection toolbar too. auto bar = SelectionBar::Get( *this ); bar.SetRate( mRate ); diff --git a/src/ProjectWindow.cpp b/src/ProjectWindow.cpp index 6a2e701e6..698083184 100644 --- a/src/ProjectWindow.cpp +++ b/src/ProjectWindow.cpp @@ -14,7 +14,7 @@ Paul Licameli split from AudacityProject.cpp #include "AdornedRulerPanel.h" #include "AllThemeResources.h" -#include "AudioIO.h" +#include "AudioIOBase.h" #include "Menus.h" #include "Project.h" #include "ProjectAudioIO.h" @@ -1555,6 +1555,7 @@ void ProjectWindow::TP_DisplaySelection() double audioTime; auto &playRegion = ViewInfo::Get( project ).playRegion; + auto gAudioIO = AudioIOBase::Get(); if (!gAudioIO->IsBusy() && !playRegion.Locked()) ruler.SetPlayRegion( selectedRegion.t0(), selectedRegion.t1() ); else @@ -1664,6 +1665,7 @@ void ProjectWindow::ZoomInByFactor( double ZoomFactor ) auto &trackPanel = TrackPanel::Get( project ); auto &viewInfo = ViewInfo::Get( project ); + auto gAudioIO = AudioIOBase::Get(); // LLL: Handling positioning differently when audio is // actively playing. Don't do this if paused. if (gAudioIO->IsStreamActive( diff --git a/src/TrackPanel.cpp b/src/TrackPanel.cpp index 4612d968b..a3723b78f 100644 --- a/src/TrackPanel.cpp +++ b/src/TrackPanel.cpp @@ -471,6 +471,7 @@ void TrackPanel::OnTimer(wxTimerEvent& ) auto &window = ProjectWindow::Get( *p ); auto &projectAudioIO = ProjectAudioIO::Get( *p ); + auto gAudioIO = AudioIO::Get(); // Check whether we were playing or recording, but the stream has stopped. if (projectAudioIO.GetAudioIOToken()>0 && !IsAudioActive()) diff --git a/src/ViewInfo.cpp b/src/ViewInfo.cpp index a2ce0f489..fb7d88686 100644 --- a/src/ViewInfo.cpp +++ b/src/ViewInfo.cpp @@ -14,7 +14,7 @@ Paul Licameli #include -#include "AudioIO.h" +#include "AudioIOBase.h" #include "prefs/GUISettings.h" #include "Prefs.h" #include "Project.h" @@ -245,6 +245,7 @@ bool ViewInfo::ReadXMLAttribute(const wxChar *attr, const wxChar *value) void ViewInfo::OnTimer(wxCommandEvent &event) { + auto gAudioIO = AudioIOBase::Get(); mRecentStreamTime = gAudioIO->GetStreamTime(); event.Skip(); // Propagate the message to other listeners bound to this diff --git a/src/effects/Effect.cpp b/src/effects/Effect.cpp index fe97e6052..e6f98e516 100644 --- a/src/effects/Effect.cpp +++ b/src/effects/Effect.cpp @@ -2494,6 +2494,7 @@ void Effect::Preview(bool dryOnly) return; } + auto gAudioIO = AudioIO::Get(); if (gAudioIO->IsBusy()) { return; } @@ -2994,6 +2995,7 @@ bool EffectUIHost::Initialize() w->SetMinSize(wxSize(wxMax(600, mParent->GetSize().GetWidth() * 2 / 3), mParent->GetSize().GetHeight() / 2)); + auto gAudioIO = AudioIO::Get(); mDisableTransport = !gAudioIO->IsAvailable(mProject); mPlaying = gAudioIO->IsStreamActive(); // not exactly right, but will suffice mCapturing = gAudioIO->IsStreamActive() && gAudioIO->GetNumCaptureChannels() > 0; @@ -3504,6 +3506,7 @@ void EffectUIHost::OnPlay(wxCommandEvent & WXUNUSED(evt)) if (mPlaying) { + auto gAudioIO = AudioIO::Get(); mPlayPos = gAudioIO->GetStreamTime(); auto &bar = ControlToolBar::Get( *mProject ); bar.StopPlaying(); @@ -3542,6 +3545,7 @@ void EffectUIHost::OnRewind(wxCommandEvent & WXUNUSED(evt)) { if (mPlaying) { + auto gAudioIO = AudioIO::Get(); double seek; gPrefs->Read(wxT("/AudioIO/SeekShortPeriod"), &seek, 1.0); @@ -3566,6 +3570,7 @@ void EffectUIHost::OnFFwd(wxCommandEvent & WXUNUSED(evt)) double seek; gPrefs->Read(wxT("/AudioIO/SeekShortPeriod"), &seek, 1.0); + auto gAudioIO = AudioIO::Get(); double pos = gAudioIO->GetStreamTime(); if (mRegion.t0() < mRegion.t1() && pos + seek > mRegion.t1()) { diff --git a/src/menus/HelpMenus.cpp b/src/menus/HelpMenus.cpp index c6add9ad9..3320e126f 100644 --- a/src/menus/HelpMenus.cpp +++ b/src/menus/HelpMenus.cpp @@ -8,7 +8,7 @@ #include "../AboutDialog.h" #include "../AllThemeResources.h" #include "../AudacityLogger.h" -#include "../AudioIO.h" +#include "../AudioIOBase.h" #include "../CrashReport.h" #include "../Dependencies.h" #include "../FileNames.h" @@ -316,6 +316,7 @@ void OnManual(const CommandContext &context) void OnAudioDeviceInfo(const CommandContext &context) { auto &project = context.project; + auto gAudioIO = AudioIOBase::Get(); wxString info = gAudioIO->GetDeviceInfo(); ShowDiagnostics( project, info, _("Audio Device Info"), wxT("deviceinfo.txt") ); @@ -325,6 +326,7 @@ void OnAudioDeviceInfo(const CommandContext &context) void OnMidiDeviceInfo(const CommandContext &context) { auto &project = context.project; + auto gAudioIO = AudioIOBase::Get(); wxString info = gAudioIO->GetMidiDeviceInfo(); ShowDiagnostics( project, info, _("MIDI Device Info"), wxT("midideviceinfo.txt") ); diff --git a/src/menus/LabelMenus.cpp b/src/menus/LabelMenus.cpp index 12fbe2fa6..30212029b 100644 --- a/src/menus/LabelMenus.cpp +++ b/src/menus/LabelMenus.cpp @@ -1,4 +1,4 @@ -#include "../AudioIO.h" +#include "../AudioIOBase.h" #include "../Clipboard.h" #include "../LabelTrack.h" #include "../Menus.h" @@ -271,6 +271,7 @@ void OnAddLabelPlaying(const CommandContext &context) auto &project = context.project; auto token = ProjectAudioIO::Get( project ).GetAudioIOToken(); + auto gAudioIO = AudioIOBase::Get(); if (token > 0 && gAudioIO->IsStreamActive(token)) { double indicator = gAudioIO->GetStreamTime(); diff --git a/src/menus/PluginMenus.cpp b/src/menus/PluginMenus.cpp index d5f2ecc17..60813cea8 100644 --- a/src/menus/PluginMenus.cpp +++ b/src/menus/PluginMenus.cpp @@ -695,6 +695,7 @@ void OnSimulateRecordingErrors(const CommandContext &context) auto &project = context.project; auto &commandManager = CommandManager::Get( project ); + auto gAudioIO = AudioIO::Get(); bool &setting = gAudioIO->mSimulateRecordingErrors; commandManager.Check(wxT("SimulateRecordingErrors"), !setting); setting = !setting; @@ -705,6 +706,7 @@ void OnDetectUpstreamDropouts(const CommandContext &context) auto &project = context.project; auto &commandManager = CommandManager::Get( project ); + auto gAudioIO = AudioIO::Get(); bool &setting = gAudioIO->mDetectUpstreamDropouts; commandManager.Check(wxT("DetectUpstreamDropouts"), !setting); setting = !setting; @@ -991,6 +993,7 @@ MenuTable::BaseItemPtr ToolsMenu( AudacityProject & ) { using namespace MenuTable; using Options = CommandManager::Options; + auto gAudioIO = AudioIO::Get(); return Menu( _("T&ools"), diff --git a/src/menus/SelectMenus.cpp b/src/menus/SelectMenus.cpp index 31630a2c5..f35fbc7cd 100644 --- a/src/menus/SelectMenus.cpp +++ b/src/menus/SelectMenus.cpp @@ -211,6 +211,7 @@ struct SeekInfo void SeekWhenAudioActive(double seekStep, wxLongLong &lastSelectionAdjustment) { + auto gAudioIO = AudioIO::Get(); #ifdef EXPERIMENTAL_IMPROVED_SEEKING if (gAudioIO->GetLastPlaybackTime() < lastSelectionAdjustment) { // Allow time for the last seek to output a buffer before @@ -451,6 +452,7 @@ void DoBoundaryMove(AudacityProject &project, int step, SeekInfo &info) if( ProjectAudioIO::Get( project ).IsAudioActive() ) { + auto gAudioIO = AudioIO::Get(); double indicator = gAudioIO->GetStreamTime(); if( bMoveT0 ) viewInfo.selectedRegion.setT0(indicator, false); @@ -627,6 +629,7 @@ void OnSetLeftSelection(const CommandContext &context) auto &window = GetProjectFrame( project ); bool bSelChanged = false; + auto gAudioIO = AudioIOBase::Get(); if ((token > 0) && gAudioIO->IsStreamActive(token)) { double indicator = gAudioIO->GetStreamTime(); @@ -667,6 +670,7 @@ void OnSetRightSelection(const CommandContext &context) auto &window = GetProjectFrame( project ); bool bSelChanged = false; + auto gAudioIO = AudioIOBase::Get(); if ((token > 0) && gAudioIO->IsStreamActive(token)) { double indicator = gAudioIO->GetStreamTime(); @@ -853,6 +857,7 @@ void OnSelectCursorStoredCursor(const CommandContext &context) auto isAudioActive = ProjectAudioIO::Get( project ).IsAudioActive(); if (mCursorPositionHasBeenStored) { + auto gAudioIO = AudioIO::Get(); double cursorPositionCurrent = isAudioActive ? gAudioIO->GetStreamTime() : selectedRegion.t0(); @@ -871,6 +876,7 @@ void OnCursorPositionStore(const CommandContext &context) auto &selectedRegion = ViewInfo::Get( project ).selectedRegion; auto isAudioActive = ProjectAudioIO::Get( project ).IsAudioActive(); + auto gAudioIO = AudioIO::Get(); mCursorPositionStored = isAudioActive ? gAudioIO->GetStreamTime() : selectedRegion.t0(); mCursorPositionHasBeenStored = true; diff --git a/src/menus/TransportMenus.cpp b/src/menus/TransportMenus.cpp index b52946e1d..a55bda429 100644 --- a/src/menus/TransportMenus.cpp +++ b/src/menus/TransportMenus.cpp @@ -47,6 +47,7 @@ bool MakeReadyToPlay(AudacityProject &project, wxCommandEvent evt; // If this project is playing, stop playing + auto gAudioIO = AudioIOBase::Get(); if (gAudioIO->IsStreamActive( ProjectAudioIO::Get( project ).GetAudioIOToken() )) { @@ -92,6 +93,7 @@ void DoPlayStop(const CommandContext &context) auto token = ProjectAudioIO::Get( project ).GetAudioIOToken(); //If this project is playing, stop playing, make sure everything is unpaused. + auto gAudioIO = AudioIOBase::Get(); if (gAudioIO->IsStreamActive(token)) { toolbar.SetPlay(false); //Pops toolbar.SetStop(true); //Pushes stop down @@ -104,7 +106,7 @@ void DoPlayStop(const CommandContext &context) //find out which project we need; auto start = AllProjects{}.begin(), finish = AllProjects{}.end(), iter = std::find_if( start, finish, - []( const AllProjects::value_type &ptr ){ + [&]( const AllProjects::value_type &ptr ){ return gAudioIO->IsStreamActive( ProjectAudioIO::Get( *ptr ).GetAudioIOToken()); } ); @@ -219,6 +221,7 @@ bool DoPlayStopSelect auto token = ProjectAudioIO::Get( project ).GetAudioIOToken(); auto &viewInfo = ViewInfo::Get( project ); auto &selection = viewInfo.selectedRegion; + auto gAudioIO = AudioIOBase::Get(); //If busy, stop playing, make sure everything is unpaused. if (scrubber.HasMark() || @@ -274,6 +277,7 @@ void DoPlayStopSelect(AudacityProject &project) { auto &toolbar = ControlToolBar::Get( project ); wxCommandEvent evt; + auto gAudioIO = AudioIO::Get(); if (DoPlayStopSelect(project, false, false)) toolbar.OnStop(evt); else if (!gAudioIO->IsBusy()) { @@ -511,6 +515,7 @@ void OnPunchAndRoll(const CommandContext &context) static const auto url = wxT("Punch_and_Roll_Record#Using_Punch_and_Roll_Record"); + auto gAudioIO = AudioIO::Get(); if (gAudioIO->IsBusy()) return; @@ -1034,6 +1039,7 @@ void OnStopSelect(const CommandContext &context) auto &selectedRegion = viewInfo.selectedRegion; wxCommandEvent evt; + auto gAudioIO = AudioIOBase::Get(); if (gAudioIO->IsStreamActive()) { auto &controlToolbar = ControlToolBar::Get( project ); selectedRegion.setT0(gAudioIO->GetStreamTime(), false); diff --git a/src/prefs/PrefsDialog.cpp b/src/prefs/PrefsDialog.cpp index 43a298215..4dda5edee 100644 --- a/src/prefs/PrefsDialog.cpp +++ b/src/prefs/PrefsDialog.cpp @@ -814,6 +814,7 @@ void PrefsDialog::OnOK(wxCommandEvent & WXUNUSED(event)) SavePreferredPage(); #if USE_PORTMIXER + auto gAudioIO = AudioIO::Get(); if (gAudioIO) { // We cannot have opened this dialog if gAudioIO->IsAudioTokenActive(), // per the setting of AudioIONotBusyFlag and AudioIOBusyFlag in diff --git a/src/prefs/QualityPrefs.cpp b/src/prefs/QualityPrefs.cpp index 2694c697d..97ff08699 100644 --- a/src/prefs/QualityPrefs.cpp +++ b/src/prefs/QualityPrefs.cpp @@ -22,7 +22,7 @@ #include #include -#include "../AudioIO.h" +#include "../AudioIOBase.h" #include "../Dither.h" #include "../Prefs.h" #include "../Resample.h" @@ -92,7 +92,7 @@ void QualityPrefs::Populate() GetNamesAndLabels(); gPrefs->Read(wxT("/SamplingRate/DefaultProjectSampleRate"), &mOtherSampleRateValue, - AudioIO::GetOptimalSupportedSampleRate()); + AudioIOBase::GetOptimalSupportedSampleRate()); //------------------------- Main section -------------------- // Now construct the GUI itself. @@ -126,8 +126,8 @@ void QualityPrefs::GetNamesAndLabels() // // GetSupportedSampleRates() allows passing in device names, but // how do you get at them as they are on the Audio I/O page???? - for (int i = 0; i < AudioIO::NumStandardRates; i++) { - int iRate = AudioIO::StandardRates[i]; + for (int i = 0; i < AudioIOBase::NumStandardRates; i++) { + int iRate = AudioIOBase::StandardRates[i]; mSampleRateLabels.push_back(iRate); mSampleRateNames.push_back(wxString::Format(wxT("%i Hz"), iRate)); } @@ -160,7 +160,7 @@ void QualityPrefs::PopulateOrExchange(ShuttleGui & S) // We make sure we have a pointer to it, so that we can drive it. mSampleRates = S.TieNumberAsChoice( {}, wxT("/SamplingRate/DefaultProjectSampleRate"), - AudioIO::GetOptimalSupportedSampleRate(), + AudioIOBase::GetOptimalSupportedSampleRate(), mSampleRateNames, mSampleRateLabels); diff --git a/src/toolbars/ControlToolBar.cpp b/src/toolbars/ControlToolBar.cpp index 7e1842956..959a981c9 100644 --- a/src/toolbars/ControlToolBar.cpp +++ b/src/toolbars/ControlToolBar.cpp @@ -481,6 +481,7 @@ void ControlToolBar::EnableDisableButtons() bool paused = mPause->IsDown(); bool playing = mPlay->IsDown(); bool recording = mRecord->IsDown(); + auto gAudioIO = AudioIO::Get(); bool busy = gAudioIO->IsBusy(); // Only interested in audio type tracks @@ -609,6 +610,7 @@ int ControlToolBar::PlayPlayRegion(const SelectedRegion &selectedRegion, } } ); + auto gAudioIO = AudioIO::Get(); if (gAudioIO->IsBusy()) return -1; @@ -787,6 +789,8 @@ void ControlToolBar::OnKeyEvent(wxKeyEvent & event) return; } + auto gAudioIO = AudioIOBase::Get(); + // Does not appear to be needed on Linux. Perhaps on some other platform? // If so, "!CanStopAudioStream()" should probably apply. if (event.GetKeyCode() == WXK_SPACE) { @@ -833,6 +837,7 @@ void ControlToolBar::OnStop(wxCommandEvent & WXUNUSED(evt)) bool ControlToolBar::CanStopAudioStream() { + auto gAudioIO = AudioIO::Get(); return (!gAudioIO->IsStreamActive() || gAudioIO->IsMonitoring() || gAudioIO->GetOwningProject() == GetActiveProject()); @@ -864,6 +869,8 @@ void ControlToolBar::StopPlaying(bool stopStream /* = true*/) mStop->PushDown(); + auto gAudioIO = AudioIO::Get(); + SetStop(false); if(stopStream) gAudioIO->StopStream(); @@ -903,8 +910,10 @@ void ControlToolBar::StopPlaying(bool stopStream /* = true*/) void ControlToolBar::Pause() { - if (!CanStopAudioStream()) + if (!CanStopAudioStream()) { + auto gAudioIO = AudioIO::Get(); gAudioIO->SetPaused(!gAudioIO->IsPaused()); + } else { wxCommandEvent dummy; OnPause(dummy); @@ -1095,6 +1104,7 @@ bool ControlToolBar::DoRecord(AudacityProject &project, return false; // ...end of code from CommandHandler. + auto gAudioIO = AudioIO::Get(); if (gAudioIO->IsBusy()) { if (!CanStopAudioStream() || 0 == gAudioIO->GetNumCaptureChannels()) mRecord->PopUp(); @@ -1301,6 +1311,8 @@ void ControlToolBar::OnPause(wxCommandEvent & WXUNUSED(evt)) mPaused=true; } + auto gAudioIO = AudioIO::Get(); + #ifdef EXPERIMENTAL_SCRUBBING_SUPPORT auto project = GetActiveProject(); @@ -1480,6 +1492,7 @@ void ControlToolBar::StartScrolling() using Mode = ProjectWindow::PlaybackScroller::Mode; const auto project = GetActiveProject(); if (project) { + auto gAudioIO = AudioIO::Get(); auto mode = Mode::Pinned; #if 0 diff --git a/src/toolbars/DeviceToolBar.cpp b/src/toolbars/DeviceToolBar.cpp index 9c995e762..f64b7537f 100644 --- a/src/toolbars/DeviceToolBar.cpp +++ b/src/toolbars/DeviceToolBar.cpp @@ -341,6 +341,7 @@ void DeviceToolBar::UpdateSelectedPrefs( int id ) void DeviceToolBar::EnableDisableButtons() { + auto gAudioIO = AudioIO::Get(); if (gAudioIO) { // we allow changes when monitoring, but not when recording bool audioStreamActive = gAudioIO->IsStreamActive() && !gAudioIO->IsMonitoring(); @@ -775,6 +776,7 @@ void DeviceToolBar::OnChoice(wxCommandEvent &event) ChangeDevice(false); } + auto gAudioIO = AudioIO::Get(); if (gAudioIO) { // We cannot have gotten here if gAudioIO->IsAudioTokenActive(), // per the setting of AudioIONotBusyFlag and AudioIOBusyFlag in diff --git a/src/toolbars/MixerToolBar.cpp b/src/toolbars/MixerToolBar.cpp index f0b6b260c..c50cf8676 100644 --- a/src/toolbars/MixerToolBar.cpp +++ b/src/toolbars/MixerToolBar.cpp @@ -120,6 +120,7 @@ void MixerToolBar::Populate() &MixerToolBar::OnFocus, this); // Show or hide the input slider based on whether it works + auto gAudioIO = AudioIO::Get(); mInputSlider->Enable(gAudioIO->InputMixerWorks()); UpdateControls(); @@ -164,6 +165,7 @@ void MixerToolBar::UpdatePrefs() int inputSource; // Reset the selected source + auto gAudioIO = AudioIO::Get(); gAudioIO->GetMixer(&inputSource, &inputVolume, &playbackVolume); // Show or hide the input slider based on whether it works @@ -210,6 +212,7 @@ void MixerToolBar::UpdateControls() int inputSource; // Show or hide the input slider based on whether it works + auto gAudioIO = AudioIO::Get(); mInputSlider->Enable(gAudioIO->InputMixerWorks()); gAudioIO->GetMixer(&inputSource, &inputVolume, &playbackVolume); @@ -236,6 +239,7 @@ void MixerToolBar::SetMixer(wxCommandEvent & WXUNUSED(event)) float oldIn, oldOut; int inputSource; + auto gAudioIO = AudioIO::Get(); gAudioIO->GetMixer(&inputSource, &oldIn, &oldOut); gAudioIO->SetMixer(inputSource, inputVolume, outputVolume); mOutputSliderVolume = outputVolume; @@ -297,6 +301,7 @@ void MixerToolBar::SetToolTips() if (mOutputSlider->IsEnabled()) { wxString format; + auto gAudioIO = AudioIO::Get(); if (gAudioIO->OutputMixerEmulated()) format = _("Playback Volume: %s (emulated)"); else diff --git a/src/toolbars/SelectionBar.cpp b/src/toolbars/SelectionBar.cpp index 066278664..ba8404a7b 100644 --- a/src/toolbars/SelectionBar.cpp +++ b/src/toolbars/SelectionBar.cpp @@ -52,7 +52,7 @@ with changes in the SelectionBar. #include "../widgets/AButton.h" -#include "../AudioIO.h" +#include "../AudioIOBase.h" #include "../AColor.h" #include "../KeyboardCapture.h" #include "../Prefs.h" @@ -120,7 +120,7 @@ SelectionBar::SelectionBar() // Audacity to fail. // We expect mRate to be set from the project later. mRate = (double) gPrefs->Read(wxT("/SamplingRate/DefaultProjectSampleRate"), - AudioIO::GetOptimalSupportedSampleRate()); + AudioIOBase::GetOptimalSupportedSampleRate()); // Selection mode of 0 means showing 'start' and 'end' only. mSelectionMode = gPrefs->ReadLong(wxT("/SelectionToolbarMode"), 0); @@ -711,8 +711,9 @@ void SelectionBar::UpdateRates() { wxString oldValue = mRateBox->GetValue(); mRateBox->Clear(); - for (int i = 0; i < AudioIO::NumStandardRates; i++) { - mRateBox->Append(wxString::Format(wxT("%d"), AudioIO::StandardRates[i])); + for (int i = 0; i < AudioIOBase::NumStandardRates; i++) { + mRateBox->Append( + wxString::Format(wxT("%d"), AudioIOBase::StandardRates[i])); } mRateBox->SetValue(oldValue); } diff --git a/src/toolbars/TranscriptionToolBar.cpp b/src/toolbars/TranscriptionToolBar.cpp index ca3fcea8c..75417d5bc 100644 --- a/src/toolbars/TranscriptionToolBar.cpp +++ b/src/toolbars/TranscriptionToolBar.cpp @@ -35,7 +35,7 @@ #include "ControlToolBar.h" #include "../AllThemeResources.h" -#include "../AudioIO.h" +#include "../AudioIOBase.h" #include "../ImageManipulation.h" #include "../KeyboardCapture.h" #include "../Project.h" @@ -381,6 +381,7 @@ void TranscriptionToolBar::OnKeyEvent(wxKeyEvent & event) } if (event.GetKeyCode() == WXK_SPACE) { + auto gAudioIO = AudioIOBase::Get(); if (gAudioIO->IsBusy()) { /*Do Stuff Here*/ } @@ -485,6 +486,7 @@ void TranscriptionToolBar::PlayAtSpeed(bool looped, bool cutPreview) SetButton(false, mButtons[TTB_PlaySpeed]); // If IO is busy, abort immediately + auto gAudioIO = AudioIOBase::Get(); if (gAudioIO->IsBusy()) { auto &bar = ControlToolBar::Get( *p ); bar.StopPlaying(); @@ -541,6 +543,7 @@ void TranscriptionToolBar::OnSpeedSlider(wxCommandEvent& WXUNUSED(event)) // If IO is busy, abort immediately // AWD: This is disabled to work around a hang on Linux when PulseAudio is // used. If we figure that one out we can re-enable this code. + // auto gAudioIO = AudioIOBase::Get(); //if (gAudioIO->IsBusy()) { // OnPlaySpeed(event); //} @@ -550,6 +553,7 @@ void TranscriptionToolBar::OnSpeedSlider(wxCommandEvent& WXUNUSED(event)) void TranscriptionToolBar::OnStartOn(wxCommandEvent & WXUNUSED(event)) { //If IO is busy, abort immediately + auto gAudioIO = AudioIOBase::Get(); if (gAudioIO->IsBusy()){ SetButton(false,mButtons[TTB_StartOn]); return; @@ -582,6 +586,7 @@ void TranscriptionToolBar::OnStartOn(wxCommandEvent & WXUNUSED(event)) void TranscriptionToolBar::OnStartOff(wxCommandEvent & WXUNUSED(event)) { //If IO is busy, abort immediately + auto gAudioIO = AudioIOBase::Get(); if (gAudioIO->IsBusy()){ SetButton(false,mButtons[TTB_StartOff]); return; @@ -615,6 +620,7 @@ void TranscriptionToolBar::OnEndOn(wxCommandEvent & WXUNUSED(event)) { //If IO is busy, abort immediately + auto gAudioIO = AudioIOBase::Get(); if (gAudioIO->IsBusy()){ SetButton(false,mButtons[TTB_EndOn]); return; @@ -650,6 +656,7 @@ void TranscriptionToolBar::OnEndOff(wxCommandEvent & WXUNUSED(event)) { //If IO is busy, abort immediately + auto gAudioIO = AudioIOBase::Get(); if (gAudioIO->IsBusy()){ SetButton(false,mButtons[TTB_EndOff]); return; @@ -684,6 +691,7 @@ void TranscriptionToolBar::OnSelectSound(wxCommandEvent & WXUNUSED(event)) { //If IO is busy, abort immediately + auto gAudioIO = AudioIOBase::Get(); if (gAudioIO->IsBusy()){ SetButton(false,mButtons[TTB_SelectSound]); return; @@ -723,6 +731,7 @@ void TranscriptionToolBar::OnSelectSilence(wxCommandEvent & WXUNUSED(event)) { //If IO is busy, abort immediately + auto gAudioIO = AudioIOBase::Get(); if (gAudioIO->IsBusy()){ SetButton(false,mButtons[TTB_SelectSilence]); return; @@ -761,6 +770,7 @@ void TranscriptionToolBar::OnSelectSilence(wxCommandEvent & WXUNUSED(event)) void TranscriptionToolBar::OnCalibrate(wxCommandEvent & WXUNUSED(event)) { //If IO is busy, abort immediately + auto gAudioIO = AudioIOBase::Get(); if (gAudioIO->IsBusy()){ SetButton(false,mButtons[TTB_Calibrate]); return; @@ -808,6 +818,7 @@ void TranscriptionToolBar::OnAutomateSelection(wxCommandEvent & WXUNUSED(event)) //If IO is busy, abort immediately + auto gAudioIO = AudioIOBase::Get(); if (gAudioIO->IsBusy()) { SetButton(false,mButtons[TTB_EndOff]); diff --git a/src/tracks/playabletrack/wavetrack/ui/WaveTrackControls.cpp b/src/tracks/playabletrack/wavetrack/ui/WaveTrackControls.cpp index aa2b7c8b1..a8ef3f2ff 100644 --- a/src/tracks/playabletrack/wavetrack/ui/WaveTrackControls.cpp +++ b/src/tracks/playabletrack/wavetrack/ui/WaveTrackControls.cpp @@ -16,7 +16,7 @@ Paul Licameli split from TrackPanel.cpp #include "../../ui/PlayableTrackButtonHandles.h" #include "WaveTrackSliderHandles.h" -#include "../../../../AudioIO.h" +#include "../../../../AudioIOBase.h" #include "../../../../Menus.h" #include "../../../../Project.h" #include "../../../../ProjectAudioIO.h" @@ -604,6 +604,7 @@ void WaveTrackMenuTable::InitMenu(Menu *pMenu, void *pUserData) // Bug 1253. Shouldn't open preferences if audio is busy. // We can't change them on the fly yet anyway. + auto gAudioIO = AudioIOBase::Get(); const bool bAudioBusy = gAudioIO->IsBusy(); pMenu->Enable(OnSpectrogramSettingsID, (display == WaveTrack::Spectrum) && !bAudioBusy); @@ -776,6 +777,7 @@ void WaveTrackMenuTable::OnSpectrogramSettings(wxCommandEvent &) const int mPage; }; + auto gAudioIO = AudioIOBase::Get(); if (gAudioIO->IsBusy()){ AudacityMessageBox(_("To change Spectrogram Settings, stop any\n" "playing or recording first."), diff --git a/src/tracks/ui/PlayIndicatorOverlay.cpp b/src/tracks/ui/PlayIndicatorOverlay.cpp index 813cea1d6..cb6aa060f 100644 --- a/src/tracks/ui/PlayIndicatorOverlay.cpp +++ b/src/tracks/ui/PlayIndicatorOverlay.cpp @@ -69,6 +69,7 @@ std::pair PlayIndicatorOverlayBase::DoGetRectangle(wxSize size) void PlayIndicatorOverlayBase::Draw(OverlayPanel &panel, wxDC &dc) { // Set play/record color + auto gAudioIO = AudioIO::Get(); bool rec = gAudioIO->IsCapturing(); AColor::IndicatorColor(&dc, !rec); @@ -186,6 +187,8 @@ void PlayIndicatorOverlay::OnTimer(wxCommandEvent &event) // This displays the audio time, too... window.TP_DisplaySelection(); + auto gAudioIO = AudioIO::Get(); + // BG: Scroll screen if option is set if( viewInfo.bUpdateTrackIndicator && playPos >= 0 && !onScreen ) { diff --git a/src/tracks/ui/Scrubbing.cpp b/src/tracks/ui/Scrubbing.cpp index 6eb617120..6da5ec7b5 100644 --- a/src/tracks/ui/Scrubbing.cpp +++ b/src/tracks/ui/Scrubbing.cpp @@ -344,6 +344,7 @@ bool Scrubber::MaybeStartScrubbing(wxCoord xx) const auto state = ::wxGetMouseState(); mDragging = state.LeftIsDown(); + auto gAudioIO = AudioIO::Get(); const bool busy = gAudioIO->IsBusy(); if (busy && gAudioIO->GetNumCaptureChannels() > 0) { // Do not stop recording, and don't try to start scrubbing after @@ -468,6 +469,7 @@ bool Scrubber::StartSpeedPlay(double speed, double time0, double time1) if (IsScrubbing()) return false; + auto gAudioIO = AudioIO::Get(); const bool busy = gAudioIO->IsBusy(); if (busy && gAudioIO->GetNumCaptureChannels() > 0) { // Do not stop recording, and don't try to start scrubbing after @@ -545,6 +547,7 @@ void Scrubber::ContinueScrubbingPoll() // timer callback, to a left click event detected elsewhere.) const bool seek = TemporarilySeeks() || Seeks(); + auto gAudioIO = AudioIO::Get(); if (mPaused) { // When paused, make silent scrubs. mOptions.minSpeed = 0.0; @@ -691,6 +694,7 @@ void Scrubber::StopPolling() void Scrubber::StopScrubbing() { + auto gAudioIO = AudioIO::Get(); gAudioIO->StopScrub(); StopPolling(); diff --git a/src/widgets/Meter.cpp b/src/widgets/Meter.cpp index e69046835..227dc462a 100644 --- a/src/widgets/Meter.cpp +++ b/src/widgets/Meter.cpp @@ -1066,6 +1066,8 @@ void MeterPanel::OnMeterUpdate(wxTimerEvent & WXUNUSED(event)) return; } + auto gAudioIO = AudioIO::Get(); + // There may have been several update messages since the last // time we got to this function. Catch up to real-time by // popping them off until there are none left. It is necessary @@ -1866,6 +1868,7 @@ void MeterPanel::StartMonitoring() { bool start = !mMonitoring; + auto gAudioIO = AudioIO::Get(); if (gAudioIO->IsMonitoring()){ gAudioIO->StopStream(); } @@ -1884,6 +1887,7 @@ void MeterPanel::StartMonitoring() void MeterPanel::StopMonitoring(){ mMonitoring = false; + auto gAudioIO = AudioIO::Get(); if (gAudioIO->IsMonitoring()){ gAudioIO->StopStream(); } diff --git a/win/Projects/Audacity/Audacity.vcxproj b/win/Projects/Audacity/Audacity.vcxproj index 28749d3bf..3758df4e8 100755 --- a/win/Projects/Audacity/Audacity.vcxproj +++ b/win/Projects/Audacity/Audacity.vcxproj @@ -129,6 +129,7 @@ + @@ -506,6 +507,7 @@ + diff --git a/win/Projects/Audacity/Audacity.vcxproj.filters b/win/Projects/Audacity/Audacity.vcxproj.filters index 55f74aa69..eca92ee16 100755 --- a/win/Projects/Audacity/Audacity.vcxproj.filters +++ b/win/Projects/Audacity/Audacity.vcxproj.filters @@ -128,6 +128,9 @@ src + + src + src @@ -1213,6 +1216,9 @@ src + + src + src