summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/codecs/speex.c12
-rw-r--r--apps/codecs/vorbis.c4
2 files changed, 12 insertions, 4 deletions
diff --git a/apps/codecs/speex.c b/apps/codecs/speex.c
index e38a04495c..7a1efa9753 100644
--- a/apps/codecs/speex.c
+++ b/apps/codecs/speex.c
@@ -393,6 +393,9 @@ enum codec_status codec_main(void)
393 void *st = NULL; 393 void *st = NULL;
394 int j = 0; 394 int j = 0;
395 395
396 memset(&bits, 0, sizeof(bits));
397 memset(&oy, 0, sizeof(oy));
398
396 /* Ogg handling still uses mallocs, so reset the malloc buffer per track */ 399 /* Ogg handling still uses mallocs, so reset the malloc buffer per track */
397next_track: 400next_track:
398 error = CODEC_OK; 401 error = CODEC_OK;
@@ -401,16 +404,16 @@ next_track:
401 error = CODEC_ERROR; 404 error = CODEC_ERROR;
402 goto exit; 405 goto exit;
403 } 406 }
407
404 stereo = speex_stereo_state_init(); 408 stereo = speex_stereo_state_init();
409 spx_ogg_sync_init(&oy);
410 spx_ogg_alloc_buffer(&oy,2*CHUNKSIZE);
405 411
406 if (codec_wait_taginfo() != 0) 412 if (codec_wait_taginfo() != 0)
407 goto done; 413 goto done;
408 414
409 strtoffset = ci->id3->offset; 415 strtoffset = ci->id3->offset;
410 416
411 spx_ogg_sync_init(&oy);
412 spx_ogg_alloc_buffer(&oy,2*CHUNKSIZE);
413
414 samplerate = ci->id3->frequency; 417 samplerate = ci->id3->frequency;
415 codec_set_replaygain(ci->id3); 418 codec_set_replaygain(ci->id3);
416 419
@@ -558,7 +561,8 @@ done:
558 561
559 /* Clean things up for the next track */ 562 /* Clean things up for the next track */
560 563
561 speex_decoder_destroy(st); 564 if (st)
565 speex_decoder_destroy(st);
562 566
563 if (stream_init == 1) 567 if (stream_init == 1)
564 spx_ogg_stream_reset(&os); 568 spx_ogg_stream_reset(&os);
diff --git a/apps/codecs/vorbis.c b/apps/codecs/vorbis.c
index 17cc4a03f9..0a36a37c8b 100644
--- a/apps/codecs/vorbis.c
+++ b/apps/codecs/vorbis.c
@@ -110,6 +110,7 @@ enum codec_status codec_main(void)
110 OggVorbis_File vf; 110 OggVorbis_File vf;
111 ogg_int32_t **pcm; 111 ogg_int32_t **pcm;
112 112
113 bool initialized = false; /* First init done? */
113 int error; 114 int error;
114 long n; 115 long n;
115 int current_section; 116 int current_section;
@@ -185,6 +186,7 @@ next_track:
185 vf.end = ci->id3->filesize; 186 vf.end = ci->id3->filesize;
186 vf.ready_state = OPENED; 187 vf.ready_state = OPENED;
187 vf.links = 1; 188 vf.links = 1;
189 initialized = true;
188 } else { 190 } else {
189 DEBUGF("Vorbis: ov_open failed: %d\n", error); 191 DEBUGF("Vorbis: ov_open failed: %d\n", error);
190 error = CODEC_ERROR; 192 error = CODEC_ERROR;
@@ -248,6 +250,8 @@ done:
248 ogg_malloc_destroy(); 250 ogg_malloc_destroy();
249 251
250 if (ci->request_next_track()) { 252 if (ci->request_next_track()) {
253 if (!initialized)
254 goto next_track;
251 /* Clean things up for the next track */ 255 /* Clean things up for the next track */
252 vf.dataoffsets = NULL; 256 vf.dataoffsets = NULL;
253 vf.offsets = NULL; 257 vf.offsets = NULL;