bisect=(searched+endsearched)/2;
}
- ret=_seek_helper(vf,bisect);
- if(ret)return(ret);
+ if(bisect != vf->offset){
+ ret=_seek_helper(vf,bisect);
+ if(ret)return(ret);
+ }
last=_get_next_page(vf,&og,-1);
if(last==OV_EREAD)return(OV_EREAD);
endsearched=bisect;
if(last>=0)next=last;
}else{
- searched=last+og.header_len+og.body_len;
+ searched=vf->offset;
}
}
if(pos<0 || pos>vf->end)return(OV_EINVAL);
+ /* is the seek position outside our current link [if any]? */
+ if(vf->ready_state>=STREAMSET){
+ if(pos<vf->offsets[vf->current_link] || pos>=vf->offsets[vf->current_link+1])
+ _decode_clear(vf); /* clear out stream state */
+ }
+
/* don't yet clear out decoding machine (if it's initialized), in
the case we're in the same link. Restart the decode lapping, and
let _fetch_and_process_packet deal with a potential bitstream
bisect=begin +
(ogg_int64_t)((double)(target-begintime)*(end-begin)/(endtime-begintime))
- CHUNKSIZE;
- if(bisect>begin+CHUNKSIZE){
- result=_seek_helper(vf,bisect);
- if(result) goto seek_error;
- }else{
+ if(bisect<begin+CHUNKSIZE)
bisect=begin;
- }
+ }
+
+ if(bisect!=vf->offset){
+ result=_seek_helper(vf,bisect);
+ if(result) goto seek_error;
}
while(begin<end){