Skip to content

Commit

Permalink
Bug 1322505 - part2 : reset suspend type for blocked media after call…
Browse files Browse the repository at this point in the history
…ing media.pause(). r=baku

If the blocked media is paused before resuming it, we should not resume it again
after the tab is visible. The way to achieve that is to unregister the agent so
AudioChannelService can't resume that media because we have disconnected their
relationship.

MozReview-Commit-ID: 6Dq4K9hVsU0

--HG--
extra : rebase_source : 740f38a63ad02852fe914a781d09ff9e45eb5cea
  • Loading branch information
alastor0325 committed Jan 23, 2017
1 parent 6968ad6 commit 07ed095
Showing 1 changed file with 26 additions and 7 deletions.
33 changes: 26 additions & 7 deletions dom/html/HTMLMediaElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -654,15 +654,32 @@ class HTMLMediaElement::AudioChannelAgentCallback final :
}
}

bool
ShouldResetSuspend() const
{
// The disposable-pause should be clear after media starts playing.
if (!mOwner->Paused() &&
mSuspended == nsISuspendedTypes::SUSPENDED_PAUSE_DISPOSABLE) {
return true;
}

// If the blocked media is paused, we don't need to resume it. We reset the
// mSuspended in order to unregister the agent.
if (mOwner->Paused() &&
mSuspended == nsISuspendedTypes::SUSPENDED_BLOCK) {
return true;
}

return false;
}

void
NotifyPlayStateChanged()
{
MOZ_ASSERT(!mIsShutDown);
// When owner's play state changed, we should reset the suspend type. If
// owner is playing, the suspend type should be 'NONE_SUSPENDED', and if
// owner paused, the suspend type also needs to be reset because the agent
// maybe need to be unregistered.
SetSuspended(nsISuspendedTypes::NONE_SUSPENDED);
if (ShouldResetSuspend()) {
SetSuspended(nsISuspendedTypes::NONE_SUSPENDED);
}
UpdateAudioChannelPlayingState();
}

Expand Down Expand Up @@ -881,7 +898,7 @@ class HTMLMediaElement::AudioChannelAgentCallback final :
if (!IsSuspended()) {
MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug,
("HTMLMediaElement::AudioChannelAgentCallback, ResumeFromAudioChannel, "
"this = %p, Error : resume without suspended!\n", this));
"this = %p, don't need to be resumed!\n", this));
return;
}

Expand Down Expand Up @@ -2758,7 +2775,9 @@ HTMLMediaElement::Pause(ErrorResult& aRv)
// We changed mPaused and mAutoplaying which can affect AddRemoveSelfReference
AddRemoveSelfReference();
UpdateSrcMediaStreamPlaying();
UpdateAudioChannelPlayingState();
if (mAudioChannelWrapper) {
mAudioChannelWrapper->NotifyPlayStateChanged();
}

if (!oldPaused) {
FireTimeUpdate(false);
Expand Down

0 comments on commit 07ed095

Please sign in to comment.