Bug 836655 - [Audio] Remove ChildID if there is no content channel playing in foreground and only send audio-channel-changed with normal when ChildID in the background has content channel in playing state. r=baku
☠☠ backed out by 524e7bc67431 ☠ ☠
authorMarco Chen <mchen@mozilla.com>
Mon, 18 Feb 2013 14:30:32 +0800
changeset 122215 b093ba2c7ff9d5ec10ae4e70686f28eef08c3bab
parent 122214 5474b831ece7011e78cba505d992b11cdd5b2ff4
child 122216 91134dd6ac0ad65ef60524fc2caa6eeb4ef3e293
push id24322
push userdbaron@mozilla.com
push dateMon, 18 Feb 2013 08:55:11 +0000
treeherdermozilla-central@0acbd06d48a9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku
bugs836655
milestone21.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 836655 - [Audio] Remove ChildID if there is no content channel playing in foreground and only send audio-channel-changed with normal when ChildID in the background has content channel in playing state. r=baku
dom/audiochannel/AudioChannelService.cpp
--- a/dom/audiochannel/AudioChannelService.cpp
+++ b/dom/audiochannel/AudioChannelService.cpp
@@ -130,16 +130,24 @@ AudioChannelService::UnregisterType(Audi
   // The array may contain multiple occurrence of this appId but
   // this should remove only the first one.
   AudioChannelInternalType type = GetInternalType(aType, aElementHidden);
   mChannelCounters[type].RemoveElement(aChildID);
 
   // In order to avoid race conditions, it's safer to notify any existing
   // agent any time a new one is registered.
   if (XRE_GetProcessType() == GeckoProcessType_Default) {
+    // We only remove ChildID when it is in the foreground.
+    // If in the background, we kept ChildID for allowing it to play next song.
+    if (aType == AUDIO_CHANNEL_CONTENT &&
+        mActiveContentChildIDs.Contains(aChildID) &&
+        (!mActiveContentChildIDsFrozen &&
+          mChannelCounters[AUDIO_CHANNEL_INT_CONTENT].IndexOf(aChildID) == -1)) {
+      mActiveContentChildIDs.RemoveElement(aChildID);
+    }
     SendAudioChannelChangedNotification();
     Notify();
   }
 }
 
 bool
 AudioChannelService::GetMuted(AudioChannelAgent* aAgent, bool aElementHidden)
 {
@@ -286,18 +294,22 @@ AudioChannelService::SendAudioChannelCha
     else if (!mChannelCounters[AUDIO_CHANNEL_INT_ALARM_HIDDEN].IsEmpty()) {
       higher = AUDIO_CHANNEL_ALARM;
     }
 
     else if (!mChannelCounters[AUDIO_CHANNEL_INT_NOTIFICATION_HIDDEN].IsEmpty()) {
       higher = AUDIO_CHANNEL_NOTIFICATION;
     }
 
-    // Content channels play in background if just one is active.
-    else if (!mActiveContentChildIDs.IsEmpty()) {
+    // There is only one Child can play content channel in the background.
+    // And need to check whether there is any content channels under playing
+    // now.
+    else if (!mActiveContentChildIDs.IsEmpty() &&
+             mChannelCounters[AUDIO_CHANNEL_INT_CONTENT_HIDDEN].IndexOf(
+             mActiveContentChildIDs[0]) != -1) {
       higher = AUDIO_CHANNEL_CONTENT;
     }
   }
 
   if (higher != mCurrentHigherChannel) {
     mCurrentHigherChannel = higher;
 
     nsString channelName;