summaryrefslogtreecommitdiffstats
path: root/lib/rbcodec/codecs/opus.c
diff options
context:
space:
mode:
authorNils Wallménius <nils@rockbox.org>2013-05-18 19:48:08 +0200
committerNils Wallménius <nils@rockbox.org>2013-05-18 23:38:23 +0200
commitc7124b552044ef92a128481d32df081d1210cbe1 (patch)
tree4e596edb09396ef96ab93d064fddcae179d51ef7 /lib/rbcodec/codecs/opus.c
parentfc0cf8d91b1710d7843981d56ef2ac9a6dfeb294 (diff)
downloadrockbox-c7124b552044ef92a128481d32df081d1210cbe1.tar.gz
rockbox-c7124b552044ef92a128481d32df081d1210cbe1.tar.bz2
rockbox-c7124b552044ef92a128481d32df081d1210cbe1.zip
Fix opus craches with large embedded album art
Use the tlsf malloc and friends instead of the silly codec_malloc to get actually working free and saner realloc that doesn't leak memory. Makes files with moderately sized embedded AA play on targets with large enough codec buffers and files with too large AA are now skipped rather than crashing. Fixes crash when playing example file in FS#12842. Change-Id: I06562955c4d9a95bd90f55738214fba462092b71
Diffstat (limited to 'lib/rbcodec/codecs/opus.c')
-rw-r--r--lib/rbcodec/codecs/opus.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/lib/rbcodec/codecs/opus.c b/lib/rbcodec/codecs/opus.c
index 3eb316de68..d72b9cc708 100644
--- a/lib/rbcodec/codecs/opus.c
+++ b/lib/rbcodec/codecs/opus.c
@@ -329,10 +329,8 @@ enum codec_status codec_run(void)
int64_t seek_target;
uint64_t granule_pos;
- /* reset our simple malloc */
- if (codec_init()) {
- goto done;
- }
+ ogg_malloc_init();
+
global_stack = 0;
#if defined(CPU_COLDFIRE)
@@ -344,10 +342,10 @@ enum codec_status codec_run(void)
/* pre-init the ogg_sync_state buffer, so it won't need many reallocs */
ogg_sync_init(&oy);
oy.storage = 64*1024;
- oy.data = codec_malloc(oy.storage);
+ oy.data = _ogg_malloc(oy.storage);
/* allocate output buffer */
- uint16_t *output = (uint16_t*) codec_malloc(MAX_FRAME_SIZE*sizeof(uint16_t));
+ uint16_t *output = (uint16_t*) _ogg_malloc(MAX_FRAME_SIZE*sizeof(uint16_t));
ci->seek_buffer(0);
ci->set_elapsed(0);
@@ -465,6 +463,7 @@ enum codec_status codec_run(void)
LOGF("Returned OK");
error = CODEC_OK;
done:
+ ogg_malloc_destroy();
return error;
}