From 632e3bfc85ef7a6085aa0a2bc987f763bef2ad4c Mon Sep 17 00:00:00 2001 From: "sl1nk3.s" Date: Sat, 28 Mar 2009 14:08:06 +0000 Subject: [PATCH] A little fix for the Throttle, it wasn't getting the correct sample_rate thus was too fast git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2774 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/AudioCommon/Src/Mixer.cpp | 6 +++--- Source/Core/AudioCommon/Src/Mixer.h | 2 +- Source/Plugins/Plugin_DSP_HLE/Src/HLEMixer.cpp | 2 +- Source/Plugins/Plugin_DSP_HLE/Src/main.cpp | 5 ++++- Source/Plugins/Plugin_DSP_LLE-testing/Src/main.cpp | 2 +- 5 files changed, 10 insertions(+), 7 deletions(-) diff --git a/Source/Core/AudioCommon/Src/Mixer.cpp b/Source/Core/AudioCommon/Src/Mixer.cpp index 02cea2659c..38ce13dc2c 100644 --- a/Source/Core/AudioCommon/Src/Mixer.cpp +++ b/Source/Core/AudioCommon/Src/Mixer.cpp @@ -62,7 +62,7 @@ void CMixer::Mix(short *samples, int numSamples) } -void CMixer::PushSamples(short *samples, int num_stereo_samples) +void CMixer::PushSamples(short *samples, int num_stereo_samples, int core_sample_rate) { if (!soundStream) return; @@ -85,7 +85,7 @@ void CMixer::PushSamples(short *samples, int num_stereo_samples) #endif // Write Other Audio - if (! m_throttle) + if (!m_throttle) return; @@ -105,7 +105,7 @@ void CMixer::PushSamples(short *samples, int num_stereo_samples) push_sync.Enter(); while (num_stereo_samples) { - acc += m_sampleRate; + acc += core_sample_rate; while (num_stereo_samples && (acc >= 48000)) { PV4l=PV3l; PV3l=PV2l; diff --git a/Source/Core/AudioCommon/Src/Mixer.h b/Source/Core/AudioCommon/Src/Mixer.h index 433c70c61c..41dd544585 100644 --- a/Source/Core/AudioCommon/Src/Mixer.h +++ b/Source/Core/AudioCommon/Src/Mixer.h @@ -34,7 +34,7 @@ public: void Mix(short *sample, int numSamples); // Called from main thread - void PushSamples(short* samples, int num_stereo_samples); + void PushSamples(short* samples, int num_stereo_samples, int core_sample_rate); virtual void Premix(short *samples, int numSamples) {} diff --git a/Source/Plugins/Plugin_DSP_HLE/Src/HLEMixer.cpp b/Source/Plugins/Plugin_DSP_HLE/Src/HLEMixer.cpp index 7df54e8771..5a14b9809f 100644 --- a/Source/Plugins/Plugin_DSP_HLE/Src/HLEMixer.cpp +++ b/Source/Plugins/Plugin_DSP_HLE/Src/HLEMixer.cpp @@ -4,7 +4,7 @@ #include "HLEMixer.h" void HLEMixer::MixUCode(short *samples, int numSamples) { - //if this was called directly from the HLE, and not by timeout + // if this was called directly from the HLE, and not by timeout if (g_Config.m_EnableHLEAudio && IsHLEReady()) { IUCode* pUCode = CDSPHandler::GetInstance().GetUCode(); if (pUCode != NULL) diff --git a/Source/Plugins/Plugin_DSP_HLE/Src/main.cpp b/Source/Plugins/Plugin_DSP_HLE/Src/main.cpp index b80ed92927..bccece2ec3 100644 --- a/Source/Plugins/Plugin_DSP_HLE/Src/main.cpp +++ b/Source/Plugins/Plugin_DSP_HLE/Src/main.cpp @@ -346,7 +346,10 @@ void DSP_SendAIBuffer(unsigned int address, int sample_rate) //if (log_ai) // g_wave_writer.AddStereoSamples(samples, 8); } - pMixer->PushSamples(samples, 32 / 4); + + // sample_rate is usually 32k here, + // see Core/DSP/DSP.cpp for better information + pMixer->PushSamples(samples, 32 / 4, sample_rate); } // SoundStream is updated only when necessary (there is no 70 ms limit diff --git a/Source/Plugins/Plugin_DSP_LLE-testing/Src/main.cpp b/Source/Plugins/Plugin_DSP_LLE-testing/Src/main.cpp index c47b0859dd..f03d4315aa 100644 --- a/Source/Plugins/Plugin_DSP_LLE-testing/Src/main.cpp +++ b/Source/Plugins/Plugin_DSP_LLE-testing/Src/main.cpp @@ -371,7 +371,7 @@ void DSP_SendAIBuffer(unsigned int address, int sample_rate) //if (log_ai) // g_wave_writer.AddStereoSamples(samples, 8); } - soundStream->GetMixer()->PushSamples(samples, 32 / 4); + soundStream->GetMixer()->PushSamples(samples, 32 / 4, sample_rate); } // SoundStream is updated only when necessary (there is no 70 ms limit