diff options
| author | Carl Hetherington <cth@carlh.net> | 2024-07-25 16:29:49 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2024-07-26 11:39:59 +0200 |
| commit | 98b7a493933a5a47c6e1abb21ef2710ad2730a0e (patch) | |
| tree | 840ec2ca3fd693e052207b971d54e080318c71a7 /src/wx/audio_backend.cc | |
| parent | 349b0ca2ef8ab16d95d57d121960480ecce0cb7f (diff) | |
Add AudioBackend::device_output_channels().
Diffstat (limited to 'src/wx/audio_backend.cc')
| -rw-r--r-- | src/wx/audio_backend.cc | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/wx/audio_backend.cc b/src/wx/audio_backend.cc index 3cb2b8d4f..9c8b1c386 100644 --- a/src/wx/audio_backend.cc +++ b/src/wx/audio_backend.cc @@ -24,6 +24,9 @@ using std::string; using std::vector; +using boost::optional; + + AudioBackend* AudioBackend::_instance = nullptr; @@ -122,6 +125,33 @@ AudioBackend::default_device_name() } +optional<int> +AudioBackend::device_output_channels(string name) +{ +#if (RTAUDIO_VERSION_MAJOR >= 6) + for (auto device_id: _rtaudio.getDeviceIds()) { + auto info = audio.getDeviceInfo(device_id); + if (info.name == name) { + return info.outputChannels; + } + } +#else + for (unsigned int i = 0; i < _rtaudio.getDeviceCount(); ++i) { + try { + auto info = _rtaudio.getDeviceInfo(i); + if (info.name == name) { + return info.outputChannels; + } + } catch (RtAudioError&) { + /* Never mind */ + } + } +#endif + + return {}; +} + + void AudioBackend::abort_stream_if_running() { |
