* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* *
- * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2014 *
+ * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2015 *
* by the Xiph.Org Foundation http://www.xiph.org/ *
* *
********************************************************************
while((result=ogg_stream_packetout(&vf->os,&op))){
if(result>0){ /* ignore holes */
long thisblock=vorbis_packet_blocksize(vi,&op);
- if(lastblock!=-1)
- accumulated+=(lastblock+thisblock)>>2;
- lastblock=thisblock;
+ if(thisblock>=0){
+ if(lastblock!=-1)
+ accumulated+=(lastblock+thisblock)>>2;
+ lastblock=thisblock;
+ }
}
}
ogg_int64_t endtime = vf->pcmlengths[link*2+1]+begintime;
ogg_int64_t target=pos-total+begintime;
ogg_int64_t best=-1;
+ int got_page=0;
ogg_page og;
+
+ /* if we have only one page, there will be no bisection. Grab the page here */
+ if(begin==end){
+ result=_seek_helper(vf,begin);
+ if(result) goto seek_error;
+
+ result=_get_next_page(vf,&og,1);
+ if(result<0) goto seek_error;
+
+ got_page=1;
+ }
+
/* bisection loop */
while(begin<end){
ogg_int64_t bisect;
}
}else{
ogg_int64_t granulepos;
+ got_page=1;
/* got a page. analyze it */
/* only consider pages from primary vorbis stream */
bisection would 'fail' because our search target was before the
first PCM granule position fencepost. */
- if(begin == vf->dataoffsets[link] &&
+ if(got_page &&
+ begin == vf->dataoffsets[link] &&
ogg_page_serialno(&og)==vf->serialnos[link]){
/* Yes, this is the beginning-of-stream case. We already have