Clean-up for alternate configurations.
authorTimothy B. Terriberry <tterribe@xiph.org>
Sat, 29 Sep 2012 14:17:33 +0000 (07:17 -0700)
committerTimothy B. Terriberry <tterribe@xiph.org>
Sat, 29 Sep 2012 14:17:33 +0000 (07:17 -0700)
* s/op_read_stereo_float/op_read_float_stereo/ for the fixed-point
   API.
* Fix compiler warnings exposed when optimizations are enabled.
* Fix opusfile_example to work with --enable-fixed-point
   --disable-float
* Fix seeking_example to not re-define OP_FIXED_POINT if it's
   already been defined.

examples/opusfile_example.c
examples/seeking_example.c
src/http.c
src/opusfile.c

index 1f143d4..5b3f864 100644 (file)
 #endif
 #include <opusfile.h>
 
+#if defined(OP_FIXED_POINT)
+typedef opus_int16 op_sample;
+# define op_read_native_stereo op_read_stereo
+#else
+typedef float op_sample;
+# define op_read_native_stereo op_read_float_stereo
+#endif
+
 int main(int _argc,const char **_argv){
   OggOpusFile *of;
   ogg_int64_t  pcm_offset;
@@ -85,9 +93,9 @@ int main(int _argc,const char **_argv){
   }
   for(;;){
     ogg_int64_t next_pcm_offset;
-    float       pcm[120*48*2];
+    op_sample   pcm[120*48*2];
     int         li;
-    ret=op_read_float_stereo(of,pcm,sizeof(pcm)/sizeof(*pcm));
+    ret=op_read_native_stereo(of,pcm,sizeof(pcm)/sizeof(*pcm));
     if(ret<0){
       fprintf(stderr,"Error decoding '%s': %i\n",_argv[1],ret);
       ret=EXIT_FAILURE;
index a6cfeaa..df7fc9b 100644 (file)
@@ -26,7 +26,9 @@
 #include <opusfile.h>
 
 /*Use shorts, they're smaller.*/
-#define OP_FIXED_POINT (1)
+#if !defined(OP_FIXED_POINT)
+# define OP_FIXED_POINT (1)
+#endif
 
 #if defined(OP_FIXED_POINT)
 
@@ -436,8 +438,8 @@ int main(int _argc,const char **_argv){
     fprintf(stderr,")...\n");
     max_seeks=0;
     for(i=0;i<NSEEK_TESTS;i++){
-      long nseeks_tmp;
       ogg_int64_t pcm_offset2;
+      long        nseeks_tmp;
       nseeks_tmp=nreal_seeks;
       pcm_offset=(ogg_int64_t)(rand()/(double)RAND_MAX*pcm_length);
       fprintf(stderr,"\r\t%3i [PCM position %li]...                ",
index 12892f7..07a7301 100644 (file)
@@ -258,7 +258,9 @@ static int op_parse_url_impl(OpusParsedURL *_dst,const char *_src){
     hostport=userinfo_end+1;
   }
   else{
-    user=NULL;
+    /*We shouldn't have to initialize user_end, but gcc is too dumb to figure
+       out that user!=NULL below means we didn't take this else branch.*/
+    user=user_end=NULL;
     pass=NULL;
     hostport=authority;
   }
@@ -1251,6 +1253,10 @@ static int op_http_stream_open(OpusHTTPStream *_stream,const char *_url,
   int              ret;
   if(_proxy_host!=NULL&&OP_UNLIKELY(_proxy_port>65535U))return OP_EINVAL;
   last_host=NULL;
+  /*We shouldn't have to initialize last_port, but gcc is too dumb to figure
+     out that last_host!=NULL implies we've already taken one trip through the
+     loop.*/
+  last_port=0;
   ret=op_parse_url(&_stream->url,_url);
   if(OP_UNLIKELY(ret<0))return ret;
   for(nredirs=0;nredirs<OP_REDIRECT_LIMIT;nredirs++){
index 535a5fd..1f6240a 100644 (file)
@@ -712,6 +712,11 @@ static int op_find_initial_pcm_offset(OggOpusFile *_of,
   if(_og==NULL)_og=&og;
   serialno=_of->os.serialno;
   cur_page_gp=-1;
+  op_count=0;
+  /*We shouldn't have to initialize total_duration, but gcc is too dumb to
+     figure out that op_count>0 implies we've been through the whole loop at
+     least once.*/
+  total_duration=0;
   do{
     /*We should get a page unless the file is truncated or mangled.
       Otherwise there are no audio data packets in the whole logical stream.*/
@@ -2553,6 +2558,7 @@ static int op_short2float_filter(OggOpusFile *_of,void *_dst,int _dst_sz,
  op_sample *_src,int _nsamples,int _nchannels){
   float *dst;
   int    i;
+  _of=_of;
   dst=(float *)_dst;
   if(OP_UNLIKELY(_nsamples*_nchannels>_dst_sz))_nsamples=_dst_sz/_nchannels;
   _dst_sz=_nsamples*_nchannels;
@@ -2586,7 +2592,7 @@ static int op_short2float_stereo_filter(OggOpusFile *_of,
   return op_short2float_filter(_of,dst,_dst_sz,_src,_nsamples,2);
 }
 
-int op_read_stereo_float(OggOpusFile *_of,opus_int16 *_pcm,int _buf_size){
+int op_read_float_stereo(OggOpusFile *_of,float *_pcm,int _buf_size){
   return op_read_native_filter(_of,_pcm,_buf_size,
    op_short2float_stereo_filter,NULL);
 }