Commit eaa6e6eb authored by Monty's avatar Monty
Browse files

Add an optimization case to _get_prev_page that avoids a redundant...

Add an optimization case to _get_prev_page that avoids a redundant seek/resync/reread in the common seek case.


svn path=/trunk/vorbis/; revision=15925
parent 61326658
......@@ -154,6 +154,7 @@ static ogg_int64_t _get_prev_page(OggVorbis_File *vf,ogg_page *og){
if(ret)return(ret);
while(vf->offset<end){
memset(og,0,sizeof(*og));
ret=_get_next_page(vf,og,end-vf->offset);
if(ret==OV_EREAD)return(OV_EREAD);
if(ret<0){
......@@ -164,14 +165,18 @@ static ogg_int64_t _get_prev_page(OggVorbis_File *vf,ogg_page *og){
}
}
/* we have the offset. Actually snork and hold the page now */
ret=_seek_helper(vf,offset);
if(ret)return(ret);
/* In a fully compliant, non-multiplexed stream, we'll still be
holding the last page. In multiplexed (or noncompliant streams),
we may need to re-read the last page we saw */
if(og->header_len==0){
ret=_seek_helper(vf,offset);
if(ret)return(ret);
ret=_get_next_page(vf,og,CHUNKSIZE);
if(ret<0)
/* this shouldn't be possible */
return(OV_EFAULT);
ret=_get_next_page(vf,og,CHUNKSIZE);
if(ret<0)
/* this shouldn't be possible */
return(OV_EFAULT);
}
return(offset);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment