diff options
| author | Carl Hetherington <cth@carlh.net> | 2024-07-25 16:28:46 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2024-07-26 11:39:59 +0200 |
| commit | 5fc64dfcf121d785de3445d10fa7510a30c55965 (patch) | |
| tree | 546637897a79ab7c062d1aa1933f97ee0d960d6e /src/wx/audio_backend.cc | |
| parent | ce34d8e16db29c358e21337be985600cef8a5044 (diff) | |
Add AudioBackend::output_device_names().
Diffstat (limited to 'src/wx/audio_backend.cc')
| -rw-r--r-- | src/wx/audio_backend.cc | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/wx/audio_backend.cc b/src/wx/audio_backend.cc index 351f0d78b..73f57b50e 100644 --- a/src/wx/audio_backend.cc +++ b/src/wx/audio_backend.cc @@ -22,6 +22,8 @@ #include "audio_backend.h" +using std::string; +using std::vector; AudioBackend* AudioBackend::_instance = nullptr; @@ -75,6 +77,35 @@ AudioBackend::instance() } +vector<string> +AudioBackend::output_device_names() +{ + vector<string> names; + +#if (RTAUDIO_VERSION_MAJOR >= 6) + for (auto device_id: audio.getDeviceIds()) { + auto dev = audio.getDeviceInfo(device_id); + if (dev.outputChannels > 0) { + names.push_back(dev.name); + } + } +#else + for (unsigned int i = 0; i < _rtaudio.getDeviceCount(); ++i) { + try { + auto dev = _rtaudio.getDeviceInfo(i); + if (dev.probed && dev.outputChannels > 0) { + names.push_back(dev.name); + } + } catch (RtAudioError&) { + /* Something went wrong so let's just ignore that device */ + } + } +#endif + + return names; +} + + void AudioBackend::abort_stream_if_running() { |
