Fix for FS#10492, by Aoyumi: Data abort errors when playing some Vorbis files.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22653 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Magnus Holmgren 2009-09-07 19:39:51 +00:00
parent 649b50cba1
commit f733ec194f
3 changed files with 17 additions and 25 deletions

View file

@ -164,9 +164,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->iram_pcm=(ogg_int32_t *)iram_malloc(vi->channels*ci->blocksizes[1]*sizeof(ogg_int32_t));
if(v->iram_pcm != NULL) v->iram_pcm_storage=ci->blocksizes[1];
else v->iram_pcm_storage=0;
v->first_pcm=(ogg_int32_t *)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));
}
v->centerW=0;

View file

@ -77,9 +77,8 @@ typedef struct vorbis_dsp_state{
void *backend_state;
ogg_int32_t *iram_pcm; /* IRAM PCM buffer */
ogg_int32_t *iram_double_pcm; /* IRAM PCM 2nd buffer */
int iram_pcm_storage; /* size of IRAM PCM buffer */
ogg_int32_t *first_pcm; /* PCM buffer (for normal RAM or IRAM)*/
ogg_int32_t *iram_double_pcm; /* PCM 2nd buffer for IRAM */
bool reset_pcmb;
} vorbis_dsp_state;

View file

@ -70,26 +70,17 @@ int vorbis_synthesis(vorbis_block *vb,ogg_packet *op,int decodep){
if(decodep && vi->channels<=CHANNELS){
vb->pcm = ipcm_vect;
/* alloc pcm passback storage */
/* set pcm end point */
vb->pcmend=ci->blocksizes[vb->W];
if (vd->iram_pcm_storage >= vb->pcmend) {
/* use statically allocated iram buffer */
if(vd->reset_pcmb || vb->pcm[0]==NULL)
{
/* one-time initialisation at codec start
NOT for every block synthesis start
allows us to flip between buffers once initialised
by simply flipping pointers */
for(i=0; i<vi->channels; i++)
vb->pcm[i] = &vd->iram_pcm[i*vd->iram_pcm_storage];
}
} else {
if(vd->reset_pcmb || vb->pcm[0]==NULL)
{
/* dynamic allocation (slower) */
for(i=0;i<vi->channels;i++)
vb->pcm[i]=(ogg_int32_t *)_vorbis_block_alloc(vb,vb->pcmend*sizeof(*vb->pcm[i]));
}
/* use statically allocated buffer */
if(vd->reset_pcmb || vb->pcm[0]==NULL)
{
/* one-time initialisation at codec start
NOT for every block synthesis start
allows us to flip between buffers once initialised
by simply flipping pointers */
for(i=0; i<vi->channels; i++)
vb->pcm[i] = &vd->first_pcm[i*ci->blocksizes[1]];
}
vd->reset_pcmb = false;