From 34e91850d92a9dd0606e94e0c3a5368a9f3fd35c Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 1 Jul 2016 21:34:56 +0200 Subject: [PATCH] decoder/pcm: assume that audio/L16 is big-endian See https://bugs.musicpd.org/view.php?id=4547 --- src/decoder/plugins/PcmDecoderPlugin.cxx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/decoder/plugins/PcmDecoderPlugin.cxx b/src/decoder/plugins/PcmDecoderPlugin.cxx index 62abfa8d0..3a3adef37 100644 --- a/src/decoder/plugins/PcmDecoderPlugin.cxx +++ b/src/decoder/plugins/PcmDecoderPlugin.cxx @@ -22,6 +22,7 @@ #include "../DecoderAPI.hxx" #include "CheckAudioFormat.hxx" #include "input/InputStream.hxx" +#include "system/ByteOrder.hxx" #include "util/Error.hxx" #include "util/ByteReverse.hxx" #include "util/NumberParser.hxx" @@ -40,8 +41,6 @@ pcm_stream_decode(Decoder &decoder, InputStream &is) }; const char *const mime = is.GetMimeType(); - const bool reverse_endian = mime != nullptr && - strcmp(mime, "audio/x-mpd-cdda-pcm-reverse") == 0; const bool l16 = mime != nullptr && GetMimeTypeBase(mime) == "audio/L16"; @@ -52,6 +51,10 @@ pcm_stream_decode(Decoder &decoder, InputStream &is) audio_format.channels = 1; } + const bool reverse_endian = (l16 && IsLittleEndian()) || + (mime != nullptr && + strcmp(mime, "audio/x-mpd-cdda-pcm-reverse") == 0); + if (is_float) audio_format.format = SampleFormat::FLOAT;