Bug 1172394 - Ignore video tracks in autoplay checks in MediaStreamAudioSourceNode. r=alwu
☠☠ backed out by 7272d77d4e80 ☠ ☠
authorAndreas Pehrson <apehrson@mozilla.com>
Wed, 13 Nov 2019 08:58:21 +0000
changeset 501793 d0aa43657e8cb3f06eafe5c537dc64ff1499a353
parent 501792 edff95b6f7242918c660bcf4ed0cc029b4e72906
child 501794 a4f256e68ceff48ff088715a51ff793d880cd6e9
push id114172
push userdluca@mozilla.com
push dateTue, 19 Nov 2019 11:31:10 +0000
treeherdermozilla-inbound@b5c5ba07d3db [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersalwu
bugs1172394
milestone72.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1172394 - Ignore video tracks in autoplay checks in MediaStreamAudioSourceNode. r=alwu Differential Revision: https://phabricator.services.mozilla.com/D52048
dom/media/DOMMediaStream.cpp
dom/media/DOMMediaStream.h
dom/media/webaudio/MediaStreamAudioSourceNode.cpp
dom/media/webaudio/MediaStreamAudioSourceNode.h
--- a/dom/media/DOMMediaStream.cpp
+++ b/dom/media/DOMMediaStream.cpp
@@ -368,16 +368,17 @@ already_AddRefed<DOMMediaStream> DOMMedi
     RefPtr<MediaStreamTrack> clone = track->Clone();
     newStream->AddTrack(*clone);
   }
 
   return newStream.forget();
 }
 
 bool DOMMediaStream::Active() const { return mActive; }
+bool DOMMediaStream::Audible() const { return mAudible; }
 
 MediaStreamTrack* DOMMediaStream::GetTrackById(const nsAString& aId) const {
   for (const auto& track : mTracks) {
     nsString id;
     track->GetId(id);
     if (id == aId) {
       return track;
     }
--- a/dom/media/DOMMediaStream.h
+++ b/dom/media/DOMMediaStream.h
@@ -139,16 +139,19 @@ class DOMMediaStream : public DOMEventTa
 
   bool Active() const;
 
   IMPL_EVENT_HANDLER(addtrack)
   IMPL_EVENT_HANDLER(removetrack)
 
   // NON-WebIDL
 
+  // Returns true if this stream contains a live audio track.
+  bool Audible() const;
+
   /**
    * Returns true if this DOMMediaStream has aTrack in mTracks.
    */
   bool HasTrack(const MediaStreamTrack& aTrack) const;
 
   /**
    * Returns a principal indicating who may access this stream. The stream
    * contents can only be accessed by principals subsuming this principal.
--- a/dom/media/webaudio/MediaStreamAudioSourceNode.cpp
+++ b/dom/media/webaudio/MediaStreamAudioSourceNode.cpp
@@ -71,18 +71,18 @@ void MediaStreamAudioSourceNode::Init(DO
   }
 
   mInputStream = aMediaStream;
   AudioNodeEngine* engine = new MediaStreamAudioSourceNodeEngine(this);
   mTrack = AudioNodeExternalInputTrack::Create(Context()->Graph(), engine);
   mInputStream->AddConsumerToKeepAlive(ToSupports(this));
 
   mInputStream->RegisterTrackListener(this);
-  if (mInputStream->Active()) {
-    NotifyActive();
+  if (mInputStream->Audible()) {
+    NotifyAudible();
   }
   AttachToRightTrack(mInputStream, aRv);
 }
 
 void MediaStreamAudioSourceNode::Destroy() {
   if (mInputStream) {
     mInputStream->UnregisterTrackListener(this);
     mInputStream = nullptr;
@@ -197,17 +197,17 @@ void MediaStreamAudioSourceNode::NotifyT
       return;
     }
 
     DetachFromTrack();
     AttachToRightTrack(mInputStream, IgnoreErrors());
   }
 }
 
-void MediaStreamAudioSourceNode::NotifyActive() {
+void MediaStreamAudioSourceNode::NotifyAudible() {
   MOZ_ASSERT(mInputStream);
   Context()->StartBlockedAudioContextIfAllowed();
 }
 
 /**
  * Changes the principal. Note that this will be called on the main thread, but
  * changes will be enacted on the MediaTrackGraph thread. If the principal
  * change results in the document principal losing access to the stream, then
--- a/dom/media/webaudio/MediaStreamAudioSourceNode.h
+++ b/dom/media/webaudio/MediaStreamAudioSourceNode.h
@@ -86,17 +86,17 @@ class MediaStreamAudioSourceNode
   // Attaches to the first audio track in the MediaStream, when the tracks are
   // ordered by id.
   void AttachToRightTrack(const RefPtr<DOMMediaStream>& aMediaStream,
                           ErrorResult& aRv);
 
   // From DOMMediaStream::TrackListener.
   void NotifyTrackAdded(const RefPtr<MediaStreamTrack>& aTrack) override;
   void NotifyTrackRemoved(const RefPtr<MediaStreamTrack>& aTrack) override;
-  void NotifyActive() override;
+  void NotifyAudible() override;
 
   // From PrincipalChangeObserver<MediaStreamTrack>.
   void PrincipalChanged(MediaStreamTrack* aMediaStreamTrack) override;
 
   // This allows implementing the correct behaviour for both
   // MediaElementAudioSourceNode and MediaStreamAudioSourceNode, that have most
   // of their behaviour shared.
   enum TrackChangeBehavior {