mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-24 06:39:46 -06:00
Merge pull request #4825 from Orphis/cmake_alsa
CMake: Updates to AudioCommon & ALSA discovery
This commit is contained in:
@ -33,7 +33,7 @@ void InitSoundStream()
|
||||
std::string backend = SConfig::GetInstance().sBackend;
|
||||
if (backend == BACKEND_OPENAL && OpenALStream::isValid())
|
||||
g_sound_stream = std::make_unique<OpenALStream>();
|
||||
else if (backend == BACKEND_NULLSOUND && NullSound::isValid())
|
||||
else if (backend == BACKEND_NULLSOUND)
|
||||
g_sound_stream = std::make_unique<NullSound>();
|
||||
else if (backend == BACKEND_XAUDIO2)
|
||||
{
|
||||
@ -53,7 +53,7 @@ void InitSoundStream()
|
||||
else if (backend == BACKEND_OPENSLES && OpenSLESStream::isValid())
|
||||
g_sound_stream = std::make_unique<OpenSLESStream>();
|
||||
|
||||
if (!g_sound_stream && NullSound::isValid())
|
||||
if (!g_sound_stream)
|
||||
{
|
||||
WARN_LOG(AUDIO, "Could not initialize backend %s, using %s instead.", backend.c_str(),
|
||||
BACKEND_NULLSOUND);
|
||||
@ -92,12 +92,27 @@ void ShutdownSoundStream()
|
||||
INFO_LOG(AUDIO, "Done shutting down sound stream");
|
||||
}
|
||||
|
||||
std::string GetDefaultSoundBackend()
|
||||
{
|
||||
std::string backend = BACKEND_NULLSOUND;
|
||||
#if defined __linux__
|
||||
if (AlsaSound::isValid())
|
||||
backend = BACKEND_ALSA;
|
||||
#elif defined __APPLE__
|
||||
backend = BACKEND_COREAUDIO;
|
||||
#elif defined _WIN32
|
||||
backend = BACKEND_XAUDIO2;
|
||||
#elif defined ANDROID
|
||||
backend = BACKEND_OPENSLES;
|
||||
#endif
|
||||
return backend;
|
||||
}
|
||||
|
||||
std::vector<std::string> GetSoundBackends()
|
||||
{
|
||||
std::vector<std::string> backends;
|
||||
|
||||
if (NullSound::isValid())
|
||||
backends.push_back(BACKEND_NULLSOUND);
|
||||
backends.push_back(BACKEND_NULLSOUND);
|
||||
if (XAudio2_7::isValid() || XAudio2::isValid())
|
||||
backends.push_back(BACKEND_XAUDIO2);
|
||||
if (AOSound::isValid())
|
||||
|
@ -18,6 +18,7 @@ namespace AudioCommon
|
||||
{
|
||||
void InitSoundStream();
|
||||
void ShutdownSoundStream();
|
||||
std::string GetDefaultSoundBackend();
|
||||
std::vector<std::string> GetSoundBackends();
|
||||
bool SupportsDPL2Decoder(const std::string& backend);
|
||||
bool SupportsLatencyControl(const std::string& backend);
|
||||
|
@ -1,51 +1,61 @@
|
||||
set(SRCS AudioCommon.cpp
|
||||
DPL2Decoder.cpp
|
||||
Mixer.cpp
|
||||
WaveFile.cpp
|
||||
NullSoundStream.cpp)
|
||||
set(SRCS
|
||||
AudioCommon.cpp
|
||||
DPL2Decoder.cpp
|
||||
Mixer.cpp
|
||||
WaveFile.cpp
|
||||
NullSoundStream.cpp
|
||||
)
|
||||
|
||||
set(LIBS "")
|
||||
add_dolphin_library(audiocommon "${SRCS}" "")
|
||||
|
||||
find_package(OpenSLES)
|
||||
if(OPENSLES_FOUND)
|
||||
message(STATUS "OpenSLES found, enabling OpenSLES sound backend")
|
||||
set(SRCS ${SRCS} OpenSLESStream.cpp)
|
||||
set(LIBS ${LIBS} OpenSLES::OpenSLES)
|
||||
message(STATUS "OpenSLES found, enabling OpenSLES sound backend")
|
||||
target_sources(audiocommon PRIVATE OpenSLESStream.cpp)
|
||||
target_link_libraries(audiocommon PRIVATE OpenSLES::OpenSLES)
|
||||
endif()
|
||||
|
||||
if(ALSA_FOUND)
|
||||
set(SRCS ${SRCS} AlsaSoundStream.cpp)
|
||||
set(LIBS ${LIBS} ${ALSA_LIBRARIES})
|
||||
if(ENABLE_ALSA)
|
||||
find_package(ALSA)
|
||||
if(ALSA_FOUND)
|
||||
message(STATUS "ALSA found, enabling ALSA sound backend")
|
||||
target_sources(audiocommon PRIVATE AlsaSoundStream.cpp)
|
||||
target_link_libraries(audiocommon PRIVATE ALSA::ALSA)
|
||||
target_compile_definitions(audiocommon PRIVATE HAVE_ALSA=1)
|
||||
else()
|
||||
message(STATUS "ALSA NOT found, disabling ALSA sound backend")
|
||||
endif()
|
||||
else()
|
||||
message(STATUS "ALSA explicitly disabled, disabling ALSA sound backend")
|
||||
endif()
|
||||
|
||||
if(AO_FOUND)
|
||||
set(SRCS ${SRCS} AOSoundStream.cpp)
|
||||
set(LIBS ${LIBS} ${AO_LIBRARIES})
|
||||
target_sources(audiocommon PRIVATE AOSoundStream.cpp)
|
||||
target_link_libraries(audiocommon PRIVATE ${AO_LIBRARIES})
|
||||
endif()
|
||||
|
||||
if(OPENAL_FOUND)
|
||||
set(SRCS ${SRCS} OpenALStream.cpp aldlist.cpp)
|
||||
set(LIBS ${LIBS} ${OPENAL_LIBRARY} SoundTouch )
|
||||
target_sources(audiocommon PRIVATE OpenALStream.cpp aldlist.cpp)
|
||||
target_link_libraries(audiocommon PRIVATE ${OPENAL_LIBRARY} SoundTouch)
|
||||
endif()
|
||||
|
||||
if(PULSEAUDIO_FOUND)
|
||||
set(SRCS ${SRCS} PulseAudioStream.cpp)
|
||||
set(LIBS ${LIBS} ${PULSEAUDIO_LIBRARIES})
|
||||
target_sources(audiocommon PRIVATE PulseAudioStream.cpp)
|
||||
target_link_libraries(audiocommon PRIVATE ${PULSEAUDIO_LIBRARIES})
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
set(SRCS ${SRCS} XAudio2Stream.cpp)
|
||||
target_sources(audiocommon PRIVATE XAudio2Stream.cpp)
|
||||
|
||||
add_dolphin_library(audiocommon_xaudio27 "XAudio2_7Stream.cpp" "${LIBS}")
|
||||
target_include_directories(audiocommon_xaudio27 PRIVATE
|
||||
${PROJECT_SOURCE_DIR}/Externals
|
||||
${PROJECT_SOURCE_DIR}/Externals/XAudio2_7
|
||||
)
|
||||
list(APPEND LIBS audiocommon_xaudio27)
|
||||
add_dolphin_library(audiocommon_xaudio27 "XAudio2_7Stream.cpp" "${LIBS}")
|
||||
target_include_directories(audiocommon_xaudio27 PRIVATE
|
||||
${PROJECT_SOURCE_DIR}/Externals
|
||||
${PROJECT_SOURCE_DIR}/Externals/XAudio2_7
|
||||
)
|
||||
target_link_libraries(audiocommon PRIVATE audiocommon_xaudio27)
|
||||
|
||||
elseif(APPLE)
|
||||
set(SRCS ${SRCS} CoreAudioSoundStream.cpp)
|
||||
target_sources(audiocommon PRIVATE CoreAudioSoundStream.cpp)
|
||||
endif()
|
||||
|
||||
|
||||
add_dolphin_library(audiocommon "${SRCS}" "${LIBS}")
|
||||
|
@ -6,6 +6,8 @@
|
||||
#include <climits>
|
||||
#include <memory>
|
||||
|
||||
#include "AudioCommon/AudioCommon.h"
|
||||
|
||||
#include "Common/CDUtils.h"
|
||||
#include "Common/CommonPaths.h"
|
||||
#include "Common/CommonTypes.h"
|
||||
@ -613,17 +615,7 @@ void SConfig::LoadDSPSettings(IniFile& ini)
|
||||
dsp->Get("DumpAudio", &m_DumpAudio, false);
|
||||
dsp->Get("DumpAudioSilent", &m_DumpAudioSilent, false);
|
||||
dsp->Get("DumpUCode", &m_DumpUCode, false);
|
||||
#if defined __linux__ && HAVE_ALSA
|
||||
dsp->Get("Backend", &sBackend, BACKEND_ALSA);
|
||||
#elif defined __APPLE__
|
||||
dsp->Get("Backend", &sBackend, BACKEND_COREAUDIO);
|
||||
#elif defined _WIN32
|
||||
dsp->Get("Backend", &sBackend, BACKEND_XAUDIO2);
|
||||
#elif defined ANDROID
|
||||
dsp->Get("Backend", &sBackend, BACKEND_OPENSLES);
|
||||
#else
|
||||
dsp->Get("Backend", &sBackend, BACKEND_NULLSOUND);
|
||||
#endif
|
||||
dsp->Get("Backend", &sBackend, AudioCommon::GetDefaultSoundBackend());
|
||||
dsp->Get("Volume", &m_Volume, 100);
|
||||
dsp->Get("CaptureLog", &m_DSPCaptureLog, false);
|
||||
|
||||
|
Reference in New Issue
Block a user