summaryrefslogtreecommitdiff
path: root/apps/codecs/speex.c
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2011-03-02 03:47:42 +0000
committerMichael Sevakis <jethead71@rockbox.org>2011-03-02 03:47:42 +0000
commitb3bfc09852007fed60bf71451a6c71df8c28b3ed (patch)
tree1675ed55887fbe699ca16405ab95da4e6bcf3dde /apps/codecs/speex.c
parent6170ded83d342b52f0bb1237a705f3f98e99695a (diff)
downloadrockbox-b3bfc09852007fed60bf71451a6c71df8c28b3ed.tar.gz
rockbox-b3bfc09852007fed60bf71451a6c71df8c28b3ed.zip
r29348 changes can cause certain codecs to jump to code on early track change that assumes initializations have been done. Make sure that track change cleanups are only called if the state is sane to do so. Stops my vorbis data abort issue. Correctness for speex is a guess based on the library calls' source. It appears only speex/vorbis should have been bothered by said revision.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29489 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/codecs/speex.c')
-rw-r--r--apps/codecs/speex.c12
1 files changed, 8 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);