1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-04-30 15:49:41 +02:00
audacity/src/ProjectAudioIO.h
Paul Licameli 2d6db518fa Prevent dangling pointers to meters...
... This stops a crash that might occur when the checkpoint thread causes
ProjectAudioManager::Stop() to execute but the project is in the process of
closing.
2020-11-22 19:58:00 -05:00

54 lines
1.4 KiB
C++

/**********************************************************************
Audacity: A Digital Audio Editor
ProjectAudioIO.h
Paul Licameli split from AudacityProject.h
**********************************************************************/
#ifndef __PROJECT_AUDIO_IO__
#define __PROJECT_AUDIO_IO__
#include "ClientData.h" // to inherit
#include <wx/weakref.h>
class AudacityProject;
class MeterPanelBase;
///\ brief Holds per-project state needed for interaction with AudioIO,
/// including the audio stream token and pointers to meters
class ProjectAudioIO final
: public ClientData::Base
{
public:
static ProjectAudioIO &Get( AudacityProject &project );
static const ProjectAudioIO &Get( const AudacityProject &project );
explicit ProjectAudioIO( AudacityProject &project );
ProjectAudioIO( const ProjectAudioIO & ) PROHIBITED;
ProjectAudioIO &operator=( const ProjectAudioIO & ) PROHIBITED;
~ProjectAudioIO();
int GetAudioIOToken() const;
bool IsAudioActive() const;
void SetAudioIOToken(int token);
MeterPanelBase *GetPlaybackMeter();
void SetPlaybackMeter(MeterPanelBase *playback);
MeterPanelBase *GetCaptureMeter();
void SetCaptureMeter(MeterPanelBase *capture);
private:
AudacityProject &mProject;
// Project owned meters
wxWeakRef<MeterPanelBase> mPlaybackMeter{};
wxWeakRef<MeterPanelBase> mCaptureMeter{};
int mAudioIOToken{ -1 };
};
#endif