shithub: sox

Download patch

ref: b484181a5d447afd85535513f0b0ba5dae25a8a4
parent: a94ba4b564483866ad151cd6c9496603f191c2c9
author: robs <robs>
date: Wed Jul 4 15:27:00 EDT 2007

Fix a few small errors

--- a/src/alsa.c
+++ b/src/alsa.c
@@ -36,12 +36,12 @@
     {
         if (ft->signal.size == SOX_SIZE_16BIT)
         {
-            sox_report("driver only supports signed and unsigned samples.  Changing to signed.");
+            sox_report("driver supports only signed and unsigned samples.  Changing to signed.");
             ft->signal.encoding = SOX_ENCODING_SIGN2;
         }
         else
         {
-            sox_report("driver only supports signed and unsigned samples.  Changing to unsigned.");
+            sox_report("driver supports only signed and unsigned samples.  Changing to unsigned.");
             ft->signal.encoding = SOX_ENCODING_UNSIGNED;
         }
     }
@@ -257,7 +257,7 @@
     rate = range_limit(ft->signal.rate, min_rate, max_rate);
     if (rate != ft->signal.rate)
     {
-        sox_report("hardware does not support sample rate %i; changing to %i.", ft->signal.rate, rate);
+        sox_report("hardware does not support sample rate %g; changing to %i.", ft->signal.rate, rate);
         ft->signal.rate = rate;
     }
     dir = 0;
@@ -275,7 +275,7 @@
  
     if (rate != ft->signal.rate)
     {
-        sox_report("Could not set exact rate of %d.  Approximating with %d",
+        sox_report("Could not set exact rate of %g.  Approximating with %i",
                 ft->signal.rate, rate);
     }
 
--- a/src/au.c
+++ b/src/au.c
@@ -102,7 +102,7 @@
             *size = SOX_SIZE_32BIT;
             break;
     default:
-            sox_debug("encoding: 0x%lx", encoding);
+            sox_debug("encoding: 0x%lx", *encoding);
             return(SOX_EOF);
     }
     return(SOX_SUCCESS);
--- a/src/cvsd.c
+++ b/src/cvsd.c
@@ -490,11 +490,11 @@
             return rc;
         }
 
-        sox_debug("DVMS header of source file \"%s\":");
-        sox_debug("  filename  \"%.14s\"",ft->filename);
-        sox_debug("  id        0x%x", hdr.Filename);
-        sox_debug("  state     0x%x", hdr.Id, hdr.State);
-        sox_debug("  time      %s",ctime(&hdr.Unixtime)); /* ctime generates lf */
+        sox_debug("DVMS header of source file \"%s\":", ft->filename);
+        sox_debug("  filename  \"%.14s\"", hdr.Filename);
+        sox_debug("  id        0x%x", hdr.Id);
+        sox_debug("  state     0x%x", hdr.State);
+        sox_debug("  time      %s", ctime(&hdr.Unixtime)); /* ctime generates lf */
         sox_debug("  usender   %u", hdr.Usender);
         sox_debug("  ureceiver %u", hdr.Ureceiver);
         sox_debug("  length    %u", hdr.Length);
@@ -504,7 +504,7 @@
         sox_debug("  custom2   %u", hdr.Custom2);
         sox_debug("  info      \"%.16s\"", hdr.Info);
         ft->signal.rate = (hdr.Srate < 240) ? 16000 : 32000;
-        sox_debug("DVMS rate %dbit/s using %dbit/s deviation %d%%", 
+        sox_debug("DVMS rate %dbit/s using %gbit/s deviation %g%%", 
                hdr.Srate*100, ft->signal.rate, 
                ((ft->signal.rate - hdr.Srate*100) * 100) / ft->signal.rate);
         rc = sox_cvsdstartread(ft);
--- a/src/filter.c
+++ b/src/filter.c
@@ -108,7 +108,7 @@
 
         if ((f->freq0 < 0) || (f->freq0 > f->freq1))
         {
-                sox_fail("filter: low(%d),high(%d) parameters must satisfy 0 <= low <= high <= %d",
+                sox_fail("filter: low(%d),high(%d) parameters must satisfy 0 <= low <= high <= %g",
                                         f->freq0, f->freq1, f->rate/2);
                 return (SOX_EOF);
         }
--- a/src/formats.c
+++ b/src/formats.c
@@ -8,6 +8,7 @@
  */
 
 #include "sox_i.h"
+#include <string.h>
 
 /* File format handlers. */
 
@@ -31,7 +32,7 @@
 /* Find a named format in the formats library */
 sox_format_handler_t const * sox_find_format(char const * name, sox_bool no_dev)
 {
-  int f, n;
+  sox_size_t f, n;
 
   for (f = 0; f < sox_formats; ++f) {
     sox_format_handler_t const * fh = sox_format_fns[f].fn();
--- a/src/nulfile.c
+++ b/src/nulfile.c
@@ -1,5 +1,5 @@
 /*
- * File format: null   (c) 2006-7 SoX contributers
+ * File format: null   (c) 2006-7 SoX contributors
  * Based on an original idea by Carsten Borchardt
  *
  * This library is free software; you can redistribute it and/or modify it
@@ -26,7 +26,7 @@
    * (but commonly used) defaults: */
   if (!ft->signal.rate) {
     ft->signal.rate = 44100;
-    sox_report("sample rate not specified; using %i", ft->signal.rate);
+    sox_report("sample rate not specified; using %g", ft->signal.rate);
   }
   if (ft->signal.size <= 0) {
     ft->signal.size = SOX_SIZE_16BIT;
--- a/src/oss.c
+++ b/src/oss.c
@@ -162,7 +162,7 @@
          */
         if ((int)ft->signal.rate - tmp > (tmp * .01) || 
             tmp - (int)ft->signal.rate > (tmp * .01)) {
-            sox_warn("Unable to set audio speed to %d (set to %d)",
+            sox_warn("Unable to set audio speed to %g (set to %d)",
                      ft->signal.rate, tmp);
             ft->signal.rate = tmp;
         }
--- a/src/polyphas.c
+++ b/src/polyphas.c
@@ -146,7 +146,7 @@
   }
   *q = 0;
   for (pr=0; pr<q-q0; pr++) sox_debug(" %d",q0[pr]);
-  sox_debug("");
+  sox_debug(" ");
   return (q-q0);
 }
 
@@ -235,7 +235,7 @@
           sox_debug("c_min %d, [%d-%d]:",c_min,numer,denom);
           for (j=0; j<u; j++)
             sox_debug(" (%d,%d)",rate->m1[j],rate->m2[j]);
-          sox_debug("");
+          sox_debug(" ");
         }
         memcpy(rate->b1,rate->m1,u*sizeof(int));
         memcpy(rate->b2,rate->m2,u*sizeof(int));
--- a/src/sox.c
+++ b/src/sox.c
@@ -4,7 +4,7 @@
  * This is the main function for the command line sox program.
  *
  * Copyright 1991 Lance Norskog And Sundry Contributors
- * Copyright 1998-2007 Chris Bagnall and SoX contributors
+ * Copyright 1998-2007 Chris Bagwell and SoX contributors
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License as
@@ -1568,7 +1568,7 @@
   if (ofile->signal.channels == 0)
     ofile->signal.channels = combiner.channels;
 
-  combiner.rate = combiner.rate * sox_effects_globals.speed;
+  combiner.rate *= sox_effects_globals.speed;
 
   for (i = 0; i < nuser_effects; i++)
     known_length = known_length && !(user_efftab[i].handler.flags & SOX_EFF_LENGTH);
--- a/src/sox_i.h
+++ b/src/sox_i.h
@@ -28,8 +28,10 @@
 /* various gcc optimizations and portablity defines */
 #ifdef __GNUC__
 #define NORET __attribute__((noreturn))
+#define PRINTF __attribute__ ((format (printf, 1, 2)))
 #else
 #define NORET
+#define PRINTF
 #endif
 
 #ifdef _MSC_VER
@@ -201,12 +203,12 @@
 typedef void (*sox_output_message_handler_t)(unsigned level, const char *filename, const char *fmt, va_list ap);
 void sox_output_message(FILE *file, const char *filename, const char *fmt, va_list ap);
 
-void sox_fail(const char *, ...);
-void sox_warn(const char *, ...);
-void sox_report(const char *, ...);
-void sox_debug(const char *, ...);
-void sox_debug_more(char const * fmt, ...);
-void sox_debug_most(char const * fmt, ...);
+void sox_fail(const char *, ...) PRINTF;
+void sox_warn(const char *, ...) PRINTF;
+void sox_report(const char *, ...) PRINTF;
+void sox_debug(const char *, ...) PRINTF;
+void sox_debug_more(char const * fmt, ...) PRINTF;
+void sox_debug_most(char const * fmt, ...) PRINTF;
 
 #define sox_fail       sox_globals.subsystem=__FILE__,sox_fail
 #define sox_warn       sox_globals.subsystem=__FILE__,sox_warn
@@ -215,7 +217,12 @@
 #define sox_debug_more sox_globals.subsystem=__FILE__,sox_debug_more
 #define sox_debug_most sox_globals.subsystem=__FILE__,sox_debug_most
 
-void sox_fail_errno(sox_format_t *, int, const char *, ...);
+void sox_fail_errno(sox_format_t *, int, const char *, ...)
+#ifdef __GNUC__
+__attribute__ ((format (printf, 3, 4)));
+#else
+;
+#endif
 
 #ifdef WORDS_BIGENDIAN
 #define SOX_IS_BIGENDIAN 1
--- a/src/soxconfig.h.cmake
+++ b/src/soxconfig.h.cmake
@@ -22,6 +22,7 @@
 #cmakedefine HAVE_SAMPLERATE_H        1
 #cmakedefine HAVE_SNDFILE_1_0_12      1
 #cmakedefine HAVE_SNDFILE_H           1
+#cmakedefine HAVE_LIBSOUNDTOUCH       1
 #cmakedefine HAVE_STDINT_H            1
 #cmakedefine HAVE_STRCASECMP          1
 #cmakedefine HAVE_STRDUP              1
--- a/src/synth.c
+++ b/src/synth.c
@@ -2,7 +2,7 @@
  * synth - Synthesizer Effect.
  *
  * Copyright (c) Jan 2001  Carsten Borchardt
- * Copyright (c) 2001-2007 SoX contributers
+ * Copyright (c) 2001-2007 SoX contributors
  *
  * This source code is freely redistributable and may be used for any purpose.
  * This copyright notice must be maintained.  The authors are not responsible
--- a/src/tx16w.c
+++ b/src/tx16w.c
@@ -166,7 +166,7 @@
                 ft->signal.rate = 33333;
             }
     }
-    sox_debug("Sample rate = %ld",ft->signal.rate);
+    sox_debug("Sample rate = %g", ft->signal.rate);
 
     ft->signal.channels = 1 ; /* not sure about stereo sample data yet ??? */
     ft->signal.size = SOX_SIZE_16BIT; /* this is close enough */
--- a/src/voc.c
+++ b/src/voc.c
@@ -565,15 +565,13 @@
                         if (!v->extended) {
                           if (uc == 0)
                           {
-                            sox_fail_errno(ft,SOX_EFMT,
-                              "File %s: Sample rate is zero?");
+                            sox_fail_errno(ft, SOX_EFMT, "Sample rate is zero?");
                             return(SOX_EOF);
                           }
                           if ((v->rate != -1) && (uc != v->rate))
                           {
                             sox_fail_errno(ft,SOX_EFMT,
-                              "File %s: sample rate codes differ: %d != %d",
-                                 ft->filename,v->rate, uc);
+                              "sample rate codes differ: %d != %d", v->rate, uc);
                             return(SOX_EOF);
                           }
                           v->rate = uc;
@@ -584,8 +582,7 @@
                         if (uc != 0)
                         {
                           sox_fail_errno(ft,SOX_EFMT,
-                            "File %s: only interpret 8-bit data!",
-                               ft->filename);
+                            "only interpret 8-bit data!");
                           return(SOX_EOF);
                         }
                         v->extended = 0;
@@ -597,14 +594,14 @@
                         if (new_rate_32 == 0)
                         {
                             sox_fail_errno(ft,SOX_EFMT,
-                              "File %s: Sample rate is zero?",ft->filename);
+                              "Sample rate is zero?");
                             return(SOX_EOF);
                         }
                         if ((v->rate != -1) && ((long)new_rate_32 != v->rate))
                         {
                             sox_fail_errno(ft,SOX_EFMT,
-                              "File %s: sample rate codes differ: %d != %d",
-                                ft->filename, v->rate, new_rate_32);
+                              "sample rate codes differ: %d != %d",
+                                v->rate, new_rate_32);
                             return(SOX_EOF);
                         }
                         v->rate = new_rate_32;
@@ -638,9 +635,8 @@
                         sox_readb(ft, &uc);
                         if (uc == 0)
                         {
-                                sox_fail_errno(ft,SOX_EFMT,
-                                  "File %s: Silence sample rate is zero");
-                                return(SOX_EOF);
+                          sox_fail_errno(ft,SOX_EFMT, "Silence sample rate is zero");
+                          return(SOX_EOF);
                         }
                         /*
                          * Some silence-packed files have gratuitously
@@ -690,7 +686,7 @@
                         continue;       /* get next block */
                 case VOC_LOOP:
                 case VOC_LOOPEND:
-                        sox_debug("File %s: skipping repeat loop");
+                        sox_debug("skipping repeat loop");
                         for(i = 0; i < sblen; i++)
                             sox_readb(ft, (unsigned char *)&trash);
                         break;
@@ -703,15 +699,14 @@
                         sox_readw(ft, &new_rate_16);
                         if (new_rate_16 == 0)
                         {
-                           sox_fail_errno(ft,SOX_EFMT,
-                             "File %s: Sample rate is zero?");
+                           sox_fail_errno(ft,SOX_EFMT, "Sample rate is zero?");
                            return(SOX_EOF);
                         }
                         if ((v->rate != -1) && (new_rate_16 != v->rate))
                         {
                            sox_fail_errno(ft,SOX_EFMT,
-                             "File %s: sample rate codes differ: %d != %d",
-                                        ft->filename, v->rate, new_rate_16);
+                             "sample rate codes differ: %d != %d",
+                                        v->rate, new_rate_16);
                            return(SOX_EOF);
                         }
                         v->rate = new_rate_16;
@@ -719,8 +714,7 @@
                         if (uc != 0)
                         {
                                 sox_fail_errno(ft,SOX_EFMT,
-                                  "File %s: only interpret 8-bit data!",
-                                        ft->filename);
+                                  "only interpret 8-bit data!");
                                 return(SOX_EOF);
                         }
                         sox_readb(ft, &uc);
@@ -735,8 +729,7 @@
                         /* can be grabed.                               */
                         continue;
                 default:
-                        sox_debug("File %s: skipping unknown block code %d",
-                                ft->filename, block);
+                        sox_debug("skipping unknown block code %d", block);
                         for(i = 0; i < sblen; i++)
                             sox_readb(ft, (unsigned char *)&trash);
                 }
--- a/src/vol.c
+++ b/src/vol.c
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 20/03/2000 Fabien COELHO <fabien@coelho.net>
- * Copyright (c) 2000-2007 SoX contributers
+ * Copyright (c) 2000-2007 SoX contributors
  *
  * SoX vol effect; change volume with basic linear amplitude formula.
  * Beware of saturations!  Clipping is checked and reported.