Audacity  2.2.0
DeviceManager.h
Go to the documentation of this file.
1 /**********************************************************************
2 
3  Audacity: A Digital Audio Editor
4 
5  DeviceManager.h
6 
7  Created by Michael Chinen (mchinen) on 2/12/11
8  Audacity(R) is copyright (c) 1999-2011 Audacity Team.
9  License: GPL v2. See License.txt.
10 
11 ******************************************************************//*******************************************************************/
17 
18 #ifndef __AUDACITY_DEVICEMANAGER__
19 #define __AUDACITY_DEVICEMANAGER__
20 
21 #include "Experimental.h"
22 
23 #include <vector>
24 #include "wx/wx.h"
25 
26 #if defined(EXPERIMENTAL_DEVICE_CHANGE_HANDLER)
27 #include "DeviceChange.h"
28 #endif
29 
30 typedef struct DeviceSourceMap {
33  int hostIndex;
36  wxString sourceString;
37  wxString deviceString;
38  wxString hostString;
40 
41 wxString MakeDeviceSourceString(const DeviceSourceMap *map);
42 
43 class DeviceManager final
44 #if defined(EXPERIMENTAL_DEVICE_CHANGE_HANDLER)
45 #if defined(HAVE_DEVICE_CHANGE)
46 : public DeviceChangeHandler
47 #endif
48 #endif
49 {
50  public:
52  static DeviceManager* Instance();
53 
56  void Rescan();
57 
59  DeviceSourceMap* GetDefaultInputDevice(int hostIndex);
60 
61  const std::vector<DeviceSourceMap> &GetInputDeviceMaps();
62  const std::vector<DeviceSourceMap> &GetOutputDeviceMaps();
63 
64 #if defined(EXPERIMENTAL_DEVICE_CHANGE_HANDLER)
65 #if defined(HAVE_DEVICE_CHANGE)
66  // DeviceChangeHandler implementation
67  void DeviceChangeNotification();
68 #endif
69 #endif
70 
71  protected:
72  //private constructor - Singleton.
73  DeviceManager();
77  void Init();
78 
79  DeviceSourceMap* GetDefaultDevice(int hostIndex, int isInput);
80 
81  bool m_inited;
82 
83  std::vector<DeviceSourceMap> mInputDeviceSourceMaps;
84  std::vector<DeviceSourceMap> mOutputDeviceSourceMaps;
85 
86  static DeviceManager dm;
87 };
88 
89 #endif
90 
void Rescan()
Definition: DeviceManager.cpp:251
int deviceIndex
Definition: DeviceManager.h:31
int totalSources
Definition: DeviceManager.h:34
bool m_inited
Definition: DeviceManager.h:81
DeviceSourceMap * GetDefaultDevice(int hostIndex, int isInput)
Definition: DeviceManager.cpp:74
void Init()
Definition: DeviceManager.cpp:327
wxString sourceString
Definition: DeviceManager.h:36
const std::vector< DeviceSourceMap > & GetInputDeviceMaps()
Definition: DeviceManager.cpp:50
DeviceSourceMap * GetDefaultInputDevice(int hostIndex)
Definition: DeviceManager.cpp:98
DeviceManager()
Definition: DeviceManager.cpp:312
struct DeviceSourceMap DeviceSourceMap
const std::vector< DeviceSourceMap > & GetOutputDeviceMaps()
Definition: DeviceManager.cpp:56
wxString MakeDeviceSourceString(const DeviceSourceMap *map)
Definition: DeviceManager.cpp:64
static DeviceManager dm
Definition: DeviceManager.h:86
int sourceIndex
Definition: DeviceManager.h:32
int numChannels
Definition: DeviceManager.h:35
std::vector< DeviceSourceMap > mInputDeviceSourceMaps
Definition: DeviceManager.h:83
wxString deviceString
Definition: DeviceManager.h:37
std::vector< DeviceSourceMap > mOutputDeviceSourceMaps
Definition: DeviceManager.h:84
static DeviceManager * Instance()
Gets the singleton instance.
Definition: DeviceManager.cpp:45
int hostIndex
Definition: DeviceManager.h:33
wxString hostString
Definition: DeviceManager.h:38
A singleton that manages the audio devices known to Audacity.
Definition: DeviceManager.h:43
~DeviceManager()
Definition: DeviceManager.cpp:322
DeviceSourceMap * GetDefaultOutputDevice(int hostIndex)
Definition: DeviceManager.cpp:94
Definition: DeviceManager.h:30