From 15e432204e62dd5a1c873af13a679195b9645b0c Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 27 Oct 2015 00:22:22 +0100 Subject: pcm/Order: new library to convert from FLAC to ALSA channel order This new library is integrated in the PcmExport class and (if enabled) converts MPD's channel order (= FLAC channel order) to ALSA channel order. This fixes: http://bugs.musicpd.org/view.php?id=3147 and http://bugs.musicpd.org/view.php?id=3255 --- src/pcm/PcmExport.cxx | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/pcm/PcmExport.cxx') diff --git a/src/pcm/PcmExport.cxx b/src/pcm/PcmExport.cxx index af2eb7d9f..0bf4f8be8 100644 --- a/src/pcm/PcmExport.cxx +++ b/src/pcm/PcmExport.cxx @@ -19,6 +19,7 @@ #include "config.h" #include "PcmExport.hxx" +#include "Order.hxx" #include "PcmDop.hxx" #include "PcmPack.hxx" #include "util/ByteReverse.hxx" @@ -28,12 +29,16 @@ void PcmExport::Open(SampleFormat sample_format, unsigned _channels, + bool _alsa_channel_order, bool _dop, bool _shift8, bool _pack, bool _reverse_endian) { assert(audio_valid_sample_format(sample_format)); assert(!_dop || audio_valid_channel_count(_channels)); channels = _channels; + alsa_channel_order = _alsa_channel_order + ? sample_format + : SampleFormat::UNDEFINED; dop = _dop && sample_format == SampleFormat::DSD; if (dop) /* after the conversion to DoP, the DSD @@ -77,6 +82,10 @@ PcmExport::GetFrameSize(const AudioFormat &audio_format) const ConstBuffer PcmExport::Export(ConstBuffer data) { + if (alsa_channel_order != SampleFormat::UNDEFINED) + data = ToAlsaChannelOrder(order_buffer, data, + alsa_channel_order, channels); + if (dop) data = pcm_dsd_to_dop(dop_buffer, channels, ConstBuffer::FromVoid(data)) -- cgit v1.2.3