aboutsummaryrefslogtreecommitdiffstats
path: root/src/pcm
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-10-23 22:13:08 +0200
committerMax Kellermann <max@duempel.org>2014-10-23 22:42:08 +0200
commit8ce48d83eb4d6f0d97359747f15e72dd1ef8760b (patch)
treeb9dbe7b0e05931ece431954c0abced95fa5ecbff /src/pcm
parent200cdb6b0ad7b6691cd06e21a52d4dc09a685a1b (diff)
downloadmpd-8ce48d83eb4d6f0d97359747f15e72dd1ef8760b.tar.gz
mpd-8ce48d83eb4d6f0d97359747f15e72dd1ef8760b.tar.xz
mpd-8ce48d83eb4d6f0d97359747f15e72dd1ef8760b.zip
pcm/FormatConverter: move check to Open()
Report unsupported format while opening the filter, not later when the first conversion takes place.
Diffstat (limited to 'src/pcm')
-rw-r--r--src/pcm/FormatConverter.cxx34
1 files changed, 24 insertions, 10 deletions
diff --git a/src/pcm/FormatConverter.cxx b/src/pcm/FormatConverter.cxx
index 64e2d8594..b058b32f5 100644
--- a/src/pcm/FormatConverter.cxx
+++ b/src/pcm/FormatConverter.cxx
@@ -28,11 +28,31 @@
bool
PcmFormatConverter::Open(SampleFormat _src_format, SampleFormat _dest_format,
- gcc_unused Error &error)
+ Error &error)
{
assert(_src_format != SampleFormat::UNDEFINED);
assert(_dest_format != SampleFormat::UNDEFINED);
+ switch (_dest_format) {
+ case SampleFormat::UNDEFINED:
+ assert(false);
+ gcc_unreachable();
+
+ case SampleFormat::S8:
+ case SampleFormat::DSD:
+ error.Format(pcm_domain,
+ "PCM conversion from %s to %s is not implemented",
+ sample_format_to_string(_src_format),
+ sample_format_to_string(_dest_format));
+ return nullptr;
+
+ case SampleFormat::S16:
+ case SampleFormat::S24_P32:
+ case SampleFormat::S32:
+ case SampleFormat::FLOAT:
+ break;
+ }
+
src_format = _src_format;
dest_format = _dest_format;
return true;
@@ -48,20 +68,14 @@ PcmFormatConverter::Close()
}
ConstBuffer<void>
-PcmFormatConverter::Convert(ConstBuffer<void> src, Error &error)
+PcmFormatConverter::Convert(ConstBuffer<void> src, gcc_unused Error &error)
{
switch (dest_format) {
case SampleFormat::UNDEFINED:
- assert(false);
- gcc_unreachable();
-
case SampleFormat::S8:
case SampleFormat::DSD:
- error.Format(pcm_domain,
- "PCM conversion from %s to %s is not implemented",
- sample_format_to_string(src_format),
- sample_format_to_string(dest_format));
- return nullptr;
+ assert(false);
+ gcc_unreachable();
case SampleFormat::S16:
return pcm_convert_to_16(buffer, dither,