Audacity 3.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 or later. See License.txt.
10
11******************************************************************//*******************************************************************/
17
18#ifndef __AUDACITY_DEVICEMANAGER__
19#define __AUDACITY_DEVICEMANAGER__
20
21#include <chrono>
22#include <vector>
23
24#include <wx/string.h> // member variables
25
26#include "DeviceChange.h"
27
28typedef struct DeviceSourceMap {
34 wxString sourceString;
35 wxString deviceString;
36 wxString hostString;
38
39AUDIO_DEVICES_API
40wxString MakeDeviceSourceString(const DeviceSourceMap *map);
41
42class AUDIO_DEVICES_API DeviceManager final
43#if defined(EXPERIMENTAL_DEVICE_CHANGE_HANDLER) && defined(HAVE_DEVICE_CHANGE)
44: public DeviceChangeHandler
45#else
47#endif
48{
49 public:
51 static DeviceManager* Instance();
52
55 void Rescan();
56
57 // Time since devices scanned in seconds.
58 std::chrono::duration<float> GetTimeSinceRescan();
59
60 DeviceSourceMap* GetDefaultOutputDevice(int hostIndex);
61 DeviceSourceMap* GetDefaultInputDevice(int hostIndex);
62
63 const std::vector<DeviceSourceMap> &GetInputDeviceMaps();
64 const std::vector<DeviceSourceMap> &GetOutputDeviceMaps();
65
66#if defined(EXPERIMENTAL_DEVICE_CHANGE_HANDLER)
67#if defined(HAVE_DEVICE_CHANGE)
68 // DeviceChangeHandler implementation
69 void DeviceChangeNotification();
70#endif
71#endif
72
73private:
74 std::chrono::time_point<std::chrono::steady_clock> mRescanTime;
75
76 protected:
77 //private constructor - Singleton.
82 void Init();
83
84 DeviceSourceMap* GetDefaultDevice(int hostIndex, int isInput);
85
87
88 std::vector<DeviceSourceMap> mInputDeviceSourceMaps;
89 std::vector<DeviceSourceMap> mOutputDeviceSourceMaps;
90
92};
93
94#endif
95
AUDIO_DEVICES_API wxString MakeDeviceSourceString(const DeviceSourceMap *map)
struct DeviceSourceMap DeviceSourceMap
A singleton that manages the audio devices known to Audacity.
Definition: DeviceManager.h:48
static DeviceManager dm
Definition: DeviceManager.h:91
std::chrono::time_point< std::chrono::steady_clock > mRescanTime
Definition: DeviceManager.h:74
std::vector< DeviceSourceMap > mOutputDeviceSourceMaps
Definition: DeviceManager.h:89
std::vector< DeviceSourceMap > mInputDeviceSourceMaps
Definition: DeviceManager.h:88
An object that sends messages to an open-ended list of subscribed callbacks.
Definition: Observer.h:108
wxString hostString
Definition: DeviceManager.h:36
wxString sourceString
Definition: DeviceManager.h:34
wxString deviceString
Definition: DeviceManager.h:35