diff options
Diffstat (limited to 'apps/dsp.c')
-rw-r--r-- | apps/dsp.c | 60 |
1 files changed, 40 insertions, 20 deletions
diff --git a/apps/dsp.c b/apps/dsp.c index a728dd75ea..167c043427 100644 --- a/apps/dsp.c +++ b/apps/dsp.c | |||
@@ -318,30 +318,50 @@ static void tdspeed_setup(struct dsp_config *dspc) | |||
318 | resample_buf = big_resample_buf; | 318 | resample_buf = big_resample_buf; |
319 | } | 319 | } |
320 | 320 | ||
321 | |||
322 | static int move_callback(int handle, void* current, void* new) | ||
323 | { | ||
324 | /* TODO */ | ||
325 | (void)handle;(void)current;; | ||
326 | big_sample_buf = new; | ||
327 | return BUFLIB_CB_OK; | ||
328 | } | ||
329 | |||
330 | static struct buflib_callbacks ops = { | ||
331 | .move_callback = move_callback, | ||
332 | .shrink_callback = NULL, | ||
333 | }; | ||
334 | |||
335 | |||
321 | void dsp_timestretch_enable(bool enabled) | 336 | void dsp_timestretch_enable(bool enabled) |
322 | { | 337 | { |
323 | /* Hook to set up timestretch buffer on first call to settings_apply() */ | 338 | /* Hook to set up timestretch buffer on first call to settings_apply() */ |
324 | if (big_sample_buf_count < 0) /* Only do something on first call */ | 339 | static int handle; |
340 | if (enabled) | ||
325 | { | 341 | { |
326 | if (enabled) | 342 | if (big_sample_buf_count > 0) |
327 | { | 343 | return; /* already allocated and enabled */ |
328 | int handle; | 344 | /* Set up timestretch buffers */ |
329 | /* Set up timestretch buffers */ | 345 | big_sample_buf_count = SMALL_SAMPLE_BUF_COUNT * RESAMPLE_RATIO; |
330 | big_sample_buf_count = SMALL_SAMPLE_BUF_COUNT * RESAMPLE_RATIO; | 346 | big_sample_buf = small_resample_buf; |
331 | big_sample_buf = small_resample_buf; | 347 | handle = core_alloc_ex("resample buf", |
332 | handle = core_alloc("resample buf", | 348 | big_sample_buf_count * RESAMPLE_RATIO * sizeof(int32_t), &ops); |
333 | big_sample_buf_count * RESAMPLE_RATIO * sizeof(int32_t)); | 349 | if (handle > 0) |
334 | if (handle > 0) | 350 | { /* success, now setup tdspeed */ |
335 | big_resample_buf = core_get_data(handle); | 351 | big_resample_buf = core_get_data(handle); |
336 | else | 352 | tdspeed_init(); |
337 | big_sample_buf_count = 0; | 353 | tdspeed_setup(&AUDIO_DSP); |
338 | } | 354 | } |
339 | else | 355 | } |
340 | { | 356 | if (!enabled || (handle <= 0)) /* disable */ |
341 | /* Not enabled at startup, "big" buffers will never be available */ | 357 | { |
342 | big_sample_buf_count = 0; | 358 | dsp_set_timestretch(PITCH_SPEED_100); |
343 | } | 359 | tdspeed_finish(); |
344 | tdspeed_setup(&AUDIO_DSP); | 360 | if (handle > 0) |
361 | core_free(handle); | ||
362 | handle = 0; | ||
363 | big_sample_buf = NULL; | ||
364 | big_sample_buf_count = 0; | ||
345 | } | 365 | } |
346 | } | 366 | } |
347 | 367 | ||
@@ -1211,7 +1231,7 @@ int dsp_callback(int msg, intptr_t param) | |||
1211 | */ | 1231 | */ |
1212 | int dsp_process(struct dsp_config *dsp, char *dst, const char *src[], int count) | 1232 | int dsp_process(struct dsp_config *dsp, char *dst, const char *src[], int count) |
1213 | { | 1233 | { |
1214 | int32_t *tmp[2]; | 1234 | static int32_t *tmp[2]; /* tdspeed_doit() needs it static */ |
1215 | static long last_yield; | 1235 | static long last_yield; |
1216 | long tick; | 1236 | long tick; |
1217 | int written = 0; | 1237 | int written = 0; |