diff options
Diffstat (limited to 'apps')
| -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 */ |