Bug 1262053 - part5 : register audio agent immediately when media element starts playing. r=baku

In ancient degisn, we would only register audio channel after the media element has audio track and enoguh data to playback,
that is because the "audio-playback" event would be dispatched with the registration, and then shows the tab audio indicator.

However, now the event dispatching doesn't follow with the registration, it would be triggered when the media element has
really audible data which would be notified from media decoder.

Therefore, the media element without audio track or without enough data can also register audio channel agent, it won't affect
the display of tab audio indicator. The reason we need to do that is for blocking autoplay media in the non-visited tab.

The autoplay can be adding "autoplay" keyword or playing by the script, and we don't want to dispatch dom event for blocked
media. Therefore, we should register audio channel agent to know whether it needs to be blocked immediately even the media
element doesn't have any enough data which can let us to distinguish it have any audio track or not (this information can
be known from metadata).

First, we must check whether the media is blocked which is notified by audio channel agent, and then we can decide whether
need to dispatch the event. If we don't register audio channel agent, that we can't get blocking information.

MozReview-Commit-ID: HLLkOuecql1

--HG--
extra : rebase_source : 99c34f0185276ecd5b70ae09959b47c584d1564e
This commit is contained in:
Alastor Wu 2016-08-29 16:34:31 +08:00
parent 9021286e9a
commit 47079de3ad

View File

@ -5765,11 +5765,6 @@ HTMLMediaElement::IsPlayingThroughTheAudioChannel() const
return false;
}
// If this element doesn't have any audio tracks.
if (!HasAudio()) {
return false;
}
// We should consider any bfcached page or inactive document as non-playing.
if (!IsActive()) {
return false;
@ -5780,11 +5775,6 @@ HTMLMediaElement::IsPlayingThroughTheAudioChannel() const
return true;
}
// If we are actually playing...
if (IsCurrentlyPlaying()) {
return true;
}
// If we are seeking, we consider it as playing
if (mPlayingThroughTheAudioChannelBeforeSeek) {
return true;
@ -5795,7 +5785,7 @@ HTMLMediaElement::IsPlayingThroughTheAudioChannel() const
return true;
}
return false;
return true;
}
void
@ -6256,7 +6246,6 @@ HTMLMediaElement::CannotDecryptWaitingForKey()
NS_IMETHODIMP HTMLMediaElement::WindowAudioCaptureChanged(bool aCapture)
{
MOZ_ASSERT(mAudioChannelAgent);
MOZ_ASSERT(HasAudio());
if (!OwnerDoc()->GetInnerWindow()) {
return NS_OK;