Backed out 3 changesets (bug 1348803) for failures in audio and playback browser-chrome tests

CLOSED TREE

Backed out changeset 4ac559eea9ec (bug 1348803)
Backed out changeset 2ab6e0b8aec6 (bug 1348803)
Backed out changeset f966aef934b1 (bug 1348803)
This commit is contained in:
Phil Ringnalda 2017-03-27 21:47:02 -07:00
Родитель fb622b0334
Коммит e7905e8e6d
4 изменённых файлов: 37 добавлений и 56 удалений

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

@ -56,13 +56,13 @@ public class AudioFocusAgent {
switch (focusChange) {
case AudioManager.AUDIOFOCUS_LOSS:
Log.d(LOGTAG, "onAudioFocusChange, AUDIOFOCUS_LOSS");
notifyObservers("audioFocusChanged", "lostAudioFocus");
notifyObservers("AudioFocusChanged", "lostAudioFocus");
notifyMediaControlService(MediaControlService.ACTION_PAUSE_BY_AUDIO_FOCUS);
mAudioFocusState = LOST_FOCUS;
break;
case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT:
Log.d(LOGTAG, "onAudioFocusChange, AUDIOFOCUS_LOSS_TRANSIENT");
notifyObservers("audioFocusChanged", "lostAudioFocusTransiently");
notifyObservers("AudioFocusChanged", "lostAudioFocusTransiently");
notifyMediaControlService(MediaControlService.ACTION_PAUSE_BY_AUDIO_FOCUS);
mAudioFocusState = LOST_FOCUS_TRANSIENT;
break;
@ -77,7 +77,7 @@ public class AudioFocusAgent {
notifyMediaControlService(MediaControlService.ACTION_STOP_AUDIO_DUCK);
} else if (mAudioFocusState.equals(LOST_FOCUS_TRANSIENT)) {
Log.d(LOGTAG, "onAudioFocusChange, AUDIOFOCUS_GAIN");
notifyObservers("audioFocusChanged", "gainAudioFocus");
notifyObservers("AudioFocusChanged", "gainAudioFocus");
notifyMediaControlService(MediaControlService.ACTION_RESUME_BY_AUDIO_FOCUS);
}
mAudioFocusState = OWN_FOCUS;

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

@ -312,7 +312,7 @@ public class MediaControlService extends Service implements Tabs.OnTabsChangedLi
Log.d(LOGTAG, "Controller, onPlay");
super.onPlay();
setState(State.PLAYING);
notifyObservers("mediaControl", "resumeMedia");
notifyObservers("MediaControl", "resumeMedia");
}
@Override
@ -320,7 +320,7 @@ public class MediaControlService extends Service implements Tabs.OnTabsChangedLi
Log.d(LOGTAG, "Controller, onPause");
super.onPause();
setState(State.PAUSED);
notifyObservers("mediaControl", "mediaControlPaused");
notifyObservers("MediaControl", "mediaControlPaused");
}
@Override
@ -328,7 +328,7 @@ public class MediaControlService extends Service implements Tabs.OnTabsChangedLi
Log.d(LOGTAG, "Controller, onStop");
super.onStop();
setState(State.STOPPED);
notifyObservers("mediaControl", "mediaControlStopped");
notifyObservers("MediaControl", "mediaControlStopped");
mTabReference = new WeakReference<>(null);
}
});

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

@ -3636,9 +3636,9 @@ Tab.prototype = {
this.browser.addEventListener("VideoBindingAttached", this, true, true);
this.browser.addEventListener("VideoBindingCast", this, true, true);
Services.obs.addObserver(this, "audioFocusChanged", false);
Services.obs.addObserver(this, "before-first-paint", false);
Services.obs.addObserver(this, "media-playback", false);
Services.obs.addObserver(this, "media-playback-resumed", false);
// Always initialise new tabs with basic session store data to avoid
// problems with functions that always expect it to be present
@ -3751,9 +3751,9 @@ Tab.prototype = {
this.browser.removeEventListener("VideoBindingAttached", this, true, true);
this.browser.removeEventListener("VideoBindingCast", this, true, true);
Services.obs.removeObserver(this, "audioFocusChanged");
Services.obs.removeObserver(this, "before-first-paint");
Services.obs.removeObserver(this, "media-playback");
Services.obs.removeObserver(this, "media-playback-resumed");
// Make sure the previously selected panel remains selected. The selected panel of a deck is
// not stable when panels are removed.
@ -4568,21 +4568,6 @@ Tab.prototype = {
Services.obs.notifyObservers(this.browser, "Content:HistoryChange", null);
},
UpdateMediaPlaybackRelatedObserver: function(active) {
// Media control is only used for the tab which has playing media, so we
// only need to register observer after having the active media. And the
// "media-playback-resumed" is sent when user resume paused media from
// page, it notifies us that we should change the icon and content in media
// control interface.
if (active) {
Services.obs.addObserver(this, "mediaControl", false);
Services.obs.addObserver(this, "media-playback-resumed", false);
} else {
Services.obs.removeObserver(this, "mediaControl");
Services.obs.removeObserver(this, "media-playback-resumed");
}
},
ShouldNotifyMediaPlaybackChange: function(activeState) {
// If the media is active, we would check it's duration, because we don't
// want to show the media control interface for the short sound which
@ -4645,9 +4630,7 @@ Tab.prototype = {
let status;
if (aTopic == "media-playback") {
let isActive = !(aData === "inactive");
status = isActive ? "start" : "end";
this.UpdateMediaPlaybackRelatedObserver(isActive);
status = (aData === "inactive") ? "end" : "start";
} else if (aTopic == "media-playback-resumed") {
status = "resume";
}
@ -4658,36 +4641,6 @@ Tab.prototype = {
status: status
});
break;
case "audioFocusChanged":
case "mediaControl":
let win = this.browser.contentWindow;
let utils = win.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
let suspendTypes = Ci.nsISuspendedTypes;
switch (aData) {
case "lostAudioFocus":
utils.mediaSuspend = suspendTypes.SUSPENDED_PAUSE_DISPOSABLE;
break;
case "lostAudioFocusTransiently":
utils.mediaSuspend = suspendTypes.SUSPENDED_PAUSE;
break;
case "gainAudioFocus":
utils.mediaSuspend = suspendTypes.NONE_SUSPENDED;
break;
case "mediaControlPaused":
utils.mediaSuspend = suspendTypes.SUSPENDED_PAUSE_DISPOSABLE;
break;
case "mediaControlStopped":
utils.mediaSuspend = suspendTypes.SUSPENDED_STOP_DISPOSABLE;
break;
case "resumeMedia":
utils.mediaSuspend = suspendTypes.NONE_SUSPENDED;
break;
default:
dump("Error : wrong media control msg!\n");
break;
}
break;
}
},

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

@ -971,6 +971,8 @@ var AudioPlaybackListener = {
init() {
Services.obs.addObserver(this, "audio-playback", false);
Services.obs.addObserver(this, "AudioFocusChanged", false);
Services.obs.addObserver(this, "MediaControl", false);
addMessageListener("AudioPlayback", this);
addEventListener("unload", () => {
@ -980,6 +982,8 @@ var AudioPlaybackListener = {
uninit() {
Services.obs.removeObserver(this, "audio-playback");
Services.obs.removeObserver(this, "AudioFocusChanged");
Services.obs.removeObserver(this, "MediaControl");
removeMessageListener("AudioPlayback", this);
},
@ -987,6 +991,7 @@ var AudioPlaybackListener = {
handleMediaControlMessage(msg) {
let utils = global.content.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils);
let suspendTypes = Ci.nsISuspendedTypes;
switch (msg) {
case "mute":
utils.audioMuted = true;
@ -994,6 +999,27 @@ var AudioPlaybackListener = {
case "unmute":
utils.audioMuted = false;
break;
case "lostAudioFocus":
utils.mediaSuspend = suspendTypes.SUSPENDED_PAUSE_DISPOSABLE;
break;
case "lostAudioFocusTransiently":
utils.mediaSuspend = suspendTypes.SUSPENDED_PAUSE;
break;
case "gainAudioFocus":
utils.mediaSuspend = suspendTypes.NONE_SUSPENDED;
break;
case "mediaControlPaused":
utils.mediaSuspend = suspendTypes.SUSPENDED_PAUSE_DISPOSABLE;
break;
case "mediaControlStopped":
utils.mediaSuspend = suspendTypes.SUSPENDED_STOP_DISPOSABLE;
break;
case "blockInactivePageMedia":
utils.mediaSuspend = suspendTypes.SUSPENDED_BLOCK;
break;
case "resumeMedia":
utils.mediaSuspend = suspendTypes.NONE_SUSPENDED;
break;
default:
dump("Error : wrong media control msg!\n");
break;
@ -1013,6 +1039,8 @@ var AudioPlaybackListener = {
}
sendAsyncMessage(name);
}
} else if (topic == "AudioFocusChanged" || topic == "MediaControl") {
this.handleMediaControlMessage(data);
}
},