Bug 968921 - "audio-channel-change" event should consider the audio channels in the background even there is an one on the foreground. r=baku

This commit is contained in:
Marco Chen 2014-02-17 18:58:12 +08:00
parent 4b1d68ea70
commit 87c19ce54e

View File

@ -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<AudioChannelType>(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<AudioChannelType>(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");