diff options
| author | Jordan Woyak <jordan.woyak@gmail.com> | 2026-11-15 22:33:58 -0600 |
|---|---|---|
| committer | Jordan Woyak <jordan.woyak@gmail.com> | 2026-11-16 18:04:59 -0600 |
| commit | eaad965f5785a63112949535ce14798d32dd38bf (patch) | |
| tree | 9c3ac83e3fa4a57fef01d185f5e3796d0c74a152 /Source/Core/AudioCommon | |
| parent | 8169c72ce63ba9315888fd05fe8a7885f93e6f4f (diff) | |
AudioCommon: Allow MAIN_AUDIO_BACKEND to optionally specify the Cubeb backend after a slash. e.g. "Cubeb/wasapi".
Diffstat (limited to 'Source/Core/AudioCommon')
| -rw-r--r-- | Source/Core/AudioCommon/AudioCommon.cpp | 14 | ||||
| -rw-r--r-- | Source/Core/AudioCommon/AudioCommon.h | 1 | ||||
| -rw-r--r-- | Source/Core/AudioCommon/CubebUtils.cpp | 10 |
3 files changed, 21 insertions, 4 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; |
