From eda3d48d5311bc2a2d566aa9d47119f9fcaf4c52 Mon Sep 17 00:00:00 2001 From: raven02 Date: Sun, 27 Apr 2014 22:05:53 +0800 Subject: [PATCH] Switch to low/medium/high audio latency mode --- Core/Config.cpp | 2 +- Core/Config.h | 2 +- Core/HLE/__sceAudio.cpp | 20 ++++++++++++++++++-- UI/GameSettingsScreen.cpp | 3 ++- 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/Core/Config.cpp b/Core/Config.cpp index f0ec2dd3e..9c74270c7 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -403,7 +403,7 @@ static ConfigSetting soundSettings[] = { ConfigSetting("Enable", &g_Config.bEnableSound, true), ConfigSetting("VolumeBGM", &g_Config.iBGMVolume, 7), ConfigSetting("VolumeSFX", &g_Config.iSFXVolume, 7), - ConfigSetting("LowLatency", &g_Config.bLowLatencyAudio, false), + ConfigSetting("AudioLatency", &g_Config.IaudioLatency, 1), ConfigSetting(false), }; diff --git a/Core/Config.h b/Core/Config.h index 00432e2ee..4e7e153f5 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -148,7 +148,7 @@ public: // Sound bool bEnableSound; - bool bLowLatencyAudio; + int IaudioLatency; // 0 = low , 1 = medium(default) , 2 = high int iSFXVolume; int iBGMVolume; diff --git a/Core/HLE/__sceAudio.cpp b/Core/HLE/__sceAudio.cpp index 82429f107..8f98e063a 100644 --- a/Core/HLE/__sceAudio.cpp +++ b/Core/HLE/__sceAudio.cpp @@ -37,6 +37,12 @@ atomic_flag atomicLock_; recursive_mutex mutex_; +enum latency { + LOW_LATENCY = 0, + MEDIUM_LATENCY = 1, + HIGH_LATENCY = 2, +}; + int eventAudioUpdate = -1; int eventHostAudioUpdate = -1; int mixFrequency = 44100; @@ -92,16 +98,26 @@ void hleHostAudioUpdate(u64 userdata, int cyclesLate) { void __AudioInit() { mixFrequency = 44100; - if (g_Config.bLowLatencyAudio) { + switch (g_Config.IaudioLatency) { + case LOW_LATENCY: chanQueueMaxSizeFactor = 1; chanQueueMinSizeFactor = 1; hwBlockSize = 16; hostAttemptBlockSize = 256; - } else { + break; + case MEDIUM_LATENCY: chanQueueMaxSizeFactor = 2; chanQueueMinSizeFactor = 1; hwBlockSize = 64; hostAttemptBlockSize = 512; + break; + case HIGH_LATENCY: + chanQueueMaxSizeFactor = 4; + chanQueueMinSizeFactor = 2; + hwBlockSize = 64; + hostAttemptBlockSize = 512; + break; + } audioIntervalUs = (int)(1000000ULL * hwBlockSize / hwSampleRate); diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 0b2d8d0ee..61809e74d 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -243,7 +243,8 @@ void GameSettingsScreen::CreateViews() { bgmVol->SetEnabledPtr(&g_Config.bEnableSound); audioSettings->Add(new CheckBox(&g_Config.bEnableSound, a->T("Enable Sound"))); - CheckBox *lowAudio = audioSettings->Add(new CheckBox(&g_Config.bLowLatencyAudio, a->T("Low latency audio"))); + 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); audioSettings->Add(new ItemHeader(a->T("Audio hacks")));