Bug 1576836 - Let audio elements end when a MediaStream becomes inaudible. r=jib

Depends on D43628

Differential Revision: https://phabricator.services.mozilla.com/D43629
This commit is contained in:
Andreas Pehrson
2019-08-31 00:13:42 +00:00
parent 17cf784eca
commit 99042f2f36
3 changed files with 123 additions and 12 deletions

View File

@@ -4720,10 +4720,8 @@ class HTMLMediaElement::MediaStreamTrackListener
mElement->NotifyMediaStreamTrackRemoved(aTrack);
}
void NotifyActive() override {
if (!mElement) {
return;
}
void OnActive() {
MOZ_ASSERT(mElement);
// mediacapture-main says:
// Note that once ended equals true the HTMLVideoElement will not play media
@@ -4756,20 +4754,70 @@ class HTMLMediaElement::MediaStreamTrackListener
mElement->DoLoad();
}
void NotifyInactive() override {
void NotifyActive() override {
if (!mElement) {
return;
}
if (!mElement->IsVideo()) {
// Audio elements use NotifyAudible().
return;
}
OnActive();
}
void NotifyAudible() override {
if (!mElement) {
return;
}
if (mElement->IsVideo()) {
// Video elements use NotifyActive().
return;
}
OnActive();
}
void OnInactive() {
MOZ_ASSERT(mElement);
if (mElement->IsPlaybackEnded()) {
return;
}
LOG(LogLevel::Debug, ("%p, mSrcStream %p became inactive", mElement.get(),
mElement->mSrcStream.get()));
MOZ_ASSERT(!mElement->mSrcStream->Active());
mElement->PlaybackEnded();
mElement->UpdateReadyStateInternal();
}
void NotifyInactive() override {
if (!mElement) {
return;
}
if (!mElement->IsVideo()) {
// Audio elements use NotifyInaudible().
return;
}
OnInactive();
}
void NotifyInaudible() override {
if (!mElement) {
return;
}
if (mElement->IsVideo()) {
// Video elements use NotifyInactive().
return;
}
OnInactive();
}
protected:
const WeakPtr<HTMLMediaElement> mElement;
};