mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-17 08:30:06 +02:00
Separate an abstract base class from MeterPanel...
... to break its cycle with AudioIO
This commit is contained in:
parent
51051ee933
commit
17c04d1749
@ -306,7 +306,7 @@ void AudioIOBase::HandleDeviceChange()
|
||||
#endif // USE_PORTMIXER
|
||||
}
|
||||
|
||||
void AudioIOBase::SetCaptureMeter(AudacityProject *project, MeterPanel *meter)
|
||||
void AudioIOBase::SetCaptureMeter(AudacityProject *project, MeterPanelBase *meter)
|
||||
{
|
||||
if (( mOwningProject ) && ( mOwningProject != project))
|
||||
return;
|
||||
@ -320,7 +320,7 @@ void AudioIOBase::SetCaptureMeter(AudacityProject *project, MeterPanel *meter)
|
||||
mInputMeter.Release();
|
||||
}
|
||||
|
||||
void AudioIOBase::SetPlaybackMeter(AudacityProject *project, MeterPanel *meter)
|
||||
void AudioIOBase::SetPlaybackMeter(AudacityProject *project, MeterPanelBase *meter)
|
||||
{
|
||||
if (( mOwningProject ) && ( mOwningProject != project))
|
||||
return;
|
||||
|
@ -31,7 +31,7 @@ class AudioIOBase;
|
||||
class AudacityProject;
|
||||
class AudioIOListener;
|
||||
class BoundedEnvelope;
|
||||
class MeterPanel;
|
||||
class MeterPanelBase;
|
||||
using PRCrossfadeData = std::vector< std::vector < float > >;
|
||||
|
||||
#define BAD_STREAM_TIME (-DBL_MAX)
|
||||
@ -83,7 +83,7 @@ struct AudioIOStartStreamOptions
|
||||
{}
|
||||
|
||||
AudacityProject *pProject{};
|
||||
MeterPanel *captureMeter{}, *playbackMeter{};
|
||||
MeterPanelBase *captureMeter{}, *playbackMeter{};
|
||||
BoundedEnvelope *envelope; // for time warping
|
||||
AudioIOListener* listener;
|
||||
double rate;
|
||||
@ -111,8 +111,8 @@ class AudioIOBase /* not final */
|
||||
public:
|
||||
static AudioIOBase *Get();
|
||||
|
||||
void SetCaptureMeter(AudacityProject *project, MeterPanel *meter);
|
||||
void SetPlaybackMeter(AudacityProject *project, MeterPanel *meter);
|
||||
void SetCaptureMeter(AudacityProject *project, MeterPanelBase *meter);
|
||||
void SetPlaybackMeter(AudacityProject *project, MeterPanelBase *meter);
|
||||
|
||||
/** \brief update state after changing what audio devices are selected
|
||||
*
|
||||
@ -268,8 +268,8 @@ protected:
|
||||
|
||||
PaStream *mPortStreamV19;
|
||||
|
||||
wxWeakRef<MeterPanel> mInputMeter{};
|
||||
wxWeakRef<MeterPanel> mOutputMeter{};
|
||||
wxWeakRef<MeterPanelBase> mInputMeter{};
|
||||
wxWeakRef<MeterPanelBase> mOutputMeter{};
|
||||
|
||||
#if USE_PORTMIXER
|
||||
PxMixer *mPortMixer;
|
||||
|
@ -55,12 +55,12 @@ bool ProjectAudioIO::IsAudioActive() const
|
||||
gAudioIO->IsStreamActive(GetAudioIOToken());
|
||||
}
|
||||
|
||||
MeterPanel *ProjectAudioIO::GetPlaybackMeter()
|
||||
MeterPanelBase *ProjectAudioIO::GetPlaybackMeter()
|
||||
{
|
||||
return mPlaybackMeter;
|
||||
}
|
||||
|
||||
void ProjectAudioIO::SetPlaybackMeter(MeterPanel *playback)
|
||||
void ProjectAudioIO::SetPlaybackMeter(MeterPanelBase *playback)
|
||||
{
|
||||
auto &project = mProject;
|
||||
mPlaybackMeter = playback;
|
||||
@ -71,12 +71,12 @@ void ProjectAudioIO::SetPlaybackMeter(MeterPanel *playback)
|
||||
}
|
||||
}
|
||||
|
||||
MeterPanel *ProjectAudioIO::GetCaptureMeter()
|
||||
MeterPanelBase *ProjectAudioIO::GetCaptureMeter()
|
||||
{
|
||||
return mCaptureMeter;
|
||||
}
|
||||
|
||||
void ProjectAudioIO::SetCaptureMeter(MeterPanel *capture)
|
||||
void ProjectAudioIO::SetCaptureMeter(MeterPanelBase *capture)
|
||||
{
|
||||
auto &project = mProject;
|
||||
mCaptureMeter = capture;
|
||||
|
@ -14,7 +14,7 @@ Paul Licameli split from AudacityProject.h
|
||||
#include "ClientData.h" // to inherit
|
||||
|
||||
class AudacityProject;
|
||||
class MeterPanel;
|
||||
class MeterPanelBase;
|
||||
|
||||
///\ brief Holds per-project state needed for interaction with AudioIO,
|
||||
/// including the audio stream token and pointers to meters
|
||||
@ -32,17 +32,17 @@ public:
|
||||
bool IsAudioActive() const;
|
||||
void SetAudioIOToken(int token);
|
||||
|
||||
MeterPanel *GetPlaybackMeter();
|
||||
void SetPlaybackMeter(MeterPanel *playback);
|
||||
MeterPanel *GetCaptureMeter();
|
||||
void SetCaptureMeter(MeterPanel *capture);
|
||||
MeterPanelBase *GetPlaybackMeter();
|
||||
void SetPlaybackMeter(MeterPanelBase *playback);
|
||||
MeterPanelBase *GetCaptureMeter();
|
||||
void SetCaptureMeter(MeterPanelBase *capture);
|
||||
|
||||
private:
|
||||
AudacityProject &mProject;
|
||||
|
||||
// Project owned meters
|
||||
MeterPanel *mPlaybackMeter{};
|
||||
MeterPanel *mCaptureMeter{};
|
||||
MeterPanelBase *mPlaybackMeter{};
|
||||
MeterPanelBase *mCaptureMeter{};
|
||||
|
||||
int mAudioIOToken{ -1 };
|
||||
};
|
||||
|
@ -893,7 +893,7 @@ void ControlToolBar::StopPlaying(bool stopStream /* = true*/)
|
||||
// also clean the MeterQueues
|
||||
if( project ) {
|
||||
auto &projectAudioIO = ProjectAudioIO::Get( *project );
|
||||
MeterPanel *meter = projectAudioIO.GetPlaybackMeter();
|
||||
auto meter = projectAudioIO.GetPlaybackMeter();
|
||||
if( meter ) {
|
||||
meter->Clear();
|
||||
}
|
||||
|
@ -292,7 +292,7 @@ MeterPanel::MeterPanel(AudacityProject *project,
|
||||
const wxSize& size /*= wxDefaultSize*/,
|
||||
Style style /*= HorizontalStereo*/,
|
||||
float fDecayRate /*= 60.0f*/)
|
||||
: wxPanelWrapper(parent, id, pos, size, wxTAB_TRAVERSAL | wxNO_BORDER | wxWANTS_CHARS),
|
||||
: MeterPanelBase(parent, id, pos, size, wxTAB_TRAVERSAL | wxNO_BORDER | wxWANTS_CHARS),
|
||||
mProject(project),
|
||||
mQueue(1024),
|
||||
mWidth(size.x),
|
||||
@ -2151,6 +2151,10 @@ MeterAx::~MeterAx()
|
||||
{
|
||||
}
|
||||
|
||||
MeterPanelBase::~MeterPanelBase()
|
||||
{
|
||||
}
|
||||
|
||||
// Performs the default action. childId is 0 (the action for this object)
|
||||
// or > 0 (the action for a child).
|
||||
// Return wxACC_NOT_SUPPORTED if there is no default action for this
|
||||
|
@ -87,11 +87,27 @@ class MeterUpdateQueue
|
||||
|
||||
class MeterAx;
|
||||
|
||||
class MeterPanelBase /* not final */
|
||||
: public wxPanelWrapper
|
||||
{
|
||||
public:
|
||||
using wxPanelWrapper::wxPanelWrapper;
|
||||
~MeterPanelBase() override;
|
||||
|
||||
virtual void Clear() = 0;
|
||||
virtual void Reset(double sampleRate, bool resetClipping) = 0;
|
||||
virtual void UpdateDisplay(unsigned numChannels,
|
||||
int numFrames, float *sampleData) = 0;
|
||||
virtual bool IsMeterDisabled() const = 0;
|
||||
virtual float GetMaxPeak() const = 0;
|
||||
private:
|
||||
};
|
||||
|
||||
/********************************************************************//**
|
||||
\brief MeterPanel is a panel that paints the meter used for monitoring
|
||||
or playback.
|
||||
************************************************************************/
|
||||
class MeterPanel final : public wxPanelWrapper, private PrefsListener
|
||||
class MeterPanel final : public MeterPanelBase, private PrefsListener
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(MeterPanel)
|
||||
|
||||
@ -121,7 +137,7 @@ class MeterPanel final : public wxPanelWrapper, private PrefsListener
|
||||
|
||||
void SetFocusFromKbd() override;
|
||||
|
||||
void Clear();
|
||||
void Clear() override;
|
||||
|
||||
Style GetStyle() const { return mStyle; }
|
||||
Style GetDesiredStyle() const { return mDesiredStyle; }
|
||||
@ -132,7 +148,7 @@ class MeterPanel final : public wxPanelWrapper, private PrefsListener
|
||||
* This method is thread-safe! Feel free to call from a
|
||||
* different thread (like from an audio I/O callback).
|
||||
*/
|
||||
void Reset(double sampleRate, bool resetClipping);
|
||||
void Reset(double sampleRate, bool resetClipping) override;
|
||||
|
||||
/** \brief Update the meters with a block of audio data
|
||||
*
|
||||
@ -157,7 +173,7 @@ class MeterPanel final : public wxPanelWrapper, private PrefsListener
|
||||
* The second overload is for ease of use in MixerBoard.
|
||||
*/
|
||||
void UpdateDisplay(unsigned numChannels,
|
||||
int numFrames, float *sampleData);
|
||||
int numFrames, float *sampleData) override;
|
||||
|
||||
// Vaughan, 2010-11-29: This not currently used. See comments in MixerTrackCluster::UpdateMeter().
|
||||
//void UpdateDisplay(int numChannels, int numFrames,
|
||||
@ -171,9 +187,9 @@ class MeterPanel final : public wxPanelWrapper, private PrefsListener
|
||||
* This method is thread-safe! Feel free to call from a
|
||||
* different thread (like from an audio I/O callback).
|
||||
*/
|
||||
bool IsMeterDisabled() const;
|
||||
bool IsMeterDisabled() const override;
|
||||
|
||||
float GetMaxPeak() const;
|
||||
float GetMaxPeak() const override;
|
||||
|
||||
bool IsClipping() const;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user