pcm/PcmConvert: assign {src,dest}_format at the end
Fixes assertion failure in destructor by not assigning {src,dest}_format when an error occurs.
This commit is contained in:
1
NEWS
1
NEWS
@@ -1,4 +1,5 @@
|
|||||||
ver 0.19.2 (not yet released)
|
ver 0.19.2 (not yet released)
|
||||||
|
* fix assertion failure on unsupported PCM conversion
|
||||||
|
|
||||||
ver 0.19.1 (2014/10/19)
|
ver 0.19.1 (2014/10/19)
|
||||||
* input
|
* input
|
||||||
|
@@ -59,36 +59,34 @@ PcmConvert::Open(const AudioFormat _src_format, const AudioFormat _dest_format,
|
|||||||
assert(_src_format.IsValid());
|
assert(_src_format.IsValid());
|
||||||
assert(_dest_format.IsValid());
|
assert(_dest_format.IsValid());
|
||||||
|
|
||||||
src_format = _src_format;
|
AudioFormat format = _src_format;
|
||||||
dest_format = _dest_format;
|
|
||||||
|
|
||||||
AudioFormat format = src_format;
|
|
||||||
if (format.format == SampleFormat::DSD)
|
if (format.format == SampleFormat::DSD)
|
||||||
format.format = SampleFormat::FLOAT;
|
format.format = SampleFormat::FLOAT;
|
||||||
|
|
||||||
enable_resampler = format.sample_rate != dest_format.sample_rate;
|
enable_resampler = format.sample_rate != _dest_format.sample_rate;
|
||||||
if (enable_resampler) {
|
if (enable_resampler) {
|
||||||
if (!resampler.Open(format, dest_format.sample_rate, error))
|
if (!resampler.Open(format, _dest_format.sample_rate, error))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
format.format = resampler.GetOutputSampleFormat();
|
format.format = resampler.GetOutputSampleFormat();
|
||||||
format.sample_rate = dest_format.sample_rate;
|
format.sample_rate = _dest_format.sample_rate;
|
||||||
}
|
}
|
||||||
|
|
||||||
enable_format = format.format != dest_format.format;
|
enable_format = format.format != _dest_format.format;
|
||||||
if (enable_format &&
|
if (enable_format &&
|
||||||
!format_converter.Open(format.format, dest_format.format, error)) {
|
!format_converter.Open(format.format, _dest_format.format,
|
||||||
|
error)) {
|
||||||
if (enable_resampler)
|
if (enable_resampler)
|
||||||
resampler.Close();
|
resampler.Close();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
format.format = dest_format.format;
|
format.format = _dest_format.format;
|
||||||
|
|
||||||
enable_channels = format.channels != dest_format.channels;
|
enable_channels = format.channels != _dest_format.channels;
|
||||||
if (enable_channels &&
|
if (enable_channels &&
|
||||||
!channels_converter.Open(format.format, format.channels,
|
!channels_converter.Open(format.format, format.channels,
|
||||||
dest_format.channels, error)) {
|
_dest_format.channels, error)) {
|
||||||
if (enable_format)
|
if (enable_format)
|
||||||
format_converter.Close();
|
format_converter.Close();
|
||||||
if (enable_resampler)
|
if (enable_resampler)
|
||||||
@@ -96,6 +94,9 @@ PcmConvert::Open(const AudioFormat _src_format, const AudioFormat _dest_format,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
src_format = _src_format;
|
||||||
|
dest_format = _dest_format;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user