From 18e70cdf917fc355e59558dce8614431a29cc5ed Mon Sep 17 00:00:00 2001 From: Michael Maltese Date: Sun, 25 Jun 2017 23:52:51 -0700 Subject: [PATCH] Only build OpenAL on Windows --- CMakeLists.txt | 1 - Source/Core/AudioCommon/CMakeLists.txt | 27 +++++++++--------------- Source/Core/AudioCommon/OpenALStream.cpp | 4 ++-- Source/Core/AudioCommon/OpenALStream.h | 15 +++---------- Source/VSProps/Base.props | 1 - 5 files changed, 15 insertions(+), 33 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cfdea29ead..098caad8bb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,7 +21,6 @@ option(ENABLE_GENERIC "Enables generic build that should run on any little-endia option(ENABLE_HEADLESS "Enables running Dolphin as a headless variant" OFF) option(ENABLE_ALSA "Enables ALSA sound backend" ON) option(ENABLE_PULSEAUDIO "Enables PulseAudio sound backend" ON) -option(ENABLE_OPENAL "Enables OpenAL sound backend" ON) option(ENABLE_LLVM "Enables LLVM support, for disassembly" ON) # Maintainers: if you consider blanket disabling this for your users, please diff --git a/Source/Core/AudioCommon/CMakeLists.txt b/Source/Core/AudioCommon/CMakeLists.txt index 7ed1eba65d..e39296d6cb 100644 --- a/Source/Core/AudioCommon/CMakeLists.txt +++ b/Source/Core/AudioCommon/CMakeLists.txt @@ -32,23 +32,6 @@ else() message(STATUS "ALSA explicitly disabled, disabling ALSA sound backend") endif() -if(ENABLE_OPENAL) - if(WIN32) - set(ENV{OPENALDIR} ${PROJECT_SOURCE_DIR}/Externals/OpenAL) - endif() - find_package(OpenAL) - if(OPENAL_FOUND) - message(STATUS "OpenAL found, enabling OpenAL sound backend") - target_sources(audiocommon PRIVATE OpenALStream.cpp) - target_link_libraries(audiocommon PRIVATE OpenAL::OpenAL) - target_compile_definitions(audiocommon PRIVATE HAVE_OPENAL=1) - else() - message(STATUS "OpenAL NOT found, disabling OpenAL sound backend") - endif() -else() - message(STATUS "OpenAL explicitly disabled, disabling OpenAL sound backend") -endif() - if(ENABLE_PULSEAUDIO) # PulseAudio ships with a PulseAudioConfig.cmake with no imported target # So we use our own FindPulseAudio instead with "MODULE" @@ -75,6 +58,16 @@ if(WIN32) ) target_link_libraries(audiocommon PRIVATE audiocommon_xaudio27) + set(ENV{OPENALDIR} ${PROJECT_SOURCE_DIR}/Externals/OpenAL) + find_package(OpenAL) + if(OPENAL_FOUND) + message(STATUS "OpenAL found, enabling OpenAL sound backend") + target_sources(audiocommon PRIVATE OpenALStream.cpp) + target_link_libraries(audiocommon PRIVATE OpenAL::OpenAL) + else() + message(FATAL_ERROR "OpenAL NOT found in Externals") + endif() + elseif(APPLE) target_sources(audiocommon PRIVATE CoreAudioSoundStream.cpp) endif() diff --git a/Source/Core/AudioCommon/OpenALStream.cpp b/Source/Core/AudioCommon/OpenALStream.cpp index ffb0bf93dd..1265b27ae2 100644 --- a/Source/Core/AudioCommon/OpenALStream.cpp +++ b/Source/Core/AudioCommon/OpenALStream.cpp @@ -2,7 +2,7 @@ // Licensed under GPLv2+ // Refer to the license.txt file included. -#if defined HAVE_OPENAL && HAVE_OPENAL +#ifdef _WIN32 #include #include @@ -347,4 +347,4 @@ void OpenALStream::SoundLoop() } } -#endif // HAVE_OPENAL +#endif // _WIN32 diff --git a/Source/Core/AudioCommon/OpenALStream.h b/Source/Core/AudioCommon/OpenALStream.h index 5e4b49c027..2fb7d8cd27 100644 --- a/Source/Core/AudioCommon/OpenALStream.h +++ b/Source/Core/AudioCommon/OpenALStream.h @@ -12,19 +12,10 @@ #include "Core/HW/AudioInterface.h" #include "Core/HW/SystemTimers.h" -#if defined HAVE_OPENAL && HAVE_OPENAL #ifdef _WIN32 #include #include #include -#elif defined __APPLE__ -#include -#include -#else -#include -#include -#include -#endif #define SFX_MAX_SOURCE 1 #define OAL_MAX_BUFFERS 32 @@ -40,7 +31,7 @@ #define FRAME_SURROUND_FLOAT SURROUND_CHANNELS* SIZE_FLOAT #define FRAME_SURROUND_SHORT SURROUND_CHANNELS* SIZE_SHORT #define FRAME_SURROUND_INT32 SURROUND_CHANNELS* SIZE_INT32 -#endif +#endif // _WIN32 // From AL_EXT_float32 #ifndef AL_FORMAT_STEREO_FLOAT32 @@ -63,7 +54,7 @@ class OpenALStream final : public SoundStream { -#if defined HAVE_OPENAL && HAVE_OPENAL +#ifdef _WIN32 public: OpenALStream() : uiSource(0) {} bool Start() override; @@ -87,5 +78,5 @@ private: ALfloat fVolume; u8 numBuffers; -#endif // HAVE_OPENAL +#endif // _WIN32 }; diff --git a/Source/VSProps/Base.props b/Source/VSProps/Base.props index b7d04a6602..1bad01e9d0 100644 --- a/Source/VSProps/Base.props +++ b/Source/VSProps/Base.props @@ -61,7 +61,6 @@ SFML_STATIC;%(PreprocessorDefinitions) USE_ANALYTICS=1;%(PreprocessorDefinitions) CURL_STATICLIB;%(PreprocessorDefinitions) - HAVE_OPENAL=1;%(PreprocessorDefinitions) _ARCH_64=1;_M_X86_64=1;%(PreprocessorDefinitions)