summaryrefslogtreecommitdiff
path: root/apps/plugins/test_codec.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/test_codec.c')
-rw-r--r--apps/plugins/test_codec.c51
1 files changed, 24 insertions, 27 deletions
diff --git a/apps/plugins/test_codec.c b/apps/plugins/test_codec.c
index dafcf35710..920be54d56 100644
--- a/apps/plugins/test_codec.c
+++ b/apps/plugins/test_codec.c
@@ -164,6 +164,7 @@ static inline void int2le16(unsigned char* buf, int16_t x)
164 164
165static unsigned char *wavbuffer; 165static unsigned char *wavbuffer;
166static unsigned char *dspbuffer; 166static unsigned char *dspbuffer;
167static int dspbuffer_count;
167 168
168void init_wav(char* filename) 169void init_wav(char* filename)
169{ 170{
@@ -215,34 +216,31 @@ static void* codec_get_buffer(size_t *size)
215 216
216static int process_dsp(const void *ch1, const void *ch2, int count) 217static int process_dsp(const void *ch1, const void *ch2, int count)
217{ 218{
218 const char *src[2] = { ch1, ch2 }; 219 struct dsp_buffer src;
219 int written_count = 0; 220 src.remcount = count;
220 char *dest = dspbuffer; 221 src.pin[0] = ch1;
221 222 src.pin[1] = ch2;
222 while (count > 0) 223 src.proc_mask = 0;
224
225 struct dsp_buffer dst;
226 dst.remcount = 0;
227 dst.p16out = (int16_t *)dspbuffer;
228 dst.bufcount = dspbuffer_count;
229
230 while (1)
223 { 231 {
224 int out_count = rb->dsp_output_count(ci.dsp, count); 232 int old_remcount = dst.remcount;
225 233 rb->dsp_process(ci.dsp, &src, &dst);
226 int inp_count = rb->dsp_input_count(ci.dsp, out_count);
227
228 if (inp_count <= 0)
229 break;
230
231 if (inp_count > count)
232 inp_count = count;
233
234 out_count = rb->dsp_process(ci.dsp, dest, src, inp_count);
235 234
236 if (out_count <= 0) 235 if (dst.bufcount <= 0 ||
236 (src.remcount <= 0 && dst.remcount <= old_remcount))
237 {
238 /* Dest is full or no input left and DSP purged */
237 break; 239 break;
238 240 }
239 written_count += out_count;
240 dest += out_count * 4;
241
242 count -= inp_count;
243 } 241 }
244 242
245 return written_count; 243 return dst.remcount;
246} 244}
247 245
248/* Null output */ 246/* Null output */
@@ -502,7 +500,6 @@ static void configure(int setting, intptr_t value)
502 rb->dsp_configure(ci.dsp, setting, value); 500 rb->dsp_configure(ci.dsp, setting, value);
503 switch(setting) 501 switch(setting)
504 { 502 {
505 case DSP_SWITCH_FREQUENCY:
506 case DSP_SET_FREQUENCY: 503 case DSP_SET_FREQUENCY:
507 DEBUGF("samplerate=%d\n",(int)value); 504 DEBUGF("samplerate=%d\n",(int)value);
508 wavinfo.samplerate = use_dsp ? NATIVE_FREQUENCY : (int)value; 505 wavinfo.samplerate = use_dsp ? NATIVE_FREQUENCY : (int)value;
@@ -525,9 +522,7 @@ static void init_ci(void)
525{ 522{
526 /* --- Our "fake" implementations of the codec API functions. --- */ 523 /* --- Our "fake" implementations of the codec API functions. --- */
527 524
528 ci.dsp = (struct dsp_config *)rb->dsp_configure(NULL, DSP_MYDSP, 525 ci.dsp = rb->dsp_get_config(CODEC_IDX_AUDIO);
529 CODEC_IDX_AUDIO);
530
531 ci.codec_get_buffer = codec_get_buffer; 526 ci.codec_get_buffer = codec_get_buffer;
532 527
533 if (wavinfo.fd >= 0 || checksum) { 528 if (wavinfo.fd >= 0 || checksum) {
@@ -849,6 +844,8 @@ enum plugin_status plugin_start(const void* parameter)
849 844
850 wavbuffer = rb->plugin_get_buffer(&buffer_size); 845 wavbuffer = rb->plugin_get_buffer(&buffer_size);
851 dspbuffer = wavbuffer + buffer_size / 2; 846 dspbuffer = wavbuffer + buffer_size / 2;
847 dspbuffer_count = (buffer_size - (dspbuffer - wavbuffer)) /
848 (2 * sizeof (int16_t));
852 849
853 codec_mallocbuf = rb->plugin_get_audio_buffer(&audiosize); 850 codec_mallocbuf = rb->plugin_get_audio_buffer(&audiosize);
854 /* Align codec_mallocbuf to pointer size, tlsf wants that */ 851 /* Align codec_mallocbuf to pointer size, tlsf wants that */