зеркало из https://github.com/mozilla/gecko-dev.git
Bug 832665 - Switching back and forth between the music app and FM radio (using home key) causes some unexpected behavior., r=mchen, a=tef+
This commit is contained in:
Родитель
7799c058c4
Коммит
d5dbd9640b
|
@ -67,6 +67,7 @@ NS_IMPL_ISUPPORTS0(AudioChannelService)
|
||||||
|
|
||||||
AudioChannelService::AudioChannelService()
|
AudioChannelService::AudioChannelService()
|
||||||
: mCurrentHigherChannel(AUDIO_CHANNEL_LAST)
|
: mCurrentHigherChannel(AUDIO_CHANNEL_LAST)
|
||||||
|
, mActiveContentChildIDsFrozen(false)
|
||||||
{
|
{
|
||||||
// Creation of the hash table.
|
// Creation of the hash table.
|
||||||
mAgents.Init();
|
mAgents.Init();
|
||||||
|
@ -169,6 +170,27 @@ AudioChannelService::GetMutedInternal(AudioChannelType aType, uint64_t aChildID,
|
||||||
mChannelCounters[oldType].RemoveElement(aChildID);
|
mChannelCounters[oldType].RemoveElement(aChildID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If the audio content channel is visible, let's remember this ChildID.
|
||||||
|
if (newType == AUDIO_CHANNEL_INT_CONTENT &&
|
||||||
|
oldType == AUDIO_CHANNEL_INT_CONTENT_HIDDEN &&
|
||||||
|
!mActiveContentChildIDs.Contains(aChildID)) {
|
||||||
|
|
||||||
|
if (mActiveContentChildIDsFrozen) {
|
||||||
|
mActiveContentChildIDsFrozen = false;
|
||||||
|
mActiveContentChildIDs.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
mActiveContentChildIDs.AppendElement(aChildID);
|
||||||
|
}
|
||||||
|
|
||||||
|
// If nothing is visible, the list has to been frozen.
|
||||||
|
else if (newType == AUDIO_CHANNEL_INT_CONTENT_HIDDEN &&
|
||||||
|
oldType == AUDIO_CHANNEL_INT_CONTENT &&
|
||||||
|
!mActiveContentChildIDsFrozen &&
|
||||||
|
mChannelCounters[AUDIO_CHANNEL_INT_CONTENT].IsEmpty()) {
|
||||||
|
mActiveContentChildIDsFrozen = true;
|
||||||
|
}
|
||||||
|
|
||||||
// Let play any visible audio channel.
|
// Let play any visible audio channel.
|
||||||
if (!aElementHidden) {
|
if (!aElementHidden) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -179,8 +201,7 @@ AudioChannelService::GetMutedInternal(AudioChannelType aType, uint64_t aChildID,
|
||||||
// We are not visible, maybe we have to mute.
|
// We are not visible, maybe we have to mute.
|
||||||
if (newType == AUDIO_CHANNEL_INT_NORMAL_HIDDEN ||
|
if (newType == AUDIO_CHANNEL_INT_NORMAL_HIDDEN ||
|
||||||
(newType == AUDIO_CHANNEL_INT_CONTENT_HIDDEN &&
|
(newType == AUDIO_CHANNEL_INT_CONTENT_HIDDEN &&
|
||||||
(!mChannelCounters[AUDIO_CHANNEL_INT_CONTENT].IsEmpty() ||
|
!mActiveContentChildIDs.Contains(aChildID))) {
|
||||||
HasMoreThanOneContentChannelHidden()))) {
|
|
||||||
muted = true;
|
muted = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -199,25 +220,6 @@ AudioChannelService::ContentChannelIsActive()
|
||||||
!mChannelCounters[AUDIO_CHANNEL_INT_CONTENT_HIDDEN].IsEmpty();
|
!mChannelCounters[AUDIO_CHANNEL_INT_CONTENT_HIDDEN].IsEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
|
||||||
AudioChannelService::HasMoreThanOneContentChannelHidden()
|
|
||||||
{
|
|
||||||
uint32_t childId = CONTENT_PARENT_UNKNOWN_CHILD_ID;
|
|
||||||
bool empty = true;
|
|
||||||
for (uint32_t i = 0;
|
|
||||||
i < mChannelCounters[AUDIO_CHANNEL_INT_CONTENT_HIDDEN].Length();
|
|
||||||
++i) {
|
|
||||||
if (empty) {
|
|
||||||
childId = mChannelCounters[AUDIO_CHANNEL_INT_CONTENT_HIDDEN][i];
|
|
||||||
empty = false;
|
|
||||||
} else if (childId != mChannelCounters[AUDIO_CHANNEL_INT_CONTENT_HIDDEN][i]) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
AudioChannelService::SendAudioChannelChangedNotification()
|
AudioChannelService::SendAudioChannelChangedNotification()
|
||||||
{
|
{
|
||||||
|
@ -279,8 +281,7 @@ AudioChannelService::SendAudioChannelChangedNotification()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Content channels play in background if just one is active.
|
// Content channels play in background if just one is active.
|
||||||
else if ((!mChannelCounters[AUDIO_CHANNEL_INT_CONTENT_HIDDEN].IsEmpty() &&
|
else if (!mActiveContentChildIDs.IsEmpty()) {
|
||||||
!HasMoreThanOneContentChannelHidden())) {
|
|
||||||
higher = AUDIO_CHANNEL_CONTENT;
|
higher = AUDIO_CHANNEL_CONTENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -391,6 +392,10 @@ AudioChannelService::Observe(nsISupports* aSubject, const char* aTopic, const PR
|
||||||
while ((index = mChannelCounters[type].IndexOf(childID)) != -1) {
|
while ((index = mChannelCounters[type].IndexOf(childID)) != -1) {
|
||||||
mChannelCounters[type].RemoveElementAt(index);
|
mChannelCounters[type].RemoveElementAt(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((index = mActiveContentChildIDs.IndexOf(childID)) != -1) {
|
||||||
|
mActiveContentChildIDs.RemoveElementAt(index);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// We don't have to remove the agents from the mAgents hashtable because if
|
// We don't have to remove the agents from the mAgents hashtable because if
|
||||||
|
|
|
@ -98,8 +98,6 @@ protected:
|
||||||
|
|
||||||
bool ChannelsActiveWithHigherPriorityThan(AudioChannelInternalType aType);
|
bool ChannelsActiveWithHigherPriorityThan(AudioChannelInternalType aType);
|
||||||
|
|
||||||
bool HasMoreThanOneContentChannelHidden();
|
|
||||||
|
|
||||||
const char* ChannelName(AudioChannelType aType);
|
const char* ChannelName(AudioChannelType aType);
|
||||||
|
|
||||||
AudioChannelInternalType GetInternalType(AudioChannelType aType,
|
AudioChannelInternalType GetInternalType(AudioChannelType aType,
|
||||||
|
@ -130,6 +128,9 @@ protected:
|
||||||
|
|
||||||
AudioChannelType mCurrentHigherChannel;
|
AudioChannelType mCurrentHigherChannel;
|
||||||
|
|
||||||
|
nsTArray<uint64_t> mActiveContentChildIDs;
|
||||||
|
bool mActiveContentChildIDsFrozen;
|
||||||
|
|
||||||
// This is needed for IPC comunication between
|
// This is needed for IPC comunication between
|
||||||
// AudioChannelServiceChild and this class.
|
// AudioChannelServiceChild and this class.
|
||||||
friend class ContentParent;
|
friend class ContentParent;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче