summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/codecs/speex.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/apps/codecs/speex.c b/apps/codecs/speex.c
index c3f1fc8408..6fbc8adf64 100644
--- a/apps/codecs/speex.c
+++ b/apps/codecs/speex.c
@@ -385,6 +385,7 @@ enum codec_status codec_main(void)
385 int extra_headers = 0; 385 int extra_headers = 0;
386 int stream_init = 0; 386 int stream_init = 0;
387 int page_nb_packets, frame_size, packet_count = 0; 387 int page_nb_packets, frame_size, packet_count = 0;
388 int lookahead;
388 int headerssize = -1; 389 int headerssize = -1;
389 unsigned long strtoffset = 0; 390 unsigned long strtoffset = 0;
390 void *st = NULL; 391 void *st = NULL;
@@ -464,6 +465,7 @@ next_page:
464 &samplerate, &nframes, &channels, 465 &samplerate, &nframes, &channels,
465 stereo, &extra_headers); 466 stereo, &extra_headers);
466 467
468 speex_decoder_ctl(st, SPEEX_GET_LOOKAHEAD, &lookahead);
467 if (!nframes) 469 if (!nframes)
468 nframes=1; 470 nframes=1;
469 471
@@ -527,8 +529,13 @@ next_page:
527 speex_decode_stereo_int(output, frame_size, stereo); 529 speex_decode_stereo_int(output, frame_size, stereo);
528 530
529 if (frame_size > 0) { 531 if (frame_size > 0) {
530 ci->pcmbuf_insert(output, NULL, frame_size); 532 spx_int16_t *frame_start = output + lookahead;
531 533
534 if (channels == 2)
535 frame_start += lookahead;
536 ci->pcmbuf_insert(frame_start, NULL,
537 frame_size - lookahead);
538 lookahead = 0;
532 /* 2 bytes/sample */ 539 /* 2 bytes/sample */
533 cur_granule += frame_size / 2; 540 cur_granule += frame_size / 2;
534 541