Bug 1309162 - part3 : modify the place calling UpdateAudioChannelPlayingState(). r=baku

UpdateAudioChannelPlayingState() should only be called when following attributes changed.
eg. pause/ready state/error/owner document's visibility/exteral source stream.

Therefore, we don't need to call this function in FinishDecoderSetup() and AddRemoveSelfReference().

Remove AutoNotifyAudioChannelAgent is because now we don't check HasAudio() for IsPlayingThroughTheAudioChannel().

MozReview-Commit-ID: 4VTHIAdAqX1

--HG--
extra : rebase_source : 7f196581fb2e5a7e75afef27d874522986d2cdc5
This commit is contained in:
Alastor Wu 2016-11-26 02:34:49 +08:00
Родитель 59b85ce47d
Коммит 202cfad46d
2 изменённых файлов: 0 добавлений и 29 удалений

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

@ -123,24 +123,6 @@ static mozilla::LazyLogModule gMediaElementEventsLog("nsMediaElementEvents");
using namespace mozilla::layers;
using mozilla::net::nsMediaFragmentURIParser;
class MOZ_STACK_CLASS AutoNotifyAudioChannelAgent
{
RefPtr<mozilla::dom::HTMLMediaElement> mElement;
MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER;
public:
explicit AutoNotifyAudioChannelAgent(mozilla::dom::HTMLMediaElement* aElement
MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
: mElement(aElement)
{
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
}
~AutoNotifyAudioChannelAgent()
{
mElement->UpdateAudioChannelPlayingState();
}
};
namespace mozilla {
namespace dom {
@ -4441,7 +4423,6 @@ nsresult HTMLMediaElement::FinishDecoderSetup(MediaDecoder* aDecoder,
// We may want to suspend the new stream now.
// This will also do an AddRemoveSelfReference.
NotifyOwnerDocumentActivityChanged();
UpdateAudioChannelPlayingState();
if (!mPaused) {
SetPlayedOrSeeked(true);
@ -4875,11 +4856,6 @@ void HTMLMediaElement::MetadataLoaded(const MediaInfo* aInfo,
{
MOZ_ASSERT(NS_IsMainThread());
// If the element is gaining or losing an audio track, we need to notify
// the audio channel agent so that the correct audio-playback events will
// get dispatched.
AutoNotifyAudioChannelAgent autoNotify(this);
SetMediaInfo(*aInfo);
mIsEncrypted = aInfo->IsEncrypted() || mPendingEncryptedInitData.IsEncrypted();
@ -5946,8 +5922,6 @@ void HTMLMediaElement::AddRemoveSelfReference()
NS_DispatchToMainThread(event);
}
}
UpdateAudioChannelPlayingState();
}
void HTMLMediaElement::DoRemoveSelfReference()

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

@ -58,7 +58,6 @@ class VideoStreamTrack;
} // namespace dom
} // namespace mozilla
class AutoNotifyAudioChannelAgent;
class nsIChannel;
class nsIHttpChannel;
class nsILoadGroup;
@ -84,8 +83,6 @@ class HTMLMediaElement : public nsGenericHTMLElement,
public PrincipalChangeObserver<DOMMediaStream>,
public SupportsWeakPtr<HTMLMediaElement>
{
friend AutoNotifyAudioChannelAgent;
public:
typedef mozilla::TimeStamp TimeStamp;
typedef mozilla::layers::ImageContainer ImageContainer;