summaryrefslogtreecommitdiff
path: root/Source/Core/AudioCommon
diff options
context:
space:
mode:
authorAdmiral H. Curtiss <pikachu025@gmail.com>2023-01-30 09:02:45 +0100
committerGitHub <noreply@github.com>2023-01-30 09:02:45 +0100
commit8edca2039ef5cee58a2ca4637794fdf831638a47 (patch)
tree2196598c499f89c9d6b17c080012f1e6247638ec /Source/Core/AudioCommon
parenta2f4606d33a4b111f21f0e59f7d57897e041d25e (diff)
parente2aefe13a6ac924508e5749439d047fb4a6317d6 (diff)
Merge pull request #10947 from Zopolis4/opensleuth
Restrict OpenSLES to Android via CMake
Diffstat (limited to 'Source/Core/AudioCommon')
-rw-r--r--Source/Core/AudioCommon/CMakeLists.txt19
-rw-r--r--Source/Core/AudioCommon/OpenSLESStream.cpp4
-rw-r--r--Source/Core/AudioCommon/OpenSLESStream.h4
3 files changed, 15 insertions, 12 deletions
diff --git a/Source/Core/AudioCommon/CMakeLists.txt b/Source/Core/AudioCommon/CMakeLists.txt
index b3a9c57b42..18cc67470b 100644
--- a/Source/Core/AudioCommon/CMakeLists.txt
+++ b/Source/Core/AudioCommon/CMakeLists.txt
@@ -18,14 +18,17 @@ add_library(audiocommon
WaveFile.h
)
-find_package(OpenSLES)
-if(OPENSLES_FOUND)
- message(STATUS "OpenSLES found, enabling OpenSLES sound backend")
- target_sources(audiocommon PRIVATE
- OpenSLESStream.cpp
- OpenSLESStream.h
- )
- target_link_libraries(audiocommon PRIVATE OpenSLES::OpenSLES)
+if(ANDROID)
+ find_package(OpenSLES)
+ if(OPENSLES_FOUND)
+ message(STATUS "OpenSLES found, enabling OpenSLES sound backend")
+ target_sources(audiocommon PRIVATE
+ OpenSLESStream.cpp
+ OpenSLESStream.h
+ )
+ target_link_libraries(audiocommon PRIVATE OpenSLES::OpenSLES)
+ target_compile_definitions(audiocommon PRIVATE HAVE_OPENSL_ES=1)
+ endif()
endif()
if(ENABLE_ALSA)
diff --git a/Source/Core/AudioCommon/OpenSLESStream.cpp b/Source/Core/AudioCommon/OpenSLESStream.cpp
index fcf2ca58e6..a35b981017 100644
--- a/Source/Core/AudioCommon/OpenSLESStream.cpp
+++ b/Source/Core/AudioCommon/OpenSLESStream.cpp
@@ -1,7 +1,7 @@
// Copyright 2013 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
-#ifdef ANDROID
+#ifdef HAVE_OPENSL_ES
#include "AudioCommon/OpenSLESStream.h"
#include <cmath>
@@ -143,4 +143,4 @@ void OpenSLESStream::SetVolume(int volume)
volume <= 0 ? SL_MILLIBEL_MIN : static_cast<SLmillibel>(2000 * std::log10(volume / 100.0f));
(*bqPlayerVolume)->SetVolumeLevel(bqPlayerVolume, attenuation);
}
-#endif
+#endif // HAVE_OPENSL_ES
diff --git a/Source/Core/AudioCommon/OpenSLESStream.h b/Source/Core/AudioCommon/OpenSLESStream.h
index 08e8d0ed4a..0aae560ce6 100644
--- a/Source/Core/AudioCommon/OpenSLESStream.h
+++ b/Source/Core/AudioCommon/OpenSLESStream.h
@@ -10,7 +10,7 @@
class OpenSLESStream final : public SoundStream
{
-#ifdef ANDROID
+#ifdef HAVE_OPENSL_ES
public:
~OpenSLESStream() override;
bool Init() override;
@@ -21,5 +21,5 @@ public:
private:
std::thread thread;
Common::Event soundSyncEvent;
-#endif // HAVE_OPENSL
+#endif // HAVE_OPENSL_ES
};