From e1baf2ead48a7392dd6951035673e0b8dd6008a5 Mon Sep 17 00:00:00 2001 From: hrydgard Date: Tue, 21 Oct 2008 20:27:37 +0000 Subject: [PATCH] clip audio correctly in gigaherz' resampler git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@929 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Plugins/Plugin_DSP_HLE/Src/PCHW/Mixer.cpp | 10 ++++++++-- Source/Plugins/Plugin_DSP_LLE/Src/Mixer.cpp | 11 ++++++++--- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/Source/Plugins/Plugin_DSP_HLE/Src/PCHW/Mixer.cpp b/Source/Plugins/Plugin_DSP_HLE/Src/PCHW/Mixer.cpp index 2226d3f034..1aa29923b8 100644 --- a/Source/Plugins/Plugin_DSP_HLE/Src/PCHW/Mixer.cpp +++ b/Source/Plugins/Plugin_DSP_HLE/Src/PCHW/Mixer.cpp @@ -165,8 +165,14 @@ void Mixer_PushSamples(short *buffer, int num_stereo_samples, int sample_rate) { DataL = t3l; DataR = t3r; } - sample_queue.push(DataL); - sample_queue.push(DataR); + + int l = DataL, r = DataR; + if (l < -32767) l = -32767; + if (r < -32767) r = -32767; + if (l > 32767) l = 32767; + if (r > 32767) r = 32767; + sample_queue.push(l); + sample_queue.push(r); queue_size += 2; } push_sync.Leave(); diff --git a/Source/Plugins/Plugin_DSP_LLE/Src/Mixer.cpp b/Source/Plugins/Plugin_DSP_LLE/Src/Mixer.cpp index 373e0bba16..2c0b8fedad 100644 --- a/Source/Plugins/Plugin_DSP_LLE/Src/Mixer.cpp +++ b/Source/Plugins/Plugin_DSP_LLE/Src/Mixer.cpp @@ -151,9 +151,14 @@ void Mixer_PushSamples(short *buffer, int num_stereo_samples, int sample_rate) { DataL = t3l; DataR = t3r; } - sample_queue.push(DataL); - sample_queue.push(DataR); - queue_size += 2; + + int l = DataL, r = DataR; + if (l < -32767) l = -32767; + if (r < -32767) r = -32767; + if (l > 32767) l = 32767; + if (r > 32767) r = 32767; + sample_queue.push(l); + sample_queue.push(r); } push_sync.Leave(); }