diff options
| author | Nils Wallménius <nils@rockbox.org> | 2010-08-12 07:50:29 +0000 |
|---|---|---|
| committer | Nils Wallménius <nils@rockbox.org> | 2010-08-12 07:50:29 +0000 |
| commit | 13d0eca71dcd4ff50aca91d68f6c2cf7510d791b (patch) | |
| tree | 86af574ada927be9074cf72df45ffb7ab3dc3b7b | |
| parent | 56023426130d4b5fb932abc421dd8b6778d817c0 (diff) | |
| download | rockbox-13d0eca71dcd4ff50aca91d68f6c2cf7510d791b.zip rockbox-13d0eca71dcd4ff50aca91d68f6c2cf7510d791b.tar.gz rockbox-13d0eca71dcd4ff50aca91d68f6c2cf7510d791b.tar.bz2 rockbox-13d0eca71dcd4ff50aca91d68f6c2cf7510d791b.tar.xz | |
libtremor: fix possible memoryleak when playing several ogg vorbis files in sequence, hopefully fixes FS#11533
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27776 a1c6a512-1295-4272-9138-f99709370657
| -rw-r--r-- | apps/codecs/libtremor/block.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/apps/codecs/libtremor/block.c b/apps/codecs/libtremor/block.c index b4ca8f3..abf2166 100644 --- a/apps/codecs/libtremor/block.c +++ b/apps/codecs/libtremor/block.c @@ -40,6 +40,8 @@ static int ilog(unsigned int v){ static ogg_int32_t* _pcmp [CHANNELS] IBSS_ATTR; static ogg_int32_t* _pcmbp[CHANNELS] IBSS_ATTR; static ogg_int32_t* _pcmret[CHANNELS] IBSS_ATTR; +/* save original pointer returned by malloc so we can free it easily */ +static ogg_int32_t* _first_pcm = NULL; /* pcm accumulator examples (not exhaustive): @@ -165,10 +167,11 @@ static int _vds_init(vorbis_dsp_state *v,vorbis_info *vi){ /* allocate IRAM buffer for the PCM data generated by synthesis */ iram_malloc_init(); - v->first_pcm=(ogg_int32_t *)iram_malloc(vi->channels*ci->blocksizes[1]*sizeof(ogg_int32_t)); + v->first_pcm = iram_malloc(vi->channels*ci->blocksizes[1]*sizeof(ogg_int32_t)); /* when can't allocate IRAM buffer, allocate normal RAM buffer */ if(v->first_pcm == NULL){ - v->first_pcm=(ogg_int32_t *)_ogg_malloc(vi->channels*ci->blocksizes[1]*sizeof(ogg_int32_t)); + _first_pcm = _ogg_malloc(vi->channels*ci->blocksizes[1]*sizeof(ogg_int32_t)); + v->first_pcm= _first_pcm; } v->centerW=0; @@ -287,6 +290,9 @@ void vorbis_dsp_clear(vorbis_dsp_state *v){ codec_setup_info *ci=(codec_setup_info *)(vi?vi->codec_setup:NULL); private_state *b=(private_state *)v->backend_state; + if(_first_pcm != NULL) + _ogg_free(_first_pcm); + if(NULL == v->iram_double_pcm && vi != NULL) { /* pcm buffer came from oggmalloc rather than iram */ |