shithub: sox

Download patch

ref: 0da8e4cd5a4a3fe2a98f8beb7d74dbc55d557c19
parent: f105762dd1ce7c0c9317e3b0d205804d1360b418
author: Mans Rullgard <mans@mansr.com>
date: Sat Aug 8 06:37:34 EDT 2020

wav: improve error message for unsupported formats

--- a/src/wav.c
+++ b/src/wav.c
@@ -626,11 +626,14 @@
     return NULL;
 }
 
-static int wavfail(sox_format_t *ft, int tag)
+static int wavfail(sox_format_t *ft, int tag, const char *name)
 {
-    lsx_fail_errno(ft, SOX_EHDR,
-                   "WAV file encoding '%s' (%04x) is not supported",
-                   wav_format_str(tag), tag);
+    if (name)
+        lsx_fail_errno(ft, SOX_EHDR, "WAVE format '%s' (%04x) not supported",
+                       name, tag);
+    else
+        lsx_fail_errno(ft, SOX_EHDR, "Unknown WAVE format %04x", tag);
+
     return SOX_EOF;
 }
 
@@ -721,7 +724,7 @@
 
     fmt = wav_find_format(wav->formatTag);
     if (!fmt)
-        return wavfail(ft, wav->formatTag);
+        return wavfail(ft, wav->formatTag, NULL);
 
     /* format handler might override */
     ft->encoding.encoding = fmt->encoding;
@@ -730,7 +733,7 @@
         if (fmt->read_fmt(ft, len))
             return SOX_EOF;
     } else if (!fmt->encoding) {
-        return wavfail(ft, wav->formatTag);
+        return wavfail(ft, wav->formatTag, fmt->name);
     }
 
     /* User options take precedence */