From cb57a568e8dc9def607dc9ab27f515309bd13841 Mon Sep 17 00:00:00 2001 From: Thomas Martitz Date: Tue, 16 Jun 2009 00:59:24 +0000 Subject: Get rid of tdspeed_enabled in struct dsp_config and use the global_settings member instead. That one needs to be checked in tdspeed_init() as well, else the buffers are always allocated. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21305 a1c6a512-1295-4272-9138-f99709370657 --- apps/dsp.c | 9 ++++----- apps/tdspeed.c | 23 ++++++++++++++--------- 2 files changed, 18 insertions(+), 14 deletions(-) (limited to 'apps') diff --git a/apps/dsp.c b/apps/dsp.c index 496e333bc5..a68b8615f8 100644 --- a/apps/dsp.c +++ b/apps/dsp.c @@ -161,7 +161,6 @@ struct dsp_config int sample_depth; int sample_bytes; int stereo_mode; - bool tdspeed_enabled; /* User has enabled timestretch */ int tdspeed_percent; /* Speed % */ bool tdspeed_active; /* Timestretch is in use */ int frac_bits; @@ -266,12 +265,12 @@ void sound_set_pitch(int permille) AUDIO_DSP.codec_frequency); } -void tdspeed_setup(struct dsp_config *dspc) +static void tdspeed_setup(struct dsp_config *dspc) { dspc->tdspeed_active = false; if (dspc == &AUDIO_DSP) { - if (!dspc->tdspeed_enabled) + if(!dsp_timestretch_enabled()) return; if (dspc->tdspeed_percent == 0) dspc->tdspeed_percent = 100; @@ -304,7 +303,7 @@ void dsp_timestretch_enable(bool enable) if (big_sample_buf_count < 0) big_sample_buf_count = 0; } - AUDIO_DSP.tdspeed_enabled = enable; + global_settings.timestretch_enabled = enable; tdspeed_setup(&AUDIO_DSP); } @@ -321,7 +320,7 @@ int dsp_get_timestretch() bool dsp_timestretch_enabled() { - return (AUDIO_DSP.tdspeed_enabled && big_sample_buf_count > 0); + return (global_settings.timestretch_enabled && big_sample_buf_count > 0); } /* Convert count samples to the internal format, if needed. Updates src diff --git a/apps/tdspeed.c b/apps/tdspeed.c index f365e95e03..501c1d8aa9 100644 --- a/apps/tdspeed.c +++ b/apps/tdspeed.c @@ -28,6 +28,7 @@ #include "debug.h" #include "system.h" #include "tdspeed.h" +#include "settings.h" #define assert(cond) @@ -56,15 +57,18 @@ static int32_t *outbuf[2] = { NULL, NULL }; void tdspeed_init() { - /* Allocate buffers */ - if (overlap_buffer[0] == NULL) - overlap_buffer[0] = (int32_t *) buffer_alloc(FIXED_BUFSIZE * sizeof(int32_t)); - if (overlap_buffer[1] == NULL) - overlap_buffer[1] = (int32_t *) buffer_alloc(FIXED_BUFSIZE * sizeof(int32_t)); - if (outbuf[0] == NULL) - outbuf[0] = (int32_t *) buffer_alloc(TDSPEED_OUTBUFSIZE * sizeof(int32_t)); - if (outbuf[1] == NULL) - outbuf[1] = (int32_t *) buffer_alloc(TDSPEED_OUTBUFSIZE * sizeof(int32_t)); + if (global_settings.timestretch_enabled) + { + /* Allocate buffers */ + if (overlap_buffer[0] == NULL) + overlap_buffer[0] = (int32_t *) buffer_alloc(FIXED_BUFSIZE * sizeof(int32_t)); + if (overlap_buffer[1] == NULL) + overlap_buffer[1] = (int32_t *) buffer_alloc(FIXED_BUFSIZE * sizeof(int32_t)); + if (outbuf[0] == NULL) + outbuf[0] = (int32_t *) buffer_alloc(TDSPEED_OUTBUFSIZE * sizeof(int32_t)); + if (outbuf[1] == NULL) + outbuf[1] = (int32_t *) buffer_alloc(TDSPEED_OUTBUFSIZE * sizeof(int32_t)); + } } @@ -327,3 +331,4 @@ int tdspeed_doit(int32_t *src[], int count) src[1] = outbuf[1]; return count; } + -- cgit v1.2.3