AudioCommon: add Cubeb backend

This commit is contained in:
Michael Maltese
2017-03-22 16:09:59 -07:00
parent 17f4413143
commit f6e1da0dc0
8 changed files with 168 additions and 4 deletions

View File

@ -5,6 +5,7 @@
#include "AudioCommon/AudioCommon.h"
#include "AudioCommon/AlsaSoundStream.h"
#include "AudioCommon/CoreAudioSoundStream.h"
#include "AudioCommon/CubebStream.h"
#include "AudioCommon/Mixer.h"
#include "AudioCommon/NullSoundStream.h"
#include "AudioCommon/OpenALStream.h"
@ -30,7 +31,9 @@ static const int AUDIO_VOLUME_MAX = 100;
void InitSoundStream()
{
std::string backend = SConfig::GetInstance().sBackend;
if (backend == BACKEND_OPENAL && OpenALStream::isValid())
if (backend == BACKEND_CUBEB)
g_sound_stream = std::make_unique<CubebStream>();
else if (backend == BACKEND_OPENAL && OpenALStream::isValid())
g_sound_stream = std::make_unique<OpenALStream>();
else if (backend == BACKEND_NULLSOUND)
g_sound_stream = std::make_unique<NullSound>();
@ -110,6 +113,7 @@ std::vector<std::string> GetSoundBackends()
std::vector<std::string> backends;
backends.push_back(BACKEND_NULLSOUND);
backends.push_back(BACKEND_CUBEB);
if (XAudio2_7::isValid() || XAudio2::isValid())
backends.push_back(BACKEND_XAUDIO2);
if (AlsaSound::isValid())
@ -131,6 +135,8 @@ bool SupportsDPL2Decoder(const std::string& backend)
if (backend == BACKEND_OPENAL)
return true;
#endif
if (backend == BACKEND_CUBEB)
return true;
if (backend == BACKEND_PULSEAUDIO)
return true;
return false;
@ -146,7 +152,8 @@ bool SupportsVolumeChanges(const std::string& backend)
// FIXME: this one should ask the backend whether it supports it.
// but getting the backend from string etc. is probably
// too much just to enable/disable a stupid slider...
return backend == BACKEND_COREAUDIO || backend == BACKEND_OPENAL || backend == BACKEND_XAUDIO2;
return backend == BACKEND_COREAUDIO || backend == BACKEND_CUBEB || backend == BACKEND_OPENAL ||
backend == BACKEND_XAUDIO2;
}
void UpdateSoundStream()