summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2024-09-11 10:03:12 +0200
committerCarl Hetherington <cth@carlh.net>2024-09-11 10:05:07 +0200
commit24227766f782a857e3ab1fb4901e59f7997d1fba (patch)
tree04c56806ac4f67e1c544badc3abdfb5132841eaf
parente93b6e3fcdbaa0c006f47c23f6b90f230453179a (diff)
Cleanup: add AudioBackend::current_api_name().
-rw-r--r--src/wx/audio_backend.cc29
-rw-r--r--src/wx/audio_backend.h3
-rw-r--r--src/wx/config_dialog.cc19
3 files changed, 36 insertions, 15 deletions
diff --git a/src/wx/audio_backend.cc b/src/wx/audio_backend.cc
index 841efa41e..a626f9538 100644
--- a/src/wx/audio_backend.cc
+++ b/src/wx/audio_backend.cc
@@ -20,6 +20,7 @@
#include "audio_backend.h"
+#include "wx_util.h"
#include <boost/bind/bind.hpp>
@@ -191,3 +192,31 @@ AudioBackend::stream_latency() const
return const_cast<RtAudio&>(_rtaudio).getStreamLatency();
}
+
+wxString
+AudioBackend::current_api_name() const
+{
+ switch (const_cast<RtAudio&>(_rtaudio).getCurrentApi()) {
+ case RtAudio::MACOSX_CORE:
+ return _("CoreAudio");
+ case RtAudio::WINDOWS_ASIO:
+ return _("ASIO");
+ case RtAudio::WINDOWS_DS:
+ return _("Direct Sound");
+ case RtAudio::WINDOWS_WASAPI:
+ return _("WASAPI");
+ case RtAudio::UNIX_JACK:
+ return _("JACK");
+ case RtAudio::LINUX_ALSA:
+ return _("ALSA");
+ case RtAudio::LINUX_PULSE:
+ return _("PulseAudio");
+ case RtAudio::LINUX_OSS:
+ return _("OSS");
+ case RtAudio::RTAUDIO_DUMMY:
+ return _("Dummy");
+ default:
+ DCPOMATIC_ASSERT(false);
+ }
+}
+
diff --git a/src/wx/audio_backend.h b/src/wx/audio_backend.h
index d82a14dc6..0b0bff882 100644
--- a/src/wx/audio_backend.h
+++ b/src/wx/audio_backend.h
@@ -23,6 +23,7 @@
LIBDCP_DISABLE_WARNINGS
#include <RtAudio.h>
LIBDCP_ENABLE_WARNINGS
+#include <wx/wx.h>
#include <boost/optional.hpp>
#include <boost/thread/mutex.hpp>
@@ -49,6 +50,8 @@ public:
int stream_latency() const;
+ wxString current_api_name() const;
+
#if (RTAUDIO_VERSION_MAJOR >= 6)
std::string last_rtaudio_error() const;
#endif
diff --git a/src/wx/config_dialog.cc b/src/wx/config_dialog.cc
index ce8aef813..acc369207 100644
--- a/src/wx/config_dialog.cc
+++ b/src/wx/config_dialog.cc
@@ -934,13 +934,13 @@ SoundPage::config_changed ()
auto const current_so = get_sound_output ();
optional<string> configured_so;
- auto& audio = AudioBackend::instance()->rtaudio();
+ auto audio = AudioBackend::instance();
if (config->sound_output()) {
configured_so = config->sound_output().get();
} else {
/* No configured output means we should use the default */
- configured_so = AudioBackend::instance()->default_device_name();
+ configured_so = audio->default_device_name();
}
if (configured_so && current_so != configured_so) {
@@ -955,21 +955,10 @@ SoundPage::config_changed ()
}
}
- map<int, wxString> apis;
- apis[RtAudio::MACOSX_CORE] = _("CoreAudio");
- apis[RtAudio::WINDOWS_ASIO] = _("ASIO");
- apis[RtAudio::WINDOWS_DS] = _("Direct Sound");
- apis[RtAudio::WINDOWS_WASAPI] = _("WASAPI");
- apis[RtAudio::UNIX_JACK] = _("JACK");
- apis[RtAudio::LINUX_ALSA] = _("ALSA");
- apis[RtAudio::LINUX_PULSE] = _("PulseAudio");
- apis[RtAudio::LINUX_OSS] = _("OSS");
- apis[RtAudio::RTAUDIO_DUMMY] = _("Dummy");
-
- int const channels = configured_so ? AudioBackend::instance()->device_channels(*configured_so).get_value_or(0) : 0;
+ int const channels = configured_so ? audio->device_channels(*configured_so).get_value_or(0) : 0;
_sound_output_details->SetLabel (
- wxString::Format(_("%d channels on %s"), channels, apis[audio.getCurrentApi()])
+ wxString::Format(_("%d channels on %s"), channels, audio->current_api_name())
);
_map->set (Config::instance()->audio_mapping(channels));