AudioCommon: Move logic for default sound backend there from ConfigManager

This way, we don't have to leak the HAVE_ALSA define there.
This commit is contained in:
Florent Castelli 2017-02-05 02:15:38 +01:00
parent 31dfaafe0b
commit 9ebfaa9324
3 changed files with 20 additions and 11 deletions

View File

@ -92,6 +92,22 @@ 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;

View File

@ -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);

View File

@ -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);