********************************************************************
function: stdio-based convenience library for opening/seeking/decoding
- last mod: $Id: vorbisfile.c,v 1.48 2001/06/02 11:38:14 msmith Exp $
+ last mod: $Id: vorbisfile.c,v 1.49 2001/09/13 02:17:51 xiphmont Exp $
********************************************************************/
i++;
}
if(i<3)
- if(_get_next_page(vf,og_ptr,1)<0){
+ if(_get_next_page(vf,og_ptr,CHUNKSIZE)<0){
ret=OV_EBADHEADER;
goto bail_header;
}
vorbis_info_clear(vi);
vorbis_comment_clear(vc);
ogg_stream_clear(&vf->os);
+ vf->ready_state=OPENED;
+
return ret;
}
}
}
- if(vf->ready_state>=STREAMSET){
+ if(vf->ready_state>=OPENED){
if(!readp)return(0);
if(_get_next_page(vf,&og,-1)<0)return(OV_EOF); /* eof.
leave unitialized */
-
/* bitrate tracking; add the header's bytes here, the body bytes
are done by packet above */
vf->bittrack+=og.header_len*8;
/* we're streaming */
/* fetch the three header packets, build the info struct */
- _fetch_headers(vf,vf->vi,vf->vc,&vf->current_serialno,&og);
+ int ret=_fetch_headers(vf,vf->vi,vf->vc,&vf->current_serialno,&og);
+ if(ret)return(ret);
vf->current_link++;
link=0;
}
int host_endian = host_is_big_endian();
if(vf->ready_state<OPENED)return(OV_EINVAL);
- if(vf->ready_state==OPENED)return(OV_EOF); /* stream is always
- initialized after
- other calls (after
- open)... unless there
- was no page at the end
- to initialize state
- with. */
while(1){
if(vf->ready_state>=STREAMSET){
}
/* suck in another packet */
- switch(_process_packet(vf,1)){
- case 0:case OV_EOF:
- return(0);
- case OV_HOLE:
- return(OV_HOLE);
- case OV_EBADLINK:
- return(OV_EBADLINK);
+ {
+ int ret=_process_packet(vf,1);
+ if(ret==OV_EOF)return(0);
+ if(ret<=0)return(ret);
}
+
}
}