summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2009-06-16 00:59:24 +0000
committerThomas Martitz <kugel@rockbox.org>2009-06-16 00:59:24 +0000
commitcb57a568e8dc9def607dc9ab27f515309bd13841 (patch)
tree45e01c7b2d8b15c6c8fbaef8139d097c95df7e92 /apps
parent3866755d28f35bdaf29147799009b1d0ac89d1d7 (diff)
downloadrockbox-cb57a568e8dc9def607dc9ab27f515309bd13841.tar.gz
rockbox-cb57a568e8dc9def607dc9ab27f515309bd13841.zip
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
Diffstat (limited to 'apps')
-rw-r--r--apps/dsp.c9
-rw-r--r--apps/tdspeed.c23
2 files changed, 18 insertions, 14 deletions
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
161 int sample_depth; 161 int sample_depth;
162 int sample_bytes; 162 int sample_bytes;
163 int stereo_mode; 163 int stereo_mode;
164 bool tdspeed_enabled; /* User has enabled timestretch */
165 int tdspeed_percent; /* Speed % */ 164 int tdspeed_percent; /* Speed % */
166 bool tdspeed_active; /* Timestretch is in use */ 165 bool tdspeed_active; /* Timestretch is in use */
167 int frac_bits; 166 int frac_bits;
@@ -266,12 +265,12 @@ void sound_set_pitch(int permille)
266 AUDIO_DSP.codec_frequency); 265 AUDIO_DSP.codec_frequency);
267} 266}
268 267
269void tdspeed_setup(struct dsp_config *dspc) 268static void tdspeed_setup(struct dsp_config *dspc)
270{ 269{
271 dspc->tdspeed_active = false; 270 dspc->tdspeed_active = false;
272 if (dspc == &AUDIO_DSP) 271 if (dspc == &AUDIO_DSP)
273 { 272 {
274 if (!dspc->tdspeed_enabled) 273 if(!dsp_timestretch_enabled())
275 return; 274 return;
276 if (dspc->tdspeed_percent == 0) 275 if (dspc->tdspeed_percent == 0)
277 dspc->tdspeed_percent = 100; 276 dspc->tdspeed_percent = 100;
@@ -304,7 +303,7 @@ void dsp_timestretch_enable(bool enable)
304 if (big_sample_buf_count < 0) 303 if (big_sample_buf_count < 0)
305 big_sample_buf_count = 0; 304 big_sample_buf_count = 0;
306 } 305 }
307 AUDIO_DSP.tdspeed_enabled = enable; 306 global_settings.timestretch_enabled = enable;
308 tdspeed_setup(&AUDIO_DSP); 307 tdspeed_setup(&AUDIO_DSP);
309} 308}
310 309
@@ -321,7 +320,7 @@ int dsp_get_timestretch()
321 320
322bool dsp_timestretch_enabled() 321bool dsp_timestretch_enabled()
323{ 322{
324 return (AUDIO_DSP.tdspeed_enabled && big_sample_buf_count > 0); 323 return (global_settings.timestretch_enabled && big_sample_buf_count > 0);
325} 324}
326 325
327/* Convert count samples to the internal format, if needed. Updates src 326/* 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 @@
28#include "debug.h" 28#include "debug.h"
29#include "system.h" 29#include "system.h"
30#include "tdspeed.h" 30#include "tdspeed.h"
31#include "settings.h"
31 32
32#define assert(cond) 33#define assert(cond)
33 34
@@ -56,15 +57,18 @@ static int32_t *outbuf[2] = { NULL, NULL };
56 57
57void tdspeed_init() 58void tdspeed_init()
58{ 59{
59 /* Allocate buffers */ 60 if (global_settings.timestretch_enabled)
60 if (overlap_buffer[0] == NULL) 61 {
61 overlap_buffer[0] = (int32_t *) buffer_alloc(FIXED_BUFSIZE * sizeof(int32_t)); 62 /* Allocate buffers */
62 if (overlap_buffer[1] == NULL) 63 if (overlap_buffer[0] == NULL)
63 overlap_buffer[1] = (int32_t *) buffer_alloc(FIXED_BUFSIZE * sizeof(int32_t)); 64 overlap_buffer[0] = (int32_t *) buffer_alloc(FIXED_BUFSIZE * sizeof(int32_t));
64 if (outbuf[0] == NULL) 65 if (overlap_buffer[1] == NULL)
65 outbuf[0] = (int32_t *) buffer_alloc(TDSPEED_OUTBUFSIZE * sizeof(int32_t)); 66 overlap_buffer[1] = (int32_t *) buffer_alloc(FIXED_BUFSIZE * sizeof(int32_t));
66 if (outbuf[1] == NULL) 67 if (outbuf[0] == NULL)
67 outbuf[1] = (int32_t *) buffer_alloc(TDSPEED_OUTBUFSIZE * sizeof(int32_t)); 68 outbuf[0] = (int32_t *) buffer_alloc(TDSPEED_OUTBUFSIZE * sizeof(int32_t));
69 if (outbuf[1] == NULL)
70 outbuf[1] = (int32_t *) buffer_alloc(TDSPEED_OUTBUFSIZE * sizeof(int32_t));
71 }
68} 72}
69 73
70 74
@@ -327,3 +331,4 @@ int tdspeed_doit(int32_t *src[], int count)
327 src[1] = outbuf[1]; 331 src[1] = outbuf[1];
328 return count; 332 return count;
329} 333}
334