pcm/FormatConverter: move check to Open()
Report unsupported format while opening the filter, not later when the first conversion takes place.
This commit is contained in:
parent
200cdb6b0a
commit
8ce48d83eb
@ -28,11 +28,31 @@
|
|||||||
|
|
||||||
bool
|
bool
|
||||||
PcmFormatConverter::Open(SampleFormat _src_format, SampleFormat _dest_format,
|
PcmFormatConverter::Open(SampleFormat _src_format, SampleFormat _dest_format,
|
||||||
gcc_unused Error &error)
|
Error &error)
|
||||||
{
|
{
|
||||||
assert(_src_format != SampleFormat::UNDEFINED);
|
assert(_src_format != SampleFormat::UNDEFINED);
|
||||||
assert(_dest_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;
|
src_format = _src_format;
|
||||||
dest_format = _dest_format;
|
dest_format = _dest_format;
|
||||||
return true;
|
return true;
|
||||||
@ -48,20 +68,14 @@ PcmFormatConverter::Close()
|
|||||||
}
|
}
|
||||||
|
|
||||||
ConstBuffer<void>
|
ConstBuffer<void>
|
||||||
PcmFormatConverter::Convert(ConstBuffer<void> src, Error &error)
|
PcmFormatConverter::Convert(ConstBuffer<void> src, gcc_unused Error &error)
|
||||||
{
|
{
|
||||||
switch (dest_format) {
|
switch (dest_format) {
|
||||||
case SampleFormat::UNDEFINED:
|
case SampleFormat::UNDEFINED:
|
||||||
assert(false);
|
|
||||||
gcc_unreachable();
|
|
||||||
|
|
||||||
case SampleFormat::S8:
|
case SampleFormat::S8:
|
||||||
case SampleFormat::DSD:
|
case SampleFormat::DSD:
|
||||||
error.Format(pcm_domain,
|
assert(false);
|
||||||
"PCM conversion from %s to %s is not implemented",
|
gcc_unreachable();
|
||||||
sample_format_to_string(src_format),
|
|
||||||
sample_format_to_string(dest_format));
|
|
||||||
return nullptr;
|
|
||||||
|
|
||||||
case SampleFormat::S16:
|
case SampleFormat::S16:
|
||||||
return pcm_convert_to_16(buffer, dither,
|
return pcm_convert_to_16(buffer, dither,
|
||||||
|
Loading…
Reference in New Issue
Block a user