Bug 818708 - Content audio channels should be muted if in background when another content audio channel is playing. r=sicking
authorAndrea Marchesini <amarchesini@mozilla.com>
Thu, 03 Jan 2013 17:18:43 -0500
changeset 126615 8620caa05e5409da710b4bc1553a4ad4784f0581
parent 126614 81d17e61291ca2d6de778a50aadcb8a0f07dfbae
child 126616 c6d28aa6c3764834b4e9c24555c5d548d6a3bbe3
push id2151
push userlsblakk@mozilla.com
push dateTue, 19 Feb 2013 18:06:57 +0000
treeherdermozilla-beta@4952e88741ec [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssicking
bugs818708
milestone20.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 818708 - Content audio channels should be muted if in background when another content audio channel is playing. r=sicking
dom/audiochannel/AudioChannelService.cpp
--- a/dom/audiochannel/AudioChannelService.cpp
+++ b/dom/audiochannel/AudioChannelService.cpp
@@ -146,20 +146,33 @@ AudioChannelService::GetMuted(AudioChann
 {
   // We are not visible, maybe we have to mute:
   if (aElementHidden) {
     switch (aType) {
       case AUDIO_CHANNEL_NORMAL:
         return true;
 
       case AUDIO_CHANNEL_CONTENT:
-        // TODO: this should work per apps
-        if (mChannelCounters[AUDIO_CHANNEL_CONTENT].Length() > 1)
-          return true;
+      {
+        // If we have more than 1 using the content channel,
+        // this must be muted.
+        uint32_t childId = CONTENT_PARENT_UNKNOWN_CHILD_ID;
+        bool empty = true;
+        for (uint32_t i = 0;
+             i < mChannelCounters[AUDIO_CHANNEL_CONTENT].Length();
+             ++i) {
+          if (empty) {
+            childId = mChannelCounters[AUDIO_CHANNEL_CONTENT][i];
+            empty = false;
+          }
+          else if (childId != mChannelCounters[AUDIO_CHANNEL_CONTENT][i])
+            return true;
+        }
         break;
+      }
 
       case AUDIO_CHANNEL_NOTIFICATION:
       case AUDIO_CHANNEL_ALARM:
       case AUDIO_CHANNEL_TELEPHONY:
       case AUDIO_CHANNEL_RINGER:
       case AUDIO_CHANNEL_PUBLICNOTIFICATION:
         // Nothing to do
         break;