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
This commit is contained in:
Nils Wallménius 2010-08-12 07:50:29 +00:00
parent 5602342613
commit 13d0eca71d

View file

@ -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 */