summaryrefslogtreecommitdiff
path: root/apps/codecs/speex.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/codecs/speex.c')
-rw-r--r--apps/codecs/speex.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/apps/codecs/speex.c b/apps/codecs/speex.c
index 7edda4b6db..2cd547a84d 100644
--- a/apps/codecs/speex.c
+++ b/apps/codecs/speex.c
@@ -26,7 +26,8 @@
26#include "libspeex/speex/speex_config_types.h" 26#include "libspeex/speex/speex_config_types.h"
27#include "codeclib.h" 27#include "codeclib.h"
28 28
29#define MAX_FRAME_SIZE 2000 29// Room for one stereo frame of max size, 2*640
30#define MAX_FRAME_SIZE 1280
30#define CHUNKSIZE 10000 /*2kb*/ 31#define CHUNKSIZE 10000 /*2kb*/
31#define SEEK_CHUNKSIZE 7*CHUNKSIZE 32#define SEEK_CHUNKSIZE 7*CHUNKSIZE
32 33
@@ -346,7 +347,7 @@ static void *process_header(spx_ogg_packet *op,
346 speex_decoder_ctl(st, SPEEX_SET_ENH, &enh_enabled); 347 speex_decoder_ctl(st, SPEEX_SET_ENH, &enh_enabled);
347 speex_decoder_ctl(st, SPEEX_GET_FRAME_SIZE, frame_size); 348 speex_decoder_ctl(st, SPEEX_GET_FRAME_SIZE, frame_size);
348 349
349 if (!(*channels==1)){ 350 if (*channels!=1){
350 callback.callback_id = SPEEX_INBAND_STEREO; 351 callback.callback_id = SPEEX_INBAND_STEREO;
351 callback.func = speex_std_stereo_request_handler; 352 callback.func = speex_std_stereo_request_handler;
352 callback.data = stereo; 353 callback.data = stereo;
@@ -381,7 +382,8 @@ enum codec_status codec_main(void)
381 int enh_enabled = 1; 382 int enh_enabled = 1;
382 int nframes = 2; 383 int nframes = 2;
383 int eos = 0; 384 int eos = 0;
384 SpeexStereoState stereo = SPEEX_STEREO_STATE_INIT; 385 static const SpeexStereoState stereo_init = SPEEX_STEREO_STATE_INIT;
386 SpeexStereoState stereo = stereo_init;
385 int channels = -1; 387 int channels = -1;
386 int rate = 0, samplerate = 0; 388 int rate = 0, samplerate = 0;
387 int extra_headers = 0; 389 int extra_headers = 0;
@@ -531,13 +533,11 @@ next_page:
531 if (channels == 2) 533 if (channels == 2)
532 speex_decode_stereo_int(output, frame_size, &stereo); 534 speex_decode_stereo_int(output, frame_size, &stereo);
533 535
534 int new_frame_size = frame_size; 536 if (frame_size > 0) {
535 537 ci->pcmbuf_insert(output, NULL, frame_size);
536 if (new_frame_size > 0) {
537 ci->pcmbuf_insert(output, NULL, new_frame_size);
538 538
539 /* 2 bytes/sample */ 539 /* 2 bytes/sample */
540 cur_granule += new_frame_size / 2; 540 cur_granule += frame_size / 2;
541 541
542 ci->set_offset((long) ci->curpos); 542 ci->set_offset((long) ci->curpos);
543 543
@@ -566,9 +566,7 @@ done:
566 cur_granule = stream_init = rate = samplerate = headerssize 566 cur_granule = stream_init = rate = samplerate = headerssize
567 = packet_count = eos = 0; 567 = packet_count = eos = 0;
568 568
569 stereo.balance = stereo.smooth_left = stereo.smooth_right = 1; 569 stereo = stereo_init;
570 stereo.e_ratio = .5;
571 stereo.reserved1 = stereo.reserved2 = 0;
572 570
573 goto next_track; 571 goto next_track;
574 } 572 }