From 1a4414416bd6d8e83bdb119e49ccaf0c167bd4a5 Mon Sep 17 00:00:00 2001 From: Marco Chen Date: Mon, 17 Feb 2014 18:58:12 +0800 Subject: [PATCH] Bug 968921 - "audio-channel-change" event should consider the audio channels in the background even there is an one on the foreground. r=baku --- dom/audiochannel/AudioChannelService.cpp | 39 +++++++++--------------- 1 file changed, 14 insertions(+), 25 deletions(-) diff --git a/dom/audiochannel/AudioChannelService.cpp b/dom/audiochannel/AudioChannelService.cpp index 855499eea94..42d6ea0dbf3 100644 --- a/dom/audiochannel/AudioChannelService.cpp +++ b/dom/audiochannel/AudioChannelService.cpp @@ -448,7 +448,7 @@ AudioChannelService::SendAudioChannelChangedNotification(uint64_t aChildID) } // Calculating the most important active channel. - AudioChannelType higher = AUDIO_CHANNEL_LAST; + AudioChannelType higher = AUDIO_CHANNEL_DEFAULT; // Top-Down in the hierarchy for visible elements if (!mChannelCounters[AUDIO_CHANNEL_INT_PUBLICNOTIFICATION].IsEmpty()) { @@ -482,30 +482,19 @@ AudioChannelService::SendAudioChannelChangedNotification(uint64_t aChildID) AudioChannelType visibleHigher = higher; // Top-Down in the hierarchy for non-visible elements - if (higher == AUDIO_CHANNEL_LAST) { - if (!mChannelCounters[AUDIO_CHANNEL_INT_PUBLICNOTIFICATION_HIDDEN].IsEmpty()) { - higher = AUDIO_CHANNEL_PUBLICNOTIFICATION; + // And we can ignore normal channel because it can't play in the background. + for (int i = AUDIO_CHANNEL_LAST - 1; + i > higher && i > AUDIO_CHANNEL_NORMAL; i--) { + if (i == AUDIO_CHANNEL_CONTENT && + mPlayableHiddenContentChildID != CONTENT_PROCESS_ID_UNKNOWN) { + higher = static_cast(i); } - else if (!mChannelCounters[AUDIO_CHANNEL_INT_RINGER_HIDDEN].IsEmpty()) { - higher = AUDIO_CHANNEL_RINGER; - } - - else if (!mChannelCounters[AUDIO_CHANNEL_INT_TELEPHONY_HIDDEN].IsEmpty()) { - higher = AUDIO_CHANNEL_TELEPHONY; - } - - 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; - } - - // Check whether there is any playable hidden content channel or not. - else if (mPlayableHiddenContentChildID != CONTENT_PROCESS_ID_UNKNOWN) { - higher = AUDIO_CHANNEL_CONTENT; + // Each channel type will be split to fg and bg for recording the state, + // so here need to do a translation. + if (!mChannelCounters[i * 2 + 1].IsEmpty()) { + higher = static_cast(i); + break; } } @@ -513,7 +502,7 @@ AudioChannelService::SendAudioChannelChangedNotification(uint64_t aChildID) mCurrentHigherChannel = higher; nsString channelName; - if (mCurrentHigherChannel != AUDIO_CHANNEL_LAST) { + if (mCurrentHigherChannel != AUDIO_CHANNEL_DEFAULT) { channelName.AssignASCII(ChannelName(mCurrentHigherChannel)); } else { channelName.AssignLiteral("none"); @@ -528,7 +517,7 @@ AudioChannelService::SendAudioChannelChangedNotification(uint64_t aChildID) mCurrentVisibleHigherChannel = visibleHigher; nsString channelName; - if (mCurrentVisibleHigherChannel != AUDIO_CHANNEL_LAST) { + if (mCurrentVisibleHigherChannel != AUDIO_CHANNEL_DEFAULT) { channelName.AssignASCII(ChannelName(mCurrentVisibleHigherChannel)); } else { channelName.AssignLiteral("none");