diff options
Diffstat (limited to 'apps/dsp.c')
-rw-r--r-- | apps/dsp.c | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/apps/dsp.c b/apps/dsp.c index a68b8615f8..297a70d5a9 100644 --- a/apps/dsp.c +++ b/apps/dsp.c | |||
@@ -270,7 +270,7 @@ static void tdspeed_setup(struct dsp_config *dspc) | |||
270 | dspc->tdspeed_active = false; | 270 | dspc->tdspeed_active = false; |
271 | if (dspc == &AUDIO_DSP) | 271 | if (dspc == &AUDIO_DSP) |
272 | { | 272 | { |
273 | if(!dsp_timestretch_enabled()) | 273 | if(!dsp_timestretch_available()) |
274 | return; | 274 | return; |
275 | if (dspc->tdspeed_percent == 0) | 275 | if (dspc->tdspeed_percent == 0) |
276 | dspc->tdspeed_percent = 100; | 276 | dspc->tdspeed_percent = 100; |
@@ -285,26 +285,25 @@ static void tdspeed_setup(struct dsp_config *dspc) | |||
285 | } | 285 | } |
286 | } | 286 | } |
287 | 287 | ||
288 | void dsp_timestretch_enable(bool enable) | 288 | void dsp_timestretch_enable(bool enabled) |
289 | { | 289 | { |
290 | if (enable) | 290 | /* Hook to set up timestretch buffer on first call to settings_apply() */ |
291 | if (big_sample_buf_count < 0) /* Only do something on first call */ | ||
291 | { | 292 | { |
292 | /* Set up timestretch buffers on first enable */ | 293 | if (enabled) |
293 | if (big_sample_buf_count < 0) | ||
294 | { | 294 | { |
295 | /* Set up timestretch buffers */ | ||
295 | big_sample_buf_count = SMALL_SAMPLE_BUF_COUNT * RESAMPLE_RATIO; | 296 | big_sample_buf_count = SMALL_SAMPLE_BUF_COUNT * RESAMPLE_RATIO; |
296 | big_sample_buf = small_resample_buf; | 297 | big_sample_buf = small_resample_buf; |
297 | big_resample_buf = (int32_t *) buffer_alloc(big_sample_buf_count * RESAMPLE_RATIO * sizeof(int32_t)); | 298 | big_resample_buf = (int32_t *) buffer_alloc(big_sample_buf_count * RESAMPLE_RATIO * sizeof(int32_t)); |
298 | } | 299 | } |
299 | } | 300 | else |
300 | else | 301 | { |
301 | { | 302 | /* Not enabled at startup, "big" buffers will never be available */ |
302 | /* If not enabled at startup, buffers will never be available */ | ||
303 | if (big_sample_buf_count < 0) | ||
304 | big_sample_buf_count = 0; | 303 | big_sample_buf_count = 0; |
304 | } | ||
305 | tdspeed_setup(&AUDIO_DSP); | ||
305 | } | 306 | } |
306 | global_settings.timestretch_enabled = enable; | ||
307 | tdspeed_setup(&AUDIO_DSP); | ||
308 | } | 307 | } |
309 | 308 | ||
310 | void dsp_set_timestretch(int percent) | 309 | void dsp_set_timestretch(int percent) |
@@ -318,7 +317,7 @@ int dsp_get_timestretch() | |||
318 | return AUDIO_DSP.tdspeed_percent; | 317 | return AUDIO_DSP.tdspeed_percent; |
319 | } | 318 | } |
320 | 319 | ||
321 | bool dsp_timestretch_enabled() | 320 | bool dsp_timestretch_available() |
322 | { | 321 | { |
323 | return (global_settings.timestretch_enabled && big_sample_buf_count > 0); | 322 | return (global_settings.timestretch_enabled && big_sample_buf_count > 0); |
324 | } | 323 | } |