shithub: sox

Download patch

ref: 1ecdbf558c5af9da1a148520d51a2c2b2a104778
parent: 2463a11f03e843b8244cebeb558bc34cff47b29b
author: robs <robs>
date: Sat Nov 18 11:55:02 EST 2006

Fix nul file hander ignoring other format options if rate
option has not been given.

--- a/Changelog
+++ b/Changelog
@@ -32,6 +32,8 @@
     parameters. (robs)
   o Allow command-line time parameters of < 1 sec to omit the
     leading 0. (robs)
+  o Fix nul file hander ignoring other format options if rate
+    option has not been given. (robs)
 
 sox-12.18.2
 -----------
--- a/src/nulfile.c
+++ b/src/nulfile.c
@@ -27,17 +27,12 @@
  */
 int st_nulstartread(ft_t ft) 
 {
-    /* if no input rate is given as parameter, switch to 
-     * default parameter
-     */
-    if(ft->info.rate == 0)
-    {
-        /* input rate not set, switch to default */
-        ft->info.rate = 44100;
-        ft->info.size = ST_SIZE_WORD;
-        ft->info.encoding = ST_ENCODING_SIGN2;
-        ft->info.channels = 2;
-    }
+    /* If format parameters are not given, set defaults: */
+    if (ft->info.rate     ==  0) ft->info.rate     = 44100;
+    if (ft->info.size     == -1) ft->info.size     = ST_SIZE_WORD;
+    if (ft->info.encoding == -1) ft->info.encoding = ST_ENCODING_SIGN2;
+    if (ft->info.channels == -1) ft->info.channels = 2;
+
     ft->comment = "nul file";
 
     return (ST_SUCCESS);