Merge pull request #5975 from raven02/patch-32

Audio : add low/medium/high audio latency mode
This commit is contained in:
Henrik Rydgård 2014-05-08 11:00:01 +02:00
commit 155dcee5a6
4 changed files with 22 additions and 5 deletions

View File

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

View File

@ -148,7 +148,7 @@ public:
// Sound
bool bEnableSound;
bool bLowLatencyAudio;
int IaudioLatency; // 0 = low , 1 = medium(default) , 2 = high
int iSFXVolume;
int iBGMVolume;

View File

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

View File

@ -234,7 +234,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")));