Audacity 3.2.0
|
A singleton that manages the audio devices known to Audacity. More...
#include <DeviceManager.h>
Public Member Functions | |
void | Rescan () |
std::chrono::duration< float > | GetTimeSinceRescan () |
DeviceSourceMap * | GetDefaultOutputDevice (int hostIndex) |
DeviceSourceMap * | GetDefaultInputDevice (int hostIndex) |
const std::vector< DeviceSourceMap > & | GetInputDeviceMaps () |
const std::vector< DeviceSourceMap > & | GetOutputDeviceMaps () |
Public Member Functions inherited from Observer::Publisher< Message, NotifyAll > | |
template<typename Alloc = std::allocator<Record>> | |
Publisher (ExceptionPolicy *pPolicy=nullptr, Alloc a={}) | |
Constructor supporting type-erased custom allocation/deletion. More... | |
Publisher (Publisher &&)=default | |
Publisher & | operator= (Publisher &&)=default |
Subscription | Subscribe (Callback callback) |
Connect a callback to the Publisher; later-connected are called earlier. More... | |
template<typename Object , typename Return , typename... Args> | |
Subscription | Subscribe (Object &obj, Return(Object::*callback)(Args...)) |
Overload of Subscribe takes an object and pointer-to-member-function. More... | |
Static Public Member Functions | |
static DeviceManager * | Instance () |
Gets the singleton instance. More... | |
Protected Member Functions | |
DeviceManager () | |
~DeviceManager () | |
void | Init () |
DeviceSourceMap * | GetDefaultDevice (int hostIndex, int isInput) |
Protected Member Functions inherited from Observer::Publisher< Message, NotifyAll > | |
CallbackReturn | Publish (const Message &message) |
Send a message to connected callbacks. More... | |
Protected Attributes | |
bool | m_inited |
std::vector< DeviceSourceMap > | mInputDeviceSourceMaps |
std::vector< DeviceSourceMap > | mOutputDeviceSourceMaps |
Static Protected Attributes | |
static DeviceManager | dm |
Private Attributes | |
std::chrono::time_point< std::chrono::steady_clock > | mRescanTime |
Additional Inherited Members | |
Public Types inherited from Observer::Publisher< Message, NotifyAll > | |
using | message_type = Message |
using | CallbackReturn = std::conditional_t< NotifyAll, void, bool > |
using | Callback = std::function< CallbackReturn(const Message &) > |
Type of functions that can be connected to the Publisher. More... | |
Static Public Attributes inherited from Observer::Publisher< Message, NotifyAll > | |
static constexpr bool | notifies_all = NotifyAll |
A singleton that manages the audio devices known to Audacity.
Definition at line 42 of file DeviceManager.h.
|
protected |
Definition at line 299 of file DeviceManager.cpp.
|
protected |
Definition at line 310 of file DeviceManager.cpp.
|
protected |
Definition at line 62 of file DeviceManager.cpp.
References mInputDeviceSourceMaps, mOutputDeviceSourceMaps, and wxT().
Referenced by GetDefaultInputDevice(), and GetDefaultOutputDevice().
DeviceSourceMap * DeviceManager::GetDefaultInputDevice | ( | int | hostIndex | ) |
Definition at line 86 of file DeviceManager.cpp.
References GetDefaultDevice().
Referenced by DevicePrefs::OnHost(), AudioSetupToolBar::UpdatePrefs(), and DeviceToolBar::UpdatePrefs().
DeviceSourceMap * DeviceManager::GetDefaultOutputDevice | ( | int | hostIndex | ) |
Definition at line 82 of file DeviceManager.cpp.
References GetDefaultDevice().
Referenced by DevicePrefs::OnHost(), and DeviceToolBar::UpdatePrefs().
const std::vector< DeviceSourceMap > & DeviceManager::GetInputDeviceMaps | ( | ) |
Definition at line 38 of file DeviceManager.cpp.
References Init(), m_inited, and mInputDeviceSourceMaps.
Referenced by DeviceToolBar::ChangeDevice(), AudioSetupToolBar::ChangeDeviceLabel(), AudioSetupToolBar::FillHostDevices(), DeviceToolBar::FillHostDevices(), AudioSetupToolBar::FillHosts(), DeviceToolBar::FillHosts(), AudioSetupToolBar::FillInputChannels(), DeviceToolBar::FillInputChannels(), DevicePrefs::OnHost(), AudioSetupToolBar::UpdatePrefs(), and DeviceToolBar::UpdatePrefs().
const std::vector< DeviceSourceMap > & DeviceManager::GetOutputDeviceMaps | ( | ) |
Definition at line 44 of file DeviceManager.cpp.
References Init(), m_inited, and mOutputDeviceSourceMaps.
Referenced by DeviceToolBar::ChangeDevice(), AudioSetupToolBar::ChangeDeviceLabel(), AudioSetupToolBar::FillHostDevices(), DeviceToolBar::FillHostDevices(), AudioSetupToolBar::FillHosts(), DeviceToolBar::FillHosts(), DevicePrefs::OnHost(), AudioSetupToolBar::UpdatePrefs(), and DeviceToolBar::UpdatePrefs().
std::chrono::duration< float > DeviceManager::GetTimeSinceRescan | ( | ) |
Definition at line 291 of file DeviceManager.cpp.
References mRescanTime.
Referenced by AudioIO::StartPortAudioStream().
|
protected |
Does an initial scan. Called by GetInputDeviceMaps and GetOutputDeviceMaps when needed.
Definition at line 315 of file DeviceManager.cpp.
References Rescan().
Referenced by GetInputDeviceMaps(), and GetOutputDeviceMaps().
|
static |
Gets the singleton instance.
Definition at line 33 of file DeviceManager.cpp.
References dm.
Referenced by AudioSetupToolBar::AudioSetupToolBar(), DeviceToolBar::ChangeDevice(), AudioSetupToolBar::ChangeDeviceLabel(), DeviceToolBar::DeviceToolBar(), AudioSetupToolBar::FillHostDevices(), DeviceToolBar::FillHostDevices(), AudioSetupToolBar::FillHosts(), DeviceToolBar::FillHosts(), AudioSetupToolBar::FillInputChannels(), DeviceToolBar::FillInputChannels(), AudioSetupToolBar::OnAudioDeviceRescan(), DevicePrefs::OnHost(), anonymous_namespace{TransportMenus.cpp}::OnRescanDevices(), AudioIO::StartPortAudioStream(), AudioSetupToolBar::UpdatePrefs(), and DeviceToolBar::UpdatePrefs().
void DeviceManager::Rescan | ( | ) |
Gets a NEW list of devices by terminating and restarting portaudio Assumes that DeviceManager is only used on the main thread.
Definition at line 238 of file DeviceManager.cpp.
References AddSources(), AudioIOBase::Get(), m_inited, mInputDeviceSourceMaps, mOutputDeviceSourceMaps, mRescanTime, Observer::Publisher< Message, NotifyAll >::Publish(), and Rescan.
Referenced by Init(), AudioSetupToolBar::OnAudioDeviceRescan(), and anonymous_namespace{TransportMenus.cpp}::OnRescanDevices().
|
staticprotected |
Definition at line 91 of file DeviceManager.h.
Referenced by Instance().
|
protected |
Definition at line 86 of file DeviceManager.h.
Referenced by GetInputDeviceMaps(), GetOutputDeviceMaps(), and Rescan().
|
protected |
Definition at line 88 of file DeviceManager.h.
Referenced by GetDefaultDevice(), GetInputDeviceMaps(), and Rescan().
|
protected |
Definition at line 89 of file DeviceManager.h.
Referenced by GetDefaultDevice(), GetOutputDeviceMaps(), and Rescan().
|
private |
Definition at line 74 of file DeviceManager.h.
Referenced by GetTimeSinceRescan(), and Rescan().