1
0
mirror of https://github.com/cookiengineer/audacity synced 2026-03-21 05:35:45 +01:00
Files
audacity/src/DeviceManager.h
Paul Licameli 7824e94030 Harmlessly qualify classes as final (or explicitly comment not)...
... Should have no effect on generated code, except perhaps some slight faster
virtual function calls.  Mostly useful as documentation of design intent.

Tried to mark every one of our classes that inherits from another, or is a
base for others, or has abstract virtual functions, and a few others besides.
2016-02-24 20:58:30 -05:00

94 lines
2.3 KiB
C++

/**********************************************************************
Audacity: A Digital Audio Editor
DeviceManager.h
Created by Michael Chinen (mchinen) on 2/12/11
Audacity(R) is copyright (c) 1999-2011 Audacity Team.
License: GPL v2. See License.txt.
******************************************************************//**
\class DeviceManager
\brief A singleton that manages the audio devices known to Audacity
*//*******************************************************************/
#ifndef __AUDACITY_DEVICEMANAGER__
#define __AUDACITY_DEVICEMANAGER__
#include "Experimental.h"
#include <vector>
#include "wx/wx.h"
#if defined(EXPERIMENTAL_DEVICE_CHANGE_HANDLER)
#include "DeviceChange.h"
#endif
typedef struct DeviceSourceMap {
int deviceIndex;
int sourceIndex;
int hostIndex;
int totalSources;
int numChannels;
wxString sourceString;
wxString deviceString;
wxString hostString;
} DeviceSourceMap;
wxString MakeDeviceSourceString(const DeviceSourceMap *map);
class DeviceManager final
#if defined(EXPERIMENTAL_DEVICE_CHANGE_HANDLER)
#if defined(HAVE_DEVICE_CHANGE)
: public DeviceChangeHandler
#endif
#endif
{
public:
/// Gets the singleton instance
static DeviceManager* Instance();
/// Releases memory assosiated with the singleton
static void Destroy();
/// Gets a NEW list of devices by terminating and restarting portaudio
/// Assumes that DeviceManager is only used on the main thread.
void Rescan();
DeviceSourceMap* GetDefaultOutputDevice(int hostIndex);
DeviceSourceMap* GetDefaultInputDevice(int hostIndex);
const std::vector<DeviceSourceMap> &GetInputDeviceMaps();
const std::vector<DeviceSourceMap> &GetOutputDeviceMaps();
#if defined(EXPERIMENTAL_DEVICE_CHANGE_HANDLER)
#if defined(HAVE_DEVICE_CHANGE)
// DeviceChangeHandler implementation
void DeviceChangeNotification();
#endif
#endif
protected:
//private constructor - Singleton.
DeviceManager();
virtual ~DeviceManager();
/// Does an initial scan.
/// Called by GetInputDeviceMaps and GetOutputDeviceMaps when needed.
void Init();
DeviceSourceMap* GetDefaultDevice(int hostIndex, int isInput);
bool m_inited;
std::vector<DeviceSourceMap> mInputDeviceSourceMaps;
std::vector<DeviceSourceMap> mOutputDeviceSourceMaps;
static DeviceManager dm;
};
#endif