From 790024c829af4422dd1b67ce9596b84660e55ad5 Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Sat, 24 Jan 2015 13:50:27 +0100 Subject: [PATCH] Add option to choose Audio backend, as WASAPI does not seem to be ideal for everyone.. Default to WASAPI though (Auto) --- Core/Config.cpp | 1 + Core/Config.h | 7 +++++++ UI/GameSettingsScreen.cpp | 7 +++++++ UI/NativeApp.cpp | 2 +- Windows/DSoundStream.h | 7 +------ 5 files changed, 17 insertions(+), 7 deletions(-) diff --git a/Core/Config.cpp b/Core/Config.cpp index c98175169..483ffe11f 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -470,6 +470,7 @@ static ConfigSetting graphicsSettings[] = { static ConfigSetting soundSettings[] = { ConfigSetting("Enable", &g_Config.bEnableSound, true, true, true), + ConfigSetting("AudioBackend", &g_Config.iAudioBackend, 0, true, true), ConfigSetting("AudioLatency", &g_Config.iAudioLatency, 1, true, true), ConfigSetting("SoundSpeedHack", &g_Config.bSoundSpeedHack, false, true, true), diff --git a/Core/Config.h b/Core/Config.h index d55f7f007..f82975720 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -50,6 +50,12 @@ enum { GPU_BACKEND_DIRECT3D9 = 1, }; +enum AudioBackendType { + AUDIO_BACKEND_AUTO, + AUDIO_BACKEND_DSOUND, + AUDIO_BACKEND_WASAPI, +}; + // For iIOTimingMethod. enum IOTimingMethods { IOTIMING_FAST = 0, @@ -186,6 +192,7 @@ public: // Sound bool bEnableSound; int iAudioLatency; // 0 = low , 1 = medium(default) , 2 = high + int iAudioBackend; // Audio Hack bool bSoundSpeedHack; diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 06c6036d7..1568e3741 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -325,6 +325,13 @@ void GameSettingsScreen::CreateViews() { audioSettings->Add(new ItemHeader(ms->T("Audio"))); audioSettings->Add(new CheckBox(&g_Config.bEnableSound, a->T("Enable Sound"))); + +#ifdef _WIN32 + static const char *backend[] = { "Auto", "WASAPI (fast)", "DirectSound (compatible)" }; + PopupMultiChoice *audioBackend = audioSettings->Add(new PopupMultiChoice(&g_Config.iAudioBackend, a->T("Audio backend"), backend, 0, ARRAY_SIZE(backend), a, screenManager())); + audioBackend->SetEnabledPtr(&g_Config.bEnableSound); +#endif + static const char *latency[] = { "Low", "Medium", "High" }; PopupMultiChoice *lowAudio = audioSettings->Add(new PopupMultiChoice(&g_Config.iAudioLatency, a->T("Audio Latency"), latency, 0, ARRAY_SIZE(latency), gs, screenManager())); lowAudio->SetEnabledPtr(&g_Config.bEnableSound); diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index f98370557..6f8d3da84 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -577,7 +577,7 @@ void NativeInitGraphics() { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); #ifdef _WIN32 - winAudioBackend = CreateAudioBackend(AUDIO_BACKEND_AUTO); + winAudioBackend = CreateAudioBackend((AudioBackendType)g_Config.iAudioBackend); winAudioBackend->Init(MainWindow::GetHWND(), &Win32Mix, 44100); #endif } diff --git a/Windows/DSoundStream.h b/Windows/DSoundStream.h index d6c4acb49..95aee9632 100644 --- a/Windows/DSoundStream.h +++ b/Windows/DSoundStream.h @@ -1,6 +1,7 @@ #pragma once #include "Common/CommonWindows.h" +#include "Core/Config.h" typedef int (*StreamCallback)(short *buffer, int numSamples, int bits, int rate, int channels); @@ -15,11 +16,5 @@ public: virtual int GetSampleRate() = 0; }; -enum AudioBackendType { - AUDIO_BACKEND_DSOUND, - AUDIO_BACKEND_WASAPI, - AUDIO_BACKEND_AUTO -}; - // Factory WindowsAudioBackend *CreateAudioBackend(AudioBackendType type);