Bug 1275596 - Ignore ended tracks when selecting new track in MediaStreamAudioSourceNode and MediaElementSourceNode. r=padenot
authorAndreas Pehrson <pehrsons@gmail.com>
Thu, 26 May 2016 15:56:58 +0200
changeset 338277 0fa7d5fb96afee035e4fe0cfa27692c9c7d344a2
parent 338276 daf83079577fa7b8407c18164c6cf490290c8304
child 338278 2f504de936e78b736b52cff7f860305f82531ba4
push id6249
push userjlund@mozilla.com
push dateMon, 01 Aug 2016 13:59:36 +0000
treeherdermozilla-beta@bad9d4f5bf7e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspadenot
bugs1275596, 1208371
milestone49.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 1275596 - Ignore ended tracks when selecting new track in MediaStreamAudioSourceNode and MediaElementSourceNode. r=padenot This is how it was meant to work when the refactor landed in Bug 1208371. We have no test coverage of seeking apparently. MozReview-Commit-ID: IhyGbjctO7E
dom/media/webaudio/MediaStreamAudioSourceNode.cpp
--- a/dom/media/webaudio/MediaStreamAudioSourceNode.cpp
+++ b/dom/media/webaudio/MediaStreamAudioSourceNode.cpp
@@ -112,21 +112,24 @@ MediaStreamAudioSourceNode::DetachFromTr
 }
 
 void
 MediaStreamAudioSourceNode::AttachToFirstTrack(const RefPtr<DOMMediaStream>& aMediaStream)
 {
   nsTArray<RefPtr<AudioStreamTrack>> tracks;
   aMediaStream->GetAudioTracks(tracks);
 
-  if (tracks.IsEmpty()) {
+  for (const RefPtr<AudioStreamTrack>& track : tracks) {
+    if (track->Ended()) {
+      continue;
+    }
+
+    AttachToTrack(track);
     return;
   }
-
-  AttachToTrack(tracks[0]);
 }
 
 void
 MediaStreamAudioSourceNode::NotifyTrackAdded(const RefPtr<MediaStreamTrack>& aTrack)
 {
   if (mInputTrack) {
     return;
   }