From 626494177615916fd51dbfb63e1456efd97fd316 Mon Sep 17 00:00:00 2001 From: Steve Bavin Date: Wed, 17 Jun 2009 11:19:51 +0000 Subject: Rework internal timestretch enable/disable code - fix FS#10341(hopefully). git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21317 a1c6a512-1295-4272-9138-f99709370657 --- apps/dsp.c | 49 ++++++++++++++++++++----------------------------- 1 file changed, 20 insertions(+), 29 deletions(-) (limited to 'apps') diff --git a/apps/dsp.c b/apps/dsp.c index 297a70d5a9..bbe53300d3 100644 --- a/apps/dsp.c +++ b/apps/dsp.c @@ -31,7 +31,6 @@ #include "settings.h" #include "replaygain.h" #include "misc.h" -#include "debug.h" #include "tdspeed.h" #include "buffer.h" @@ -267,22 +266,27 @@ void sound_set_pitch(int permille) static void tdspeed_setup(struct dsp_config *dspc) { + /* Assume timestretch will not not be used */ dspc->tdspeed_active = false; - if (dspc == &AUDIO_DSP) - { - if(!dsp_timestretch_available()) - return; - if (dspc->tdspeed_percent == 0) - dspc->tdspeed_percent = 100; - if (!tdspeed_config( - dspc->codec_frequency == 0 ? NATIVE_FREQUENCY : dspc->codec_frequency, - dspc->stereo_mode != STEREO_MONO, - dspc->tdspeed_percent)) - return; - if (dspc->tdspeed_percent == 100 || big_sample_buf_count <= 0) - return; - dspc->tdspeed_active = true; - } + sample_buf = small_sample_buf; + resample_buf = small_resample_buf; + sample_buf_count = SMALL_SAMPLE_BUF_COUNT; + + if(!dsp_timestretch_available()) + return; /* Timestretch not enabled or buffer not allocated */ + if (dspc->tdspeed_percent == 0) + dspc->tdspeed_percent = 100; + if (!tdspeed_config( + dspc->codec_frequency == 0 ? NATIVE_FREQUENCY : dspc->codec_frequency, + dspc->stereo_mode != STEREO_MONO, + dspc->tdspeed_percent)) + return; /* Timestretch not possible or needed with these parameters */ + + /* Timestretch is to be used */ + dspc->tdspeed_active = true; + sample_buf = big_sample_buf; + sample_buf_count = big_sample_buf_count; + resample_buf = big_resample_buf; } void dsp_timestretch_enable(bool enabled) @@ -1436,19 +1440,6 @@ intptr_t dsp_configure(struct dsp_config *dsp, int setting, intptr_t value) return 0; } - if (!dsp->tdspeed_active) - { - sample_buf = small_sample_buf; - resample_buf = small_resample_buf; - sample_buf_count = SMALL_SAMPLE_BUF_COUNT; - } - else - { - sample_buf = big_sample_buf; - sample_buf_count = big_sample_buf_count; - resample_buf = big_resample_buf; - } - return 1; } -- cgit v1.2.3