diff options
author | Max Kellermann <max@duempel.org> | 2013-11-28 18:43:33 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2013-11-28 18:43:33 +0100 |
commit | a788b7e747bc21b9aadee45dd028fa6198af794e (patch) | |
tree | e8374e00197db7810e21d9bedea02a70afa96430 /src/pcm/PcmConvert.cxx | |
parent | bb288f02848793a85b74262063d1bd9c7bc7dd78 (diff) | |
download | mpd-a788b7e747bc21b9aadee45dd028fa6198af794e.tar.gz mpd-a788b7e747bc21b9aadee45dd028fa6198af794e.tar.xz mpd-a788b7e747bc21b9aadee45dd028fa6198af794e.zip |
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.
Diffstat (limited to 'src/pcm/PcmConvert.cxx')
-rw-r--r-- | src/pcm/PcmConvert.cxx | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/pcm/PcmConvert.cxx b/src/pcm/PcmConvert.cxx index cca2f701e..05ed92faf 100644 --- a/src/pcm/PcmConvert.cxx +++ b/src/pcm/PcmConvert.cxx @@ -56,6 +56,10 @@ PcmConvert::Open(AudioFormat _src_format, AudioFormat _dest_format, src_format = _src_format; dest_format = _dest_format; + is_dsd = src_format.format == SampleFormat::DSD; + if (is_dsd) + src_format.format = SampleFormat::FLOAT; + return true; } @@ -277,8 +281,7 @@ PcmConvert::Convert(const void *src, size_t src_size, size_t *dest_size_r, Error &error) { - AudioFormat float_format; - if (src_format.format == SampleFormat::DSD) { + if (is_dsd) { size_t f_size; const float *f = dsd.ToFloat(src_format.channels, false, (const uint8_t *)src, @@ -289,10 +292,6 @@ PcmConvert::Convert(const void *src, size_t src_size, return nullptr; } - float_format = src_format; - float_format.format = SampleFormat::FLOAT; - - src_format = float_format; src = f; src_size = f_size; } |