diff options
author | Max Kellermann <max@musicpd.org> | 2019-06-17 21:24:32 +0200 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2019-06-17 21:24:32 +0200 |
commit | 2c3eeb7194b4871ed7227a2c0b7bfae90b05d17f (patch) | |
tree | 225dd765a358793a3627ee109073cce0bb032c76 | |
parent | 79839db3a3b6819eb4d4d8408bc368bf1bc2618e (diff) |
MusicChunk: pad MusicChunkInfo to a multiple of 8 bytes
Workaround for a regression caused by commit
a06bf388d968279808009d4538def57e78b4bee7, revealing a problem with
discarding odd numer of frames in the DSD_U32 and DoP converters,
causing distortions with DSD_U32 and DoP on 32 bit CPUs.
Closes https://github.com/MusicPlayerDaemon/MPD/issues/469
-rw-r--r-- | NEWS | 2 | ||||
-rw-r--r-- | src/MusicChunk.hxx | 14 |
2 files changed, 15 insertions, 1 deletions
@@ -1,4 +1,6 @@ ver 0.21.11 (not yet released) +* output + - alsa, osx: fix distortions with DSD_U32 and DoP on 32 bit CPUs * protocol - fix "list" with multiple "group" levels diff --git a/src/MusicChunk.hxx b/src/MusicChunk.hxx index b809afefd..5d75e0432 100644 --- a/src/MusicChunk.hxx +++ b/src/MusicChunk.hxx @@ -43,7 +43,15 @@ struct MusicChunk; /** * Meta information for #MusicChunk. */ -struct MusicChunkInfo { +struct alignas(8) MusicChunkInfo { + /* align to multiple of 8 bytes, which adds padding at the + end, so the size of MusicChunk::data is also a multiple of + 8 bytes; this is a workaround for a bug in the DSD_U32 and + DoP converters which require processing 8 bytes at a time, + discarding the remainder */ + /* TODO: once all converters have been fixed, we should remove + this workaround */ + /** the next chunk in a linked list */ MusicChunkPtr next; @@ -119,6 +127,10 @@ struct MusicChunk : MusicChunkInfo { /** the data (probably PCM) */ uint8_t data[CHUNK_SIZE - sizeof(MusicChunkInfo)]; + /* TODO: remove this check once all converters have been fixed + (see comment in struct MusicChunkInfo for details) */ + static_assert(sizeof(data) % 8 == 0, "Wrong alignment"); + /** * Prepares appending to the music chunk. Returns a buffer * where you may write into. After you are finished, call |