diff options
Diffstat (limited to 'Source/Core/AudioCommon/CubebUtils.cpp')
| -rw-r--r-- | Source/Core/AudioCommon/CubebUtils.cpp | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/Source/Core/AudioCommon/CubebUtils.cpp b/Source/Core/AudioCommon/CubebUtils.cpp index b86283dcdf..feaa5f2392 100644 --- a/Source/Core/AudioCommon/CubebUtils.cpp +++ b/Source/Core/AudioCommon/CubebUtils.cpp @@ -10,6 +10,7 @@ #include "AudioCommon/AudioCommon.h" #include "Common/Logging/Log.h" #include "Common/Logging/LogManager.h" +#include "Common/Projection.h" #include "Common/StringUtil.h" #include "Core/Config/MainSettings.h" @@ -276,6 +277,45 @@ const void* GetOutputDeviceById(std::string_view id) return device_id; } +std::vector<std::string_view> GetBackendNames() +{ + // Some tricks to only call `cubeb_get_backend_names` if it exists. + return [](auto... args) -> std::vector<std::string_view> { + if constexpr (requires { cubeb_get_backend_names(args...); }) + { + const auto names = cubeb_get_backend_names(args...); + return {names.names, names.names + names.count}; + } + else + { // The included version of Cubeb lacks the `cubeb_get_backend_names` function. + return {}; + } + }(); +} + +std::string_view GetCubebBackendDisplayName(std::string_view backend_name) +{ + static constexpr std::pair<const char*, const char*> name_map[] = { + {"pulse", "PulseAudio"}, + {"pulse-rust", "PulseAudio Rust"}, + {"jack", "JACK"}, + {"alsa", "ALSA"}, + {"audiounit", "AudioUnit"}, + {"audiounit-rust", "AudioUnit Rust"}, + {"wasapi", "WASAPI"}, + {"winmm", "WinMM"}, + {"sun", "Sun"}, + {"opensl", "OpenSL"}, + {"oss", "OSS"}, + {"aaudio", "AAudio"}, + {"audiotrack", "AudioTrack"}, + {"kai", "KAI"}, + }; + + const auto it = std::ranges::find(name_map, backend_name, Common::Projection::First{}); + return (it != std::end(name_map)) ? it->second : backend_name; +} + CoInitSyncWorker::CoInitSyncWorker([[maybe_unused]] std::string worker_name) #ifdef _WIN32 : m_work_queue{std::move(worker_name)} |
