From 1c818ef0a048e72820a42449f821bd3b6b525a9a Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 11 Jul 2016 23:13:33 +0200 Subject: [PATCH] decoder/flac: improve warning message about unsupported bit depth --- src/decoder/plugins/FlacCommon.cxx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/decoder/plugins/FlacCommon.cxx b/src/decoder/plugins/FlacCommon.cxx index e191b126b..c0d62054e 100644 --- a/src/decoder/plugins/FlacCommon.cxx +++ b/src/decoder/plugins/FlacCommon.cxx @@ -25,6 +25,7 @@ #include "FlacCommon.hxx" #include "FlacMetadata.hxx" #include "FlacPcm.hxx" +#include "FlacDomain.hxx" #include "CheckAudioFormat.hxx" #include "util/Error.hxx" #include "Log.hxx" @@ -57,10 +58,18 @@ FlacDecoder::Initialize(unsigned sample_rate, unsigned bits_per_sample, assert(!initialized); assert(!unsupported); + auto sample_format = flac_sample_format(bits_per_sample); + if (sample_format == SampleFormat::UNDEFINED) { + FormatWarning(flac_domain, "Unsupported FLAC bit depth: %u", + bits_per_sample); + unsupported = true; + return false; + } + ::Error error; if (!audio_format_init_checked(audio_format, sample_rate, - flac_sample_format(bits_per_sample), + sample_format, channels, error)) { LogError(error); unsupported = true;