From 13dda7494629bff0f81c1f66f7836908841ecdd7 Mon Sep 17 00:00:00 2001 From: skidau Date: Mon, 1 Nov 2010 23:41:20 +0000 Subject: [PATCH] Allow the game to set the DSP sample rate. Fixes Bomberman Generation. Fixes issue 2523. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6328 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/Core/Src/HW/AudioInterface.cpp | 5 +++++ Source/Core/Core/Src/HW/AudioInterface.h | 3 +++ Source/Core/Core/Src/HW/SystemTimers.cpp | 5 +++-- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Source/Core/Core/Src/HW/AudioInterface.cpp b/Source/Core/Core/Src/HW/AudioInterface.cpp index 2795f892a4..2a3bfdfcdd 100644 --- a/Source/Core/Core/Src/HW/AudioInterface.cpp +++ b/Source/Core/Core/Src/HW/AudioInterface.cpp @@ -393,6 +393,11 @@ void IncreaseSampleCount(const u32 _iAmount) } } +unsigned int GetDSPSampleRate() +{ + return g_DACSampleRate; +} + void Update() { // update timer diff --git a/Source/Core/Core/Src/HW/AudioInterface.h b/Source/Core/Core/Src/HW/AudioInterface.h index e4cb463b1b..4a04dba919 100644 --- a/Source/Core/Core/Src/HW/AudioInterface.h +++ b/Source/Core/Core/Src/HW/AudioInterface.h @@ -40,6 +40,9 @@ unsigned int Callback_GetStreaming(short* _pDestBuffer, unsigned int _numSamples void Read32(u32& _uReturnValue, const u32 _iAddress); void Write32(const u32 _iValue, const u32 _iAddress); +// Get the audio rates (48000 or 32000 only) +unsigned int GetDSPSampleRate(); + } // namespace #endif diff --git a/Source/Core/Core/Src/HW/SystemTimers.cpp b/Source/Core/Core/Src/HW/SystemTimers.cpp index 99d209ad69..ea23043dc4 100644 --- a/Source/Core/Core/Src/HW/SystemTimers.cpp +++ b/Source/Core/Core/Src/HW/SystemTimers.cpp @@ -166,8 +166,9 @@ void DSPCallback(u64 userdata, int cyclesLate) void AudioDMACallback(u64 userdata, int cyclesLate) { + int period = CPU_CORE_CLOCK / (AudioInterface::GetDSPSampleRate() * 4 / 32); DSP::UpdateAudioDMA(); // Push audio to speakers. - CoreTiming::ScheduleEvent(AUDIO_DMA_PERIOD - cyclesLate, et_AudioDMA); + CoreTiming::ScheduleEvent(period - cyclesLate, et_AudioDMA); } void IPC_HLE_UpdateCallback(u64 userdata, int cyclesLate) @@ -279,7 +280,7 @@ void Init() AI_PERIOD = GetTicksPerSecond() / 80; // System internal sample rate is fixed at 32KHz * 4 (16bit Stereo) / 32 bytes DMA - AUDIO_DMA_PERIOD = CPU_CORE_CLOCK / (32000 * 4 / 32); + AUDIO_DMA_PERIOD = CPU_CORE_CLOCK / (AudioInterface::GetDSPSampleRate() * 4 / 32); Common::Timer::IncreaseResolution(); // store and convert localtime at boot to timebase ticks