summaryrefslogtreecommitdiff
path: root/Source/Core/AudioCommon/AudioCommon.cpp
diff options
context:
space:
mode:
authorConnor McLaughlin <stenzek@gmail.com>2019-10-06 17:24:48 +1000
committerGitHub <noreply@github.com>2019-10-06 17:24:48 +1000
commitdba7f3304dba67ab9d4c287267f102fd6e54a14e (patch)
tree63de59d69dd01b96cdd0025096a5f61d99703191 /Source/Core/AudioCommon/AudioCommon.cpp
parent86bf88d5afec0e93ea6cd7594f34431ec0960790 (diff)
parent71c3c5626bf8780150449933735d55ecf448d7e0 (diff)
Merge pull request #8361 from ligfx/remove_xaudio2
Remove XAudio2
Diffstat (limited to 'Source/Core/AudioCommon/AudioCommon.cpp')
-rw-r--r--Source/Core/AudioCommon/AudioCommon.cpp48
1 files changed, 24 insertions, 24 deletions
diff --git a/Source/Core/AudioCommon/AudioCommon.cpp b/Source/Core/AudioCommon/AudioCommon.cpp
index 11d50d9d01..dd9986077e 100644
--- a/Source/Core/AudioCommon/AudioCommon.cpp
+++ b/Source/Core/AudioCommon/AudioCommon.cpp
@@ -11,8 +11,6 @@
#include "AudioCommon/OpenSLESStream.h"
#include "AudioCommon/PulseAudioStream.h"
#include "AudioCommon/WASAPIStream.h"
-#include "AudioCommon/XAudio2Stream.h"
-#include "AudioCommon/XAudio2_7Stream.h"
#include "Common/Common.h"
#include "Common/FileUtil.h"
#include "Common/Logging/Log.h"
@@ -29,30 +27,37 @@ static bool s_sound_stream_running = false;
constexpr int AUDIO_VOLUME_MIN = 0;
constexpr int AUDIO_VOLUME_MAX = 100;
-void InitSoundStream()
+static std::unique_ptr<SoundStream> CreateSoundStreamForBackend(std::string_view backend)
{
- std::string backend = SConfig::GetInstance().sBackend;
if (backend == BACKEND_CUBEB)
- g_sound_stream = std::make_unique<CubebStream>();
+ return std::make_unique<CubebStream>();
else if (backend == BACKEND_OPENAL && OpenALStream::isValid())
- g_sound_stream = std::make_unique<OpenALStream>();
+ return std::make_unique<OpenALStream>();
else if (backend == BACKEND_NULLSOUND)
- g_sound_stream = std::make_unique<NullSound>();
- else if (backend == BACKEND_XAUDIO2)
- {
- if (XAudio2::isValid())
- g_sound_stream = std::make_unique<XAudio2>();
- else if (XAudio2_7::isValid())
- g_sound_stream = std::make_unique<XAudio2_7>();
- }
+ return std::make_unique<NullSound>();
else if (backend == BACKEND_ALSA && AlsaSound::isValid())
- g_sound_stream = std::make_unique<AlsaSound>();
+ return std::make_unique<AlsaSound>();
else if (backend == BACKEND_PULSEAUDIO && PulseAudio::isValid())
- g_sound_stream = std::make_unique<PulseAudio>();
+ return std::make_unique<PulseAudio>();
else if (backend == BACKEND_OPENSLES && OpenSLESStream::isValid())
- g_sound_stream = std::make_unique<OpenSLESStream>();
+ return std::make_unique<OpenSLESStream>();
else if (backend == BACKEND_WASAPI && WASAPIStream::isValid())
- g_sound_stream = std::make_unique<WASAPIStream>();
+ return std::make_unique<WASAPIStream>();
+ return {};
+}
+
+void InitSoundStream()
+{
+ std::string backend = SConfig::GetInstance().sBackend;
+ g_sound_stream = CreateSoundStreamForBackend(backend);
+
+ if (!g_sound_stream)
+ {
+ WARN_LOG(AUDIO, "Unknown backend %s, using %s instead.", backend.c_str(),
+ GetDefaultSoundBackend().c_str());
+ backend = GetDefaultSoundBackend();
+ g_sound_stream = CreateSoundStreamForBackend(GetDefaultSoundBackend());
+ }
if (!g_sound_stream || !g_sound_stream->Init())
{
@@ -101,8 +106,6 @@ std::vector<std::string> GetSoundBackends()
backends.emplace_back(BACKEND_NULLSOUND);
backends.emplace_back(BACKEND_CUBEB);
- if (XAudio2_7::isValid() || XAudio2::isValid())
- backends.emplace_back(BACKEND_XAUDIO2);
if (AlsaSound::isValid())
backends.emplace_back(BACKEND_ALSA);
if (PulseAudio::isValid())
@@ -127,8 +130,6 @@ bool SupportsDPL2Decoder(std::string_view backend)
return true;
if (backend == BACKEND_PULSEAUDIO)
return true;
- if (backend == BACKEND_XAUDIO2)
- return true;
return false;
}
@@ -142,8 +143,7 @@ bool SupportsVolumeChanges(std::string_view 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_CUBEB || backend == BACKEND_OPENAL || backend == BACKEND_XAUDIO2 ||
- backend == BACKEND_WASAPI;
+ return backend == BACKEND_CUBEB || backend == BACKEND_OPENAL || backend == BACKEND_WASAPI;
}
void UpdateSoundStream()