From 7d642b25e9feb9d58cc8cbf6e82d6fa3612f8cec Mon Sep 17 00:00:00 2001 From: MerryMage Date: Thu, 12 Jul 2018 15:52:06 +0100 Subject: [PATCH] sink: Make auto device name a constant --- src/audio_core/cubeb_sink.cpp | 2 +- src/audio_core/sdl2_sink.cpp | 2 +- src/audio_core/sink.h | 2 ++ src/citra_qt/configuration/configure_audio.cpp | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/audio_core/cubeb_sink.cpp b/src/audio_core/cubeb_sink.cpp index 9d07825986..e679a95886 100644 --- a/src/audio_core/cubeb_sink.cpp +++ b/src/audio_core/cubeb_sink.cpp @@ -44,7 +44,7 @@ CubebSink::CubebSink(std::string target_device_name) : impl(std::make_uniquectx, ¶ms, &minimum_latency) != CUBEB_OK) LOG_CRITICAL(Audio_Sink, "Error getting minimum latency"); - if (target_device_name != "auto" && !target_device_name.empty()) { + if (target_device_name != auto_device_name && !target_device_name.empty()) { cubeb_device_collection collection; if (cubeb_enumerate_devices(impl->ctx, CUBEB_DEVICE_TYPE_OUTPUT, &collection) != CUBEB_OK) { LOG_WARNING(Audio_Sink, "Audio output device enumeration not supported"); diff --git a/src/audio_core/sdl2_sink.cpp b/src/audio_core/sdl2_sink.cpp index 7b3439c4ed..f18da88458 100644 --- a/src/audio_core/sdl2_sink.cpp +++ b/src/audio_core/sdl2_sink.cpp @@ -42,7 +42,7 @@ SDL2Sink::SDL2Sink(std::string device_name) : impl(std::make_unique()) { SDL_zero(obtained_audiospec); const char* device = nullptr; - if (device_name != "auto" && !device_name.empty()) { + if (device_name != auto_device_name && !device_name.empty()) { device = device_name.c_str(); } diff --git a/src/audio_core/sink.h b/src/audio_core/sink.h index e8b0d755f3..723756b675 100644 --- a/src/audio_core/sink.h +++ b/src/audio_core/sink.h @@ -9,6 +9,8 @@ namespace AudioCore { +constexpr char auto_device_name[] = "auto"; + /** * This class is an interface for an audio sink. An audio sink accepts samples in stereo signed * PCM16 format to be output. Sinks *do not* handle resampling and expect the correct sample rate. diff --git a/src/citra_qt/configuration/configure_audio.cpp b/src/citra_qt/configuration/configure_audio.cpp index 2a2932bb90..a06276a873 100644 --- a/src/citra_qt/configuration/configure_audio.cpp +++ b/src/citra_qt/configuration/configure_audio.cpp @@ -66,7 +66,7 @@ void ConfigureAudio::applyConfiguration() { void ConfigureAudio::updateAudioDevices(int sink_index) { ui->audio_device_combo_box->clear(); - ui->audio_device_combo_box->addItem("auto"); + ui->audio_device_combo_box->addItem(AudioCore::auto_device_name); std::string sink_id = ui->output_sink_combo_box->itemText(sink_index).toStdString(); std::vector device_list = AudioCore::GetSinkDetails(sink_id).list_devices();