diff options
| author | OatmealDome <julian@oatmealdome.me> | 2025-01-25 14:06:55 -0500 |
|---|---|---|
| committer | OatmealDome <julian@oatmealdome.me> | 2025-01-25 14:06:55 -0500 |
| commit | d89e7c84fbd938dc9f2265363334ec46c4cb321f (patch) | |
| tree | 34643c52977ea176ade44beb71af4fb9dc38b092 /Source/Core/AudioCommon | |
| parent | d0b7c96fdb7ea50d55bb3cf581e5820d7b27b7e1 (diff) | |
CMakeLists: Add flag to disable Cubeb
Diffstat (limited to 'Source/Core/AudioCommon')
| -rw-r--r-- | Source/Core/AudioCommon/AudioCommon.cpp | 10 | ||||
| -rw-r--r-- | Source/Core/AudioCommon/CMakeLists.txt | 18 | ||||
| -rw-r--r-- | Source/Core/AudioCommon/CubebStream.h | 5 |
3 files changed, 25 insertions, 8 deletions
diff --git a/Source/Core/AudioCommon/AudioCommon.cpp b/Source/Core/AudioCommon/AudioCommon.cpp index d9fee4ef72..0a0aafd307 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) + if (backend == BACKEND_CUBEB && CubebStream::IsValid()) return std::make_unique<CubebStream>(); else if (backend == BACKEND_OPENAL && OpenALStream::IsValid()) return std::make_unique<OpenALStream>(); @@ -100,10 +100,11 @@ std::string GetDefaultSoundBackend() #elif defined __linux__ if (AlsaSound::IsValid()) backend = BACKEND_ALSA; - else + else if (CubebStream::IsValid()) backend = BACKEND_CUBEB; #elif defined(__APPLE__) || defined(_WIN32) || defined(__OpenBSD__) - backend = BACKEND_CUBEB; + if (CubebStream::IsValid()) + backend = BACKEND_CUBEB; #endif return backend; } @@ -118,7 +119,8 @@ std::vector<std::string> GetSoundBackends() std::vector<std::string> backends; backends.emplace_back(BACKEND_NULLSOUND); - backends.emplace_back(BACKEND_CUBEB); + if (CubebStream::IsValid()) + backends.emplace_back(BACKEND_CUBEB); if (AlsaSound::IsValid()) backends.emplace_back(BACKEND_ALSA); if (PulseAudio::IsValid()) diff --git a/Source/Core/AudioCommon/CMakeLists.txt b/Source/Core/AudioCommon/CMakeLists.txt index 26dc443d90..d08a87247b 100644 --- a/Source/Core/AudioCommon/CMakeLists.txt +++ b/Source/Core/AudioCommon/CMakeLists.txt @@ -3,10 +3,7 @@ add_library(audiocommon AudioCommon.h AudioStretcher.cpp AudioStretcher.h - CubebStream.cpp CubebStream.h - CubebUtils.cpp - CubebUtils.h Enums.h Mixer.cpp Mixer.h @@ -18,6 +15,16 @@ add_library(audiocommon WaveFile.h ) +if(ENABLE_CUBEB) + message(STATUS "Cubeb found, enabling Cubeb sound backend") + target_sources(audiocommon PRIVATE + CubebStream.cpp + CubebUtils.cpp + CubebUtils.h + ) + target_link_libraries(audiocommon PRIVATE cubeb) +endif() + if(ANDROID) find_package(OpenSLES) if(OPENSLES_FOUND) @@ -83,10 +90,13 @@ PUBLIC common PRIVATE - cubeb::cubeb SoundTouch FreeSurround) +if(ENABLE_CUBEB) + target_link_libraries(audiocommon PRIVATE cubeb::cubeb) +endif() + if(MSVC) # Add precompiled header target_link_libraries(audiocommon PRIVATE use_pch) diff --git a/Source/Core/AudioCommon/CubebStream.h b/Source/Core/AudioCommon/CubebStream.h index 4b0c0e5eae..72d7d1c117 100644 --- a/Source/Core/AudioCommon/CubebStream.h +++ b/Source/Core/AudioCommon/CubebStream.h @@ -11,10 +11,13 @@ #include "AudioCommon/SoundStream.h" #include "Common/WorkQueueThread.h" +#ifdef HAVE_CUBEB #include <cubeb/cubeb.h> +#endif class CubebStream final : public SoundStream { +#ifdef HAVE_CUBEB public: CubebStream(); CubebStream(const CubebStream& other) = delete; @@ -25,6 +28,7 @@ public: bool Init() override; bool SetRunning(bool running) override; void SetVolume(int) override; + static bool IsValid() { return true; } private: bool m_stereo = false; @@ -43,4 +47,5 @@ private: static long DataCallback(cubeb_stream* stream, void* user_data, const void* /*input_buffer*/, void* output_buffer, long num_frames); static void StateCallback(cubeb_stream* stream, void* user_data, cubeb_state state); +#endif }; |
