pcm/Dsd32: fix the byte order

The byte order of DSD_U32 was wrong from the start.  The oldest bits
must be in the MSB, not in the LSB, according to
snd_pcm_format_descriptions in alsa-lib.
This commit is contained in:
Max Kellermann 2017-01-11 22:25:54 +01:00
parent c5a2cadccc
commit cc0dbcf3f4
3 changed files with 7 additions and 3 deletions

1
NEWS
View File

@ -5,6 +5,7 @@ ver 0.20.2 (not yet released)
- libsamplerate: reset state after seeking
* output
- alsa: fix the DSD_U32 sample rate
- alsa: fix the DSD_U32 byte order
ver 0.20.1 (2017/01/09)
* input

View File

@ -29,8 +29,11 @@
static constexpr inline uint32_t
Construct32(uint8_t a, uint8_t b, uint8_t c, uint8_t d)
{
return uint32_t(a) | (uint32_t(b) << 8) |
(uint32_t(c) << 16) | (uint32_t(d) << 24);
/* "a" is the oldest byte, which must be in the most
significant byte */
return uint32_t(d) | (uint32_t(c) << 8) |
(uint32_t(b) << 16) | (uint32_t(a) << 24);
}
static constexpr inline uint32_t

View File

@ -28,7 +28,7 @@ template<typename T> struct ConstBuffer;
class PcmBuffer;
/**
* Convert DSD_U8 to DSD_U32 (native endian).
* Convert DSD_U8 to DSD_U32 (native endian, oldest bits in MSB).
*/
ConstBuffer<uint32_t>
Dsd8To32(PcmBuffer &buffer, unsigned channels, ConstBuffer<uint8_t> src);