ref: 6c56a9739723335b82eff400fbd90770a69602d2
parent: 737cbf573b16b7f4aa0dc9ab8ff7680139e34af0
author: Timothy B. Terriberry <tterribe@xiph.org>
date: Mon Oct 1 04:41:36 EDT 2012
Multiple small fixes. * Tags were being freed even if not initialized if op_fetch_headers() failed on the first link. The logic for handling completely empty links would leak, also. * Ignore fragment identifiers in http URLs instead of rejecting them. * Get the current link in seeking_example's verify_seek when op_read_native() fails to return it for us.
--- a/examples/seeking_example.c
+++ b/examples/seeking_example.c
@@ -158,6 +158,7 @@
if(nsamples<0){
fprintf(stderr,"\nFailed to read PCM data after seek: %i\n",nsamples);
nfailures++;
+ li=op_current_link(_of);
}
for(lj=0;lj<li;lj++){
duration=op_pcm_total(_of,lj);
--- a/src/http.c
+++ b/src/http.c
@@ -232,7 +232,6 @@
const char *port_end;
const char *path;
const char *path_end;
- const char *fragment_end;
const char *uri_end;
scheme_end=_src+strspn(_src,OP_URL_SCHEME);
if(OP_UNLIKELY(*scheme_end!=':')
@@ -307,12 +306,10 @@
This doesn't get sent to the server.
Some day we should add support for Media Fragment URIs
<http://www.w3.org/TR/media-frags/>.*/
- if(*path_end=='#'){
- uri_end=fragment_end=path_end+1+strspn(path_end+1,OP_URL_QUERY_FRAG);
- }
+ if(*path_end=='#')uri_end=path_end+1+strspn(path_end+1,OP_URL_QUERY_FRAG);
else uri_end=path_end;
/*If there's anything left, this was not a valid URL.*/
- if(OP_UNLIKELY(*path_end!='\0'))return OP_EINVAL;
+ if(OP_UNLIKELY(*uri_end!='\0'))return OP_EINVAL;
_dst->scheme=op_string_range_dup(_src,scheme_end);
if(OP_UNLIKELY(_dst->scheme==NULL))return OP_EFAULT;
op_string_tolower(_dst->scheme);
--- a/src/opusfile.c
+++ b/src/opusfile.c
@@ -1353,7 +1353,6 @@
_of->seekable=seekable;
/*Don't seek yet.
Set up a 'single' (current) logical bitstream entry for partial open.*/
- _of->nlinks=1;
_of->links=(OggOpusLink *)_ogg_malloc(sizeof(*_of->links));
/*The serialno gets filled in later by op_fetch_headers().*/
ogg_stream_init(&_of->os,-1);
@@ -1364,6 +1363,7 @@
ret=op_fetch_headers(_of,&_of->links[0].head,&_of->links[0].tags,
&_of->serialnos,&_of->nserialnos,&_of->cserialnos,pog);
if(OP_UNLIKELY(ret<0))break;
+ _of->nlinks=1;
_of->links[0].offset=0;
_of->links[0].data_offset=_of->offset;
_of->links[0].pcm_end=-1;
@@ -1374,8 +1374,10 @@
/*This link was empty, but we already have the BOS page for the next one in
og.
We can't seek, so start processing the next link right now.*/
+ opus_tags_clear(&_of->links[0].tags);
+ _of->nlinks=0;
+ if(!seekable)_of->cur_link++;
pog=&og;
- _of->cur_link++;
}
if(OP_UNLIKELY(ret<0)){
/*Don't auto-close the stream on failure.*/