PcmConvert: fix src_format corruption when converting from DSD
Method PcmConvert::Convert() modifies the src_format variable. This
used to be a parameter, however commit d2679f59c
made it an attribute
instead. The modification to src_format persisted, and the next call
would return garbage.
This commit is contained in:
parent
bb288f0284
commit
a788b7e747
|
@ -56,6 +56,10 @@ PcmConvert::Open(AudioFormat _src_format, AudioFormat _dest_format,
|
||||||
src_format = _src_format;
|
src_format = _src_format;
|
||||||
dest_format = _dest_format;
|
dest_format = _dest_format;
|
||||||
|
|
||||||
|
is_dsd = src_format.format == SampleFormat::DSD;
|
||||||
|
if (is_dsd)
|
||||||
|
src_format.format = SampleFormat::FLOAT;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -277,8 +281,7 @@ PcmConvert::Convert(const void *src, size_t src_size,
|
||||||
size_t *dest_size_r,
|
size_t *dest_size_r,
|
||||||
Error &error)
|
Error &error)
|
||||||
{
|
{
|
||||||
AudioFormat float_format;
|
if (is_dsd) {
|
||||||
if (src_format.format == SampleFormat::DSD) {
|
|
||||||
size_t f_size;
|
size_t f_size;
|
||||||
const float *f = dsd.ToFloat(src_format.channels,
|
const float *f = dsd.ToFloat(src_format.channels,
|
||||||
false, (const uint8_t *)src,
|
false, (const uint8_t *)src,
|
||||||
|
@ -289,10 +292,6 @@ PcmConvert::Convert(const void *src, size_t src_size,
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
float_format = src_format;
|
|
||||||
float_format.format = SampleFormat::FLOAT;
|
|
||||||
|
|
||||||
src_format = float_format;
|
|
||||||
src = f;
|
src = f;
|
||||||
src_size = f_size;
|
src_size = f_size;
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,6 +51,13 @@ class PcmConvert {
|
||||||
|
|
||||||
AudioFormat src_format, dest_format;
|
AudioFormat src_format, dest_format;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Do we get DSD source data? Then this flag is true and
|
||||||
|
* src_format.format is set to SampleFormat::FLOAT, because
|
||||||
|
* the #PcmDsd class will convert it to floating point.
|
||||||
|
*/
|
||||||
|
bool is_dsd;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PcmConvert();
|
PcmConvert();
|
||||||
~PcmConvert();
|
~PcmConvert();
|
||||||
|
|
Loading…
Reference in New Issue