Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #10947 from Zopolis4/opensleuth
Restrict OpenSLES to Android via CMake
  • Loading branch information
AdmiralCurtiss committed Jan 30, 2023
2 parents a2f4606 + e2aefe1 commit 8edca20
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
19 changes: 11 additions & 8 deletions Source/Core/AudioCommon/CMakeLists.txt
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions 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>
Expand Down Expand Up @@ -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
4 changes: 2 additions & 2 deletions Source/Core/AudioCommon/OpenSLESStream.h
Expand Up @@ -10,7 +10,7 @@

class OpenSLESStream final : public SoundStream
{
#ifdef ANDROID
#ifdef HAVE_OPENSL_ES
public:
~OpenSLESStream() override;
bool Init() override;
Expand All @@ -21,5 +21,5 @@ class OpenSLESStream final : public SoundStream
private:
std::thread thread;
Common::Event soundSyncEvent;
#endif // HAVE_OPENSL
#endif // HAVE_OPENSL_ES
};

0 comments on commit 8edca20

Please sign in to comment.