aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--xbmc/cores/AudioEngine/Sinks/AESinkALSA.cpp5
-rw-r--r--xbmc/cores/AudioEngine/Utils/AEChannelInfo.cpp24
-rw-r--r--xbmc/cores/AudioEngine/Utils/AEChannelInfo.h2
3 files changed, 31 insertions, 0 deletions
diff --git a/xbmc/cores/AudioEngine/Sinks/AESinkALSA.cpp b/xbmc/cores/AudioEngine/Sinks/AESinkALSA.cpp
index d66993a095..4d87afa2c9 100644
--- a/xbmc/cores/AudioEngine/Sinks/AESinkALSA.cpp
+++ b/xbmc/cores/AudioEngine/Sinks/AESinkALSA.cpp
@@ -618,6 +618,11 @@ bool CAESinkALSA::Initialize(AEAudioFormat &format, std::string &device)
}
// adjust format to the configuration we got
format.m_channelLayout = GetChannelLayout(format, outconfig.channels);
+ // we might end up with an unusable channel layout that contains only UNKNOWN
+ // channels, let's do a sanity check.
+ if (!format.m_channelLayout.IsLayoutValid())
+ return false;
+
format.m_sampleRate = outconfig.sampleRate;
format.m_frames = outconfig.periodSize;
format.m_frameSize = outconfig.frameSize;
diff --git a/xbmc/cores/AudioEngine/Utils/AEChannelInfo.cpp b/xbmc/cores/AudioEngine/Utils/AEChannelInfo.cpp
index 4f77c04fe7..636d728714 100644
--- a/xbmc/cores/AudioEngine/Utils/AEChannelInfo.cpp
+++ b/xbmc/cores/AudioEngine/Utils/AEChannelInfo.cpp
@@ -259,6 +259,30 @@ CAEChannelInfo::operator std::string() const
return s;
}
+bool CAEChannelInfo::IsChannelValid(const unsigned int pos)
+{
+ assert(pos < m_channelCount);
+ bool isValid = false;
+ if (m_channels[pos] > AE_CH_NULL && m_channels[pos] < AE_CH_UNKNOWN1)
+ isValid = true;
+
+ return isValid;
+}
+
+bool CAEChannelInfo::IsLayoutValid()
+{
+ if (m_channelCount == 0)
+ return false;
+
+ for (unsigned int i = 0; i < m_channelCount; ++i)
+ {
+ // we need at least one valid channel
+ if (IsChannelValid(i))
+ return true;
+ }
+ return false;
+}
+
const char* CAEChannelInfo::GetChName(const enum AEChannel ch)
{
assert(ch >= 0 && ch < AE_CH_MAX);
diff --git a/xbmc/cores/AudioEngine/Utils/AEChannelInfo.h b/xbmc/cores/AudioEngine/Utils/AEChannelInfo.h
index 4151776eab..1ed9578781 100644
--- a/xbmc/cores/AudioEngine/Utils/AEChannelInfo.h
+++ b/xbmc/cores/AudioEngine/Utils/AEChannelInfo.h
@@ -51,6 +51,8 @@ public:
inline unsigned int Count() const { return m_channelCount; }
static const char* GetChName(const enum AEChannel ch);
bool HasChannel(const enum AEChannel ch) const;
+ bool IsChannelValid(const unsigned int pos);
+ bool IsLayoutValid();
bool ContainsChannels(const CAEChannelInfo& rhs) const;
void ReplaceChannel(const enum AEChannel from, const enum AEChannel to);
int BestMatch(const std::vector<CAEChannelInfo>& dsts, int* score = NULL) const;