aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRainer Hochecker <fernetmenta@online.de>2014-02-19 11:18:34 +0100
committerRainer Hochecker <fernetmenta@online.de>2014-02-19 13:01:42 +0100
commitc45e4710331c91c257d8173fe47e66427a69edeb (patch)
treeae64b6f347c401dc159536f2c0cbf71396e09280
parentf6f539a7c933b37f3efd08cea765f1f0f59a30c5 (diff)
ActiveAE: fix downmix for the case a sink returns more channels than requested
-rw-r--r--xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAE.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAE.cpp b/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAE.cpp
index ccbe99a45c..f30f37b556 100644
--- a/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAE.cpp
+++ b/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAE.cpp
@@ -930,6 +930,11 @@ void CActiveAE::Configure(AEAudioFormat *desiredFmt)
if (m_streams.empty())
{
inputFormat = m_sinkFormat;
+ if (m_sinkFormat.m_channelLayout.Count() > m_sinkRequestFormat.m_channelLayout.Count())
+ {
+ inputFormat.m_channelLayout = m_sinkRequestFormat.m_channelLayout;
+ inputFormat.m_channelLayout.ResolveChannels(m_sinkFormat.m_channelLayout);
+ }
inputFormat.m_dataFormat = AE_FMT_FLOAT;
inputFormat.m_frameSize = inputFormat.m_channelLayout.Count() *
(CAEUtil::DataFormatToBits(inputFormat.m_dataFormat) >> 3);
@@ -1023,6 +1028,16 @@ void CActiveAE::Configure(AEAudioFormat *desiredFmt)
outputFormat.m_dataFormat = AE_FMT_FLOAT;
outputFormat.m_frameSize = outputFormat.m_channelLayout.Count() *
(CAEUtil::DataFormatToBits(outputFormat.m_dataFormat) >> 3);
+
+ // due to channel ordering of the driver, a sink may return more channels than
+ // requested, i.e. 2.1 request returns FL,FR,BL,BR,FC,LFE for ALSA
+ // in this case we need to downmix to requested format
+ if (m_sinkFormat.m_channelLayout.Count() > m_sinkRequestFormat.m_channelLayout.Count())
+ {
+ outputFormat.m_channelLayout = m_sinkRequestFormat.m_channelLayout;
+ outputFormat.m_channelLayout.ResolveChannels(m_sinkFormat.m_channelLayout);
+ }
+
// TODO: adjust to decoder
sinkInputFormat = outputFormat;
}