Permalink
Browse files

[AE] Add "operator-=" to AEChannelInfo

  • Loading branch information...
1 parent d626565 commit 7a78119d18a0a8c6475f5cf62d14529190b655d9 @Karlson2k committed Oct 7, 2012
Showing with 18 additions and 0 deletions.
  1. +17 −0 xbmc/cores/AudioEngine/Utils/AEChannelInfo.cpp
  2. +1 −0 xbmc/cores/AudioEngine/Utils/AEChannelInfo.h
@@ -196,6 +196,23 @@ void CAEChannelInfo::operator+=(const enum AEChannel rhs)
m_channels[m_channelCount++] = rhs;
}
+void CAEChannelInfo::operator-=(const enum AEChannel rhs)
+{
+ ASSERT(rhs > AE_CH_NULL && rhs < AE_CH_MAX);
+
+ int i = 0;
+ while(i < m_channelCount && m_channels[i] != rhs)
+ i++;
+ if (i >= m_channelCount)
+ return; // Channel not found
+
+ for(; i < m_channelCount-1; i++)
+ m_channels[i] = m_channels[i+1];
+
+ m_channels[i] = AE_CH_NULL;
+ m_channelCount--;
+}
+
const enum AEChannel CAEChannelInfo::operator[](unsigned int i) const
{
ASSERT(i < m_channelCount);
@@ -81,6 +81,7 @@ class CAEChannelInfo {
bool operator==(const CAEChannelInfo& rhs);
bool operator!=(const CAEChannelInfo& rhs);
void operator+=(const enum AEChannel rhs);
+ void operator-=(const enum AEChannel rhs);
const enum AEChannel operator[](unsigned int i) const;
operator std::string();

1 comment on commit 7a78119

@gnif
gnif commented on 7a78119 Oct 10, 2012

Nice, this should be a separate PR as I would merge it in a second.

Please sign in to comment.