зеркало из https://github.com/mozilla/gecko-dev.git
Bug 828283 - Apps playing sound should not be muted when the screen is put to sleep., r=sicking
This commit is contained in:
Родитель
965c7d58cb
Коммит
3f200030f7
|
@ -398,6 +398,7 @@ var shell = {
|
|||
needBufferSysMsgs: true,
|
||||
bufferedSysMsgs: [],
|
||||
timer: null,
|
||||
visibleAudioActive: false,
|
||||
|
||||
handleEvent: function shell_handleEvent(evt) {
|
||||
let content = this.contentBrowser.contentWindow;
|
||||
|
@ -415,7 +416,7 @@ var shell = {
|
|||
Services.fm.focusedWindow = window;
|
||||
break;
|
||||
case 'sizemodechange':
|
||||
if (window.windowState == window.STATE_MINIMIZED) {
|
||||
if (window.windowState == window.STATE_MINIMIZED && !this.visibleAudioActive) {
|
||||
this.contentBrowser.setVisible(false);
|
||||
} else {
|
||||
this.contentBrowser.setVisible(true);
|
||||
|
@ -1052,6 +1053,16 @@ window.addEventListener('ContentStart', function update_onContentStart() {
|
|||
}, "audio-channel-changed", false);
|
||||
})();
|
||||
|
||||
(function visibleAudioChannelChangedTracker() {
|
||||
Services.obs.addObserver(function(aSubject, aTopic, aData) {
|
||||
shell.sendChromeEvent({
|
||||
type: 'visible-audio-channel-changed',
|
||||
channel: aData
|
||||
});
|
||||
shell.visibleAudioActive = (aData !== 'none');
|
||||
}, "visible-audio-channel-changed", false);
|
||||
})();
|
||||
|
||||
(function recordingStatusTracker() {
|
||||
let gRecordingActiveCount = 0;
|
||||
|
||||
|
|
|
@ -67,6 +67,7 @@ NS_IMPL_ISUPPORTS0(AudioChannelService)
|
|||
|
||||
AudioChannelService::AudioChannelService()
|
||||
: mCurrentHigherChannel(AUDIO_CHANNEL_LAST)
|
||||
, mCurrentVisibleHigherChannel(AUDIO_CHANNEL_LAST)
|
||||
, mActiveContentChildIDsFrozen(false)
|
||||
{
|
||||
// Creation of the hash table.
|
||||
|
@ -214,10 +215,11 @@ AudioChannelService::GetMutedInternal(AudioChannelType aType, uint64_t aChildID,
|
|||
}
|
||||
|
||||
bool
|
||||
AudioChannelService::ContentChannelIsActive()
|
||||
AudioChannelService::ContentOrNormalChannelIsActive()
|
||||
{
|
||||
return !mChannelCounters[AUDIO_CHANNEL_INT_CONTENT].IsEmpty() ||
|
||||
!mChannelCounters[AUDIO_CHANNEL_INT_CONTENT_HIDDEN].IsEmpty();
|
||||
!mChannelCounters[AUDIO_CHANNEL_INT_CONTENT_HIDDEN].IsEmpty() ||
|
||||
!mChannelCounters[AUDIO_CHANNEL_INT_NORMAL].IsEmpty();
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -259,30 +261,34 @@ AudioChannelService::SendAudioChannelChangedNotification()
|
|||
higher = AUDIO_CHANNEL_NORMAL;
|
||||
}
|
||||
|
||||
AudioChannelType visibleHigher = higher;
|
||||
|
||||
// Top-Down in the hierarchy for non-visible elements
|
||||
else if (!mChannelCounters[AUDIO_CHANNEL_INT_PUBLICNOTIFICATION_HIDDEN].IsEmpty()) {
|
||||
higher = AUDIO_CHANNEL_PUBLICNOTIFICATION;
|
||||
}
|
||||
if (higher == AUDIO_CHANNEL_LAST) {
|
||||
if (!mChannelCounters[AUDIO_CHANNEL_INT_PUBLICNOTIFICATION_HIDDEN].IsEmpty()) {
|
||||
higher = AUDIO_CHANNEL_PUBLICNOTIFICATION;
|
||||
}
|
||||
|
||||
else if (!mChannelCounters[AUDIO_CHANNEL_INT_RINGER_HIDDEN].IsEmpty()) {
|
||||
higher = AUDIO_CHANNEL_RINGER;
|
||||
}
|
||||
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_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_ALARM_HIDDEN].IsEmpty()) {
|
||||
higher = AUDIO_CHANNEL_ALARM;
|
||||
}
|
||||
|
||||
else if (!mChannelCounters[AUDIO_CHANNEL_INT_NOTIFICATION_HIDDEN].IsEmpty()) {
|
||||
higher = AUDIO_CHANNEL_NOTIFICATION;
|
||||
}
|
||||
else if (!mChannelCounters[AUDIO_CHANNEL_INT_NOTIFICATION_HIDDEN].IsEmpty()) {
|
||||
higher = AUDIO_CHANNEL_NOTIFICATION;
|
||||
}
|
||||
|
||||
// Content channels play in background if just one is active.
|
||||
else if (!mActiveContentChildIDs.IsEmpty()) {
|
||||
higher = AUDIO_CHANNEL_CONTENT;
|
||||
// Content channels play in background if just one is active.
|
||||
else if (!mActiveContentChildIDs.IsEmpty()) {
|
||||
higher = AUDIO_CHANNEL_CONTENT;
|
||||
}
|
||||
}
|
||||
|
||||
if (higher != mCurrentHigherChannel) {
|
||||
|
@ -298,6 +304,20 @@ AudioChannelService::SendAudioChannelChangedNotification()
|
|||
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
|
||||
obs->NotifyObservers(nullptr, "audio-channel-changed", channelName.get());
|
||||
}
|
||||
|
||||
if (visibleHigher != mCurrentVisibleHigherChannel) {
|
||||
mCurrentVisibleHigherChannel = visibleHigher;
|
||||
|
||||
nsString channelName;
|
||||
if (mCurrentVisibleHigherChannel != AUDIO_CHANNEL_LAST) {
|
||||
channelName.AssignASCII(ChannelName(mCurrentVisibleHigherChannel));
|
||||
} else {
|
||||
channelName.AssignLiteral("none");
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
|
||||
obs->NotifyObservers(nullptr, "visible-audio-channel-changed", channelName.get());
|
||||
}
|
||||
}
|
||||
|
||||
PLDHashOperator
|
||||
|
|
|
@ -57,7 +57,7 @@ public:
|
|||
* Return true if there is a content channel active in this process
|
||||
* or one of its subprocesses.
|
||||
*/
|
||||
virtual bool ContentChannelIsActive();
|
||||
virtual bool ContentOrNormalChannelIsActive();
|
||||
|
||||
protected:
|
||||
void Notify();
|
||||
|
@ -127,6 +127,7 @@ protected:
|
|||
nsTArray<uint64_t> mChannelCounters[AUDIO_CHANNEL_INT_LAST];
|
||||
|
||||
AudioChannelType mCurrentHigherChannel;
|
||||
AudioChannelType mCurrentVisibleHigherChannel;
|
||||
|
||||
nsTArray<uint64_t> mActiveContentChildIDs;
|
||||
bool mActiveContentChildIDsFrozen;
|
||||
|
|
|
@ -83,7 +83,7 @@ ProcessPriority
|
|||
GetBackgroundPriority()
|
||||
{
|
||||
AudioChannelService* service = AudioChannelService::GetAudioChannelService();
|
||||
if (service->ContentChannelIsActive()) {
|
||||
if (service->ContentOrNormalChannelIsActive()) {
|
||||
return PROCESS_PRIORITY_BACKGROUND_PERCEIVABLE;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче