From ccc49f8ccf3b69d7fd02d5343e61a13fed3faeed Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Mon, 10 Jun 2019 17:36:54 -0400 Subject: [PATCH] Abstract virtual AudioIOBase::StopStream... ... so that DeviceManager, DeviceToolbar, and PrefsDialog do not depend directly on AudioIO. But no function in the base class for starting streams, which would require mention of Track types, which we want to avoid. --- src/AudioIO.h | 2 +- src/AudioIOBase.cpp | 2 ++ src/AudioIOBase.h | 4 ++++ src/DeviceManager.cpp | 4 ++-- src/prefs/PrefsDialog.cpp | 4 ++-- src/toolbars/DeviceToolBar.cpp | 6 +++--- 6 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/AudioIO.h b/src/AudioIO.h index fc579fc4f..c5de9bd2b 100644 --- a/src/AudioIO.h +++ b/src/AudioIO.h @@ -586,7 +586,7 @@ public: * Does quite a bit of housekeeping, including switching off monitoring, * flushing recording buffers out to wave tracks, and applies latency * correction to recorded tracks if necessary */ - void StopStream(); + void StopStream() override; /** \brief Move the playback / recording position of the current stream * by the specified amount from where it is now */ void SeekStream(double seconds) { mSeek = seconds; } diff --git a/src/AudioIOBase.cpp b/src/AudioIOBase.cpp index f9390ba68..3d02d6a3c 100644 --- a/src/AudioIOBase.cpp +++ b/src/AudioIOBase.cpp @@ -96,6 +96,8 @@ AudioIOBase *AudioIOBase::Get() return ugAudioIO.get(); } +AudioIOBase::~AudioIOBase() = default; + void AudioIOBase::SetMixer(int inputSource) { #if defined(USE_PORTMIXER) diff --git a/src/AudioIOBase.h b/src/AudioIOBase.h index ad9432d7c..281516867 100644 --- a/src/AudioIOBase.h +++ b/src/AudioIOBase.h @@ -111,6 +111,8 @@ class AudioIOBase /* not final */ public: static AudioIOBase *Get(); + virtual ~AudioIOBase(); + void SetCaptureMeter(AudacityProject *project, MeterPanelBase *meter); void SetPlaybackMeter(AudacityProject *project, MeterPanelBase *meter); @@ -211,6 +213,8 @@ public: /** \brief Find out if playback / recording is currently paused */ bool IsPaused() const; + virtual void StopStream() = 0; + /** \brief Returns true if audio i/o is busy starting, stopping, playing, * or recording. * diff --git a/src/DeviceManager.cpp b/src/DeviceManager.cpp index c2143922b..ff6a7ad3d 100644 --- a/src/DeviceManager.cpp +++ b/src/DeviceManager.cpp @@ -35,7 +35,7 @@ #include "Project.h" -#include "AudioIO.h" +#include "AudioIOBase.h" #include "DeviceChange.h" // for HAVE_DEVICE_CHANGE #include "toolbars/DeviceToolBar.h" @@ -259,7 +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(); + auto gAudioIO = AudioIOBase::Get(); if (gAudioIO) { if (gAudioIO->IsMonitoring()) { diff --git a/src/prefs/PrefsDialog.cpp b/src/prefs/PrefsDialog.cpp index 4dda5edee..8eb749af7 100644 --- a/src/prefs/PrefsDialog.cpp +++ b/src/prefs/PrefsDialog.cpp @@ -34,7 +34,7 @@ #include -#include "../AudioIO.h" +#include "../AudioIOBase.h" #include "../Prefs.h" #include "../ShuttleGui.h" @@ -814,7 +814,7 @@ void PrefsDialog::OnOK(wxCommandEvent & WXUNUSED(event)) SavePreferredPage(); #if USE_PORTMIXER - auto gAudioIO = AudioIO::Get(); + auto gAudioIO = AudioIOBase::Get(); if (gAudioIO) { // We cannot have opened this dialog if gAudioIO->IsAudioTokenActive(), // per the setting of AudioIONotBusyFlag and AudioIOBusyFlag in diff --git a/src/toolbars/DeviceToolBar.cpp b/src/toolbars/DeviceToolBar.cpp index f64b7537f..7d59d080c 100644 --- a/src/toolbars/DeviceToolBar.cpp +++ b/src/toolbars/DeviceToolBar.cpp @@ -39,7 +39,7 @@ #include "../AColor.h" #include "../AllThemeResources.h" -#include "../AudioIO.h" +#include "../AudioIOBase.h" #include "../ImageManipulation.h" #include "../KeyboardCapture.h" #include "../Prefs.h" @@ -341,7 +341,7 @@ void DeviceToolBar::UpdateSelectedPrefs( int id ) void DeviceToolBar::EnableDisableButtons() { - auto gAudioIO = AudioIO::Get(); + auto gAudioIO = AudioIOBase::Get(); if (gAudioIO) { // we allow changes when monitoring, but not when recording bool audioStreamActive = gAudioIO->IsStreamActive() && !gAudioIO->IsMonitoring(); @@ -776,7 +776,7 @@ void DeviceToolBar::OnChoice(wxCommandEvent &event) ChangeDevice(false); } - auto gAudioIO = AudioIO::Get(); + auto gAudioIO = AudioIOBase::Get(); if (gAudioIO) { // We cannot have gotten here if gAudioIO->IsAudioTokenActive(), // per the setting of AudioIONotBusyFlag and AudioIOBusyFlag in