shithub: sox

Download patch

ref: 338273aba970352de84eb5ea3278cd4f64689f72
parent: ca3b22d45853318bde9ed8237a4017c7ab1a5141
author: Ulrich Klauer <ulrich@chirlu.de>
date: Wed Jan 11 12:46:15 EST 2012

Allow the last of multiple effects chains to be empty

In multiple effects chain mode, allow the last chain to be empty to
indicate copying without further processing. E.g.,
  sox infile.wav outfile.wav trim 0 30 reverse :
would reverse the first thirty seconds of the input file, then append
the rest of the file unchanged.

This resolves feature request 2459231 and also fixes a memory leak,
where in previous versions the empty last chain was ignored but not
freed.

--- a/src/sox.c
+++ b/src/sox.c
@@ -2905,13 +2905,10 @@
   /* Loop through the rest of the arguments looking for effects */
   add_eff_chain();
   parse_effects(argc, argv);
-  if (eff_chain_count == 0 || nuser_effects[eff_chain_count] > 0)
-  {
-    eff_chain_count++;
-    /* Note: Purposely not calling add_eff_chain() to save some
-     * memory although it would be more consistent to do so.
-     */
-  }
+  eff_chain_count++;
+  /* Note: Purposely not calling add_eff_chain() to save some
+   * memory although it would be more consistent to do so.
+   */
 
   /* Not the best way for users to do this; now deprecated in favour of soxi. */
   if (!show_progress && !nuser_effects[current_eff_chain] &&