History

wav: improve error message for unsupported formats

Mans Rullgard committed 6 years ago

Commit 0da8e4c1 parent f1057621 file · +9 −6Browse files

Showing the changes to src (1 of 1 file). Show all

Unified · Split

src/wav.c+9−6
@@ -626,11 +626,14 @@ static const struct wave_format *wav_find_format(unsigned tag) · 625 unmodified lines
626626 return NULL;
627627 }
628628
629−static int wavfail(sox_format_t *ft, int tag)
629+static int wavfail(sox_format_t *ft, int tag, const char *name)
630630 {
631− lsx_fail_errno(ft, SOX_EHDR,
632− "WAV file encoding '%s' (%04x) is not supported",
633− wav_format_str(tag), tag);
631+ if (name)
632+ lsx_fail_errno(ft, SOX_EHDR, "WAVE format '%s' (%04x) not supported",
633+ name, tag);
634+ else
635+ lsx_fail_errno(ft, SOX_EHDR, "Unknown WAVE format %04x", tag);
636+
634637 return SOX_EOF;
635638 }
636639
@@ -721,7 +724,7 @@ static int wav_read_fmt(sox_format_t *ft, uint32_t len) · 84 unmodified lines
721724
722725 fmt = wav_find_format(wav->formatTag);
723726 if (!fmt)
724− return wavfail(ft, wav->formatTag);
727+ return wavfail(ft, wav->formatTag, NULL);
725728
726729 /* format handler might override */
727730 ft->encoding.encoding = fmt->encoding;
@@ -730,7 +733,7 @@ static int wav_read_fmt(sox_format_t *ft, uint32_t len) · 2 unmodified lines
730733 if (fmt->read_fmt(ft, len))
731734 return SOX_EOF;
732735 } else if (!fmt->encoding) {
733− return wavfail(ft, wav->formatTag);
736+ return wavfail(ft, wav->formatTag, fmt->name);
734737 }
735738
736739 /* User options take precedence */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t