Bug 1579588 - part2 : create media controller for media element only. r=chunmin
We use `NotifyMediaStarted()` and `NotifyMediaStopped()` to notify `MediaControlService` on parent process to start/stop a media controller, and use `NotifyMediaAudibleChanged()` to notify controller's audible state in order to request audio focus. As our goal is to use media controller to control media element, not for web audio, web speech and other stuffs which also use audio channel agent. Therefore, we should notify parent process to start/stop controller only for media element, instead of sending a notification in AudioChannelService because that would create media controller for all different consumers which uses audio channel agent. Differential Revision: https://phabricator.services.mozilla.com/D45591
This commit is contained in:
@@ -139,10 +139,6 @@ bool IsEnableAudioCompetingForAllAgents() {
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
extern void NotifyMediaStarted(uint64_t aWindowID);
|
||||
extern void NotifyMediaStopped(uint64_t aWindowID);
|
||||
extern void NotifyMediaAudibleChanged(uint64_t aWindowID, bool aAudible);
|
||||
|
||||
const char* SuspendTypeToStr(const nsSuspendedTypes& aSuspend) {
|
||||
MOZ_ASSERT(aSuspend == nsISuspendedTypes::NONE_SUSPENDED ||
|
||||
aSuspend == nsISuspendedTypes::SUSPENDED_PAUSE ||
|
||||
@@ -774,7 +770,6 @@ void AudioChannelService::AudioChannelWindow::AppendAgentAndIncreaseAgentsNum(
|
||||
if (mConfig.mNumberOfAgents == 1) {
|
||||
NotifyChannelActive(aAgent->WindowID(), true);
|
||||
}
|
||||
NotifyMediaStarted(aAgent->WindowID());
|
||||
}
|
||||
|
||||
void AudioChannelService::AudioChannelWindow::RemoveAgentAndReduceAgentsNum(
|
||||
@@ -790,7 +785,6 @@ void AudioChannelService::AudioChannelWindow::RemoveAgentAndReduceAgentsNum(
|
||||
if (mConfig.mNumberOfAgents == 0) {
|
||||
NotifyChannelActive(aAgent->WindowID(), false);
|
||||
}
|
||||
NotifyMediaStopped(aAgent->WindowID());
|
||||
}
|
||||
|
||||
void AudioChannelService::AudioChannelWindow::AudioCapturedChanged(
|
||||
@@ -830,7 +824,6 @@ void AudioChannelService::AudioChannelWindow::AppendAudibleAgentIfNotContained(
|
||||
NotifyAudioAudibleChanged(aAgent->Window(), AudibleState::eAudible,
|
||||
aReason);
|
||||
}
|
||||
NotifyMediaAudibleChanged(aAgent->WindowID(), true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -844,7 +837,6 @@ void AudioChannelService::AudioChannelWindow::RemoveAudibleAgentIfContained(
|
||||
NotifyAudioAudibleChanged(aAgent->Window(), AudibleState::eNotAudible,
|
||||
aReason);
|
||||
}
|
||||
NotifyMediaAudibleChanged(aAgent->WindowID(), false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -147,6 +147,10 @@ using namespace mozilla::dom::HTMLMediaElement_Binding;
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
extern void NotifyMediaStarted(uint64_t aWindowID);
|
||||
extern void NotifyMediaStopped(uint64_t aWindowID);
|
||||
extern void NotifyMediaAudibleChanged(uint64_t aWindowID, bool aAudible);
|
||||
|
||||
// Number of milliseconds between progress events as defined by spec
|
||||
static const uint32_t PROGRESS_MS = 350;
|
||||
|
||||
@@ -1130,6 +1134,9 @@ class HTMLMediaElement::AudioChannelAgentCallback final
|
||||
|
||||
mIsOwnerAudible = newAudibleState;
|
||||
mAudioChannelAgent->NotifyStartedAudible(mIsOwnerAudible, aReason);
|
||||
NotifyMediaAudibleChanged(
|
||||
mAudioChannelAgent->WindowID(),
|
||||
mIsOwnerAudible == AudioChannelService::AudibleState::eAudible);
|
||||
}
|
||||
|
||||
bool IsPlaybackBlocked() {
|
||||
@@ -1199,6 +1206,7 @@ class HTMLMediaElement::AudioChannelAgentCallback final
|
||||
return;
|
||||
}
|
||||
|
||||
NotifyMediaStarted(mAudioChannelAgent->WindowID());
|
||||
WindowVolumeChanged(config.mVolume, config.mMuted);
|
||||
WindowSuspendChanged(config.mSuspend);
|
||||
}
|
||||
@@ -1207,6 +1215,7 @@ class HTMLMediaElement::AudioChannelAgentCallback final
|
||||
MOZ_ASSERT(mAudioChannelAgent);
|
||||
MOZ_ASSERT(mAudioChannelAgent->IsPlayingStarted());
|
||||
mAudioChannelAgent->NotifyStoppedPlaying();
|
||||
NotifyMediaStopped(mAudioChannelAgent->WindowID());
|
||||
}
|
||||
|
||||
void SetSuspended(SuspendTypes aSuspend) {
|
||||
@@ -2540,7 +2549,8 @@ void HTMLMediaElement::LoadFromSourceChildren() {
|
||||
|
||||
while (nextChild) {
|
||||
if (nextChild && nextChild->IsHTMLElement(nsGkAtoms::source)) {
|
||||
ReportLoadError("MediaLoadUnsupportedTypeAttributeLoadingNextChild", params);
|
||||
ReportLoadError("MediaLoadUnsupportedTypeAttributeLoadingNextChild",
|
||||
params);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user