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
Родитель 620bc5078d
Коммит 865c10599b
1 изменённых файлов: 14 добавлений и 25 удалений

Просмотреть файл

@ -448,7 +448,7 @@ AudioChannelService::SendAudioChannelChangedNotification(uint64_t aChildID)
} }
// Calculating the most important active channel. // Calculating the most important active channel.
AudioChannelType higher = AUDIO_CHANNEL_LAST; AudioChannelType higher = AUDIO_CHANNEL_DEFAULT;
// Top-Down in the hierarchy for visible elements // Top-Down in the hierarchy for visible elements
if (!mChannelCounters[AUDIO_CHANNEL_INT_PUBLICNOTIFICATION].IsEmpty()) { if (!mChannelCounters[AUDIO_CHANNEL_INT_PUBLICNOTIFICATION].IsEmpty()) {
@ -482,30 +482,19 @@ AudioChannelService::SendAudioChannelChangedNotification(uint64_t aChildID)
AudioChannelType visibleHigher = higher; AudioChannelType visibleHigher = higher;
// Top-Down in the hierarchy for non-visible elements // Top-Down in the hierarchy for non-visible elements
if (higher == AUDIO_CHANNEL_LAST) { // And we can ignore normal channel because it can't play in the background.
if (!mChannelCounters[AUDIO_CHANNEL_INT_PUBLICNOTIFICATION_HIDDEN].IsEmpty()) { for (int i = AUDIO_CHANNEL_LAST - 1;
higher = AUDIO_CHANNEL_PUBLICNOTIFICATION; 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()) { // Each channel type will be split to fg and bg for recording the state,
higher = AUDIO_CHANNEL_RINGER; // so here need to do a translation.
} if (!mChannelCounters[i * 2 + 1].IsEmpty()) {
higher = static_cast<AudioChannelType>(i);
else if (!mChannelCounters[AUDIO_CHANNEL_INT_TELEPHONY_HIDDEN].IsEmpty()) { break;
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;
} }
} }
@ -513,7 +502,7 @@ AudioChannelService::SendAudioChannelChangedNotification(uint64_t aChildID)
mCurrentHigherChannel = higher; mCurrentHigherChannel = higher;
nsString channelName; nsString channelName;
if (mCurrentHigherChannel != AUDIO_CHANNEL_LAST) { if (mCurrentHigherChannel != AUDIO_CHANNEL_DEFAULT) {
channelName.AssignASCII(ChannelName(mCurrentHigherChannel)); channelName.AssignASCII(ChannelName(mCurrentHigherChannel));
} else { } else {
channelName.AssignLiteral("none"); channelName.AssignLiteral("none");
@ -528,7 +517,7 @@ AudioChannelService::SendAudioChannelChangedNotification(uint64_t aChildID)
mCurrentVisibleHigherChannel = visibleHigher; mCurrentVisibleHigherChannel = visibleHigher;
nsString channelName; nsString channelName;
if (mCurrentVisibleHigherChannel != AUDIO_CHANNEL_LAST) { if (mCurrentVisibleHigherChannel != AUDIO_CHANNEL_DEFAULT) {
channelName.AssignASCII(ChannelName(mCurrentVisibleHigherChannel)); channelName.AssignASCII(ChannelName(mCurrentVisibleHigherChannel));
} else { } else {
channelName.AssignLiteral("none"); channelName.AssignLiteral("none");