summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorJordan Woyak <jordan.woyak@gmail.com>2026-11-15 22:33:58 -0600
committerJordan Woyak <jordan.woyak@gmail.com>2026-11-16 18:04:59 -0600
commiteaad965f5785a63112949535ce14798d32dd38bf (patch)
tree9c3ac83e3fa4a57fef01d185f5e3796d0c74a152 /Source/Core
parent8169c72ce63ba9315888fd05fe8a7885f93e6f4f (diff)
AudioCommon: Allow MAIN_AUDIO_BACKEND to optionally specify the Cubeb backend after a slash. e.g. "Cubeb/wasapi".
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/AudioCommon/AudioCommon.cpp14
-rw-r--r--Source/Core/AudioCommon/AudioCommon.h1
-rw-r--r--Source/Core/AudioCommon/CubebUtils.cpp10
-rw-r--r--Source/Core/DolphinQt/Settings/AudioPane.cpp4
4 files changed, 23 insertions, 6 deletions
diff --git a/Source/Core/AudioCommon/AudioCommon.cpp b/Source/Core/AudioCommon/AudioCommon.cpp
index 73e1094a69..b766815312 100644
--- a/Source/Core/AudioCommon/AudioCommon.cpp
+++ b/Source/Core/AudioCommon/AudioCommon.cpp
@@ -28,7 +28,7 @@ constexpr int AUDIO_VOLUME_MAX = 100;
static std::unique_ptr<SoundStream> CreateSoundStreamForBackend(std::string_view backend)
{
- if (backend == BACKEND_CUBEB && CubebStream::IsValid())
+ if (IsCubebBackend(backend) && CubebStream::IsValid())
return std::make_unique<CubebStream>();
else if (backend == BACKEND_OPENAL && OpenALStream::IsValid())
return std::make_unique<OpenALStream>();
@@ -135,13 +135,20 @@ std::vector<std::string> GetSoundBackends()
return backends;
}
+bool IsCubebBackend(std::string_view backend)
+{
+ // Cubeb may have its own backend specified after a slash.
+ // e.g. "Cubeb/wasapi"
+ return backend.substr(0, backend.find('/')) == BACKEND_CUBEB;
+}
+
bool SupportsDPL2Decoder(std::string_view backend)
{
#ifndef __APPLE__
if (backend == BACKEND_OPENAL)
return true;
#endif
- if (backend == BACKEND_CUBEB)
+ if (AudioCommon::IsCubebBackend(backend))
return true;
if (backend == BACKEND_PULSEAUDIO)
return true;
@@ -158,7 +165,8 @@ bool SupportsVolumeChanges(std::string_view backend)
// FIXME: this one should ask the backend whether it supports it.
// but getting the backend from string etc. is probably
// too much just to enable/disable a stupid slider...
- return backend == BACKEND_CUBEB || backend == BACKEND_OPENAL || backend == BACKEND_WASAPI;
+ return AudioCommon::IsCubebBackend(backend) || backend == BACKEND_OPENAL ||
+ backend == BACKEND_WASAPI;
}
void UpdateSoundStream(Core::System& system)
diff --git a/Source/Core/AudioCommon/AudioCommon.h b/Source/Core/AudioCommon/AudioCommon.h
index bd94ba5eba..34e74fd16b 100644
--- a/Source/Core/AudioCommon/AudioCommon.h
+++ b/Source/Core/AudioCommon/AudioCommon.h
@@ -25,6 +25,7 @@ void ShutdownSoundStream(Core::System& system);
std::string GetDefaultSoundBackend();
std::vector<std::string> GetSoundBackends();
DPL2Quality GetDefaultDPL2Quality();
+bool IsCubebBackend(std::string_view backend);
bool SupportsDPL2Decoder(std::string_view backend);
bool SupportsLatencyControl(std::string_view backend);
bool SupportsVolumeChanges(std::string_view backend);
diff --git a/Source/Core/AudioCommon/CubebUtils.cpp b/Source/Core/AudioCommon/CubebUtils.cpp
index 4dc34a0d44..ff1a304880 100644
--- a/Source/Core/AudioCommon/CubebUtils.cpp
+++ b/Source/Core/AudioCommon/CubebUtils.cpp
@@ -10,6 +10,7 @@
#include "Common/Logging/Log.h"
#include "Common/Logging/LogManager.h"
#include "Common/StringUtil.h"
+#include "Core/Config/MainSettings.h"
#include <cubeb/cubeb.h>
@@ -67,8 +68,15 @@ std::shared_ptr<cubeb> GetContext()
ERROR_LOG_FMT(AUDIO, "Error setting cubeb log callback");
}
+ // Cubeb may have its own backend specified after a slash.
+ // e.g. "Cubeb/wasapi"
+ const auto audio_backend = Config::Get(Config::MAIN_AUDIO_BACKEND);
+ const auto cubeb_backend_delimiter_pos = audio_backend.find('/');
+ const char* const backend_name = (cubeb_backend_delimiter_pos == std::string::npos) ?
+ nullptr :
+ audio_backend.c_str() + cubeb_backend_delimiter_pos + 1;
cubeb* ctx;
- if (cubeb_init(&ctx, "Dolphin Emulator", nullptr) != CUBEB_OK)
+ if (cubeb_init(&ctx, "Dolphin Emulator", backend_name) != CUBEB_OK)
{
ERROR_LOG_FMT(AUDIO, "Error initializing cubeb library");
return nullptr;
diff --git a/Source/Core/DolphinQt/Settings/AudioPane.cpp b/Source/Core/DolphinQt/Settings/AudioPane.cpp
index f204fb7f03..c23ef658cd 100644
--- a/Source/Core/DolphinQt/Settings/AudioPane.cpp
+++ b/Source/Core/DolphinQt/Settings/AudioPane.cpp
@@ -401,7 +401,7 @@ void AudioPane::UpdateWiimoteRoutingEnabled()
return;
const bool running = Core::GetState(Core::System::GetInstance()) != Core::State::Uninitialized;
- const bool is_cubeb = Config::Get(Config::MAIN_AUDIO_BACKEND) == BACKEND_CUBEB;
+ const bool is_cubeb = AudioCommon::IsCubebBackend(Config::Get(Config::MAIN_AUDIO_BACKEND));
const bool speaker_enabled = Config::Get(Config::MAIN_WIIMOTE_ENABLE_SPEAKER);
const bool bt_passthrough = Config::Get(Config::MAIN_BLUETOOTH_PASSTHROUGH_ENABLED);
@@ -432,7 +432,7 @@ void AudioPane::UpdateGBARoutingEnabled()
return;
const bool running = Core::GetState(Core::System::GetInstance()) != Core::State::Uninitialized;
- const bool is_cubeb = Config::Get(Config::MAIN_AUDIO_BACKEND) == BACKEND_CUBEB;
+ const bool is_cubeb = AudioCommon::IsCubebBackend(Config::Get(Config::MAIN_AUDIO_BACKEND));
const bool group_usable = !running && is_cubeb;
m_gba_routing_enable->setEnabled(group_usable);