Backed out changeset a7e4ef74441d (bug 1057955) for Crashtest failures (crashes/assertions) on a CLOSED TREE
authorCarsten "Tomcat" Book <cbook@mozilla.com>
Wed, 27 Aug 2014 08:40:50 +0200
changeset 223543 e9c509681fede8c74e1d8a942f670b3323ced086
parent 223542 4a5a41e9b883e26ee0cfe3d0cf3272a68af68bf3
child 223544 c47c04eceb4610d9d560fb5bbd26724abf8df0f3
push id3979
push userraliiev@mozilla.com
push dateMon, 13 Oct 2014 16:35:44 +0000
treeherdermozilla-beta@30f2cc610691 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1057955
milestone34.0a1
backs outa7e4ef74441d2531e3be0003a655f364ccc92737
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
Backed out changeset a7e4ef74441d (bug 1057955) for Crashtest failures (crashes/assertions) on a CLOSED TREE
content/media/TrackUnionStream.h
--- a/content/media/TrackUnionStream.h
+++ b/content/media/TrackUnionStream.h
@@ -21,18 +21,18 @@ namespace mozilla {
  * See MediaStreamGraph::CreateTrackUnionStream.
  * This file is only included by MediaStreamGraph.cpp so it's OK to put the
  * entire implementation in this header file.
  */
 class TrackUnionStream : public ProcessedMediaStream {
 public:
   TrackUnionStream(DOMMediaStream* aWrapper) :
     ProcessedMediaStream(aWrapper),
-    mFilterCallback(nullptr)
-  {}
+    mFilterCallback(nullptr),
+    mMaxTrackID(0) {}
 
   virtual void RemoveInput(MediaInputPort* aPort) MOZ_OVERRIDE
   {
     for (int32_t i = mTrackMap.Length() - 1; i >= 0; --i) {
       if (mTrackMap[i].mInputPort == aPort) {
         EndTrack(i);
         mTrackMap.RemoveElementAt(i);
       }
@@ -158,31 +158,20 @@ protected:
     TrackID mInputTrackID;
     TrackID mOutputTrackID;
     nsAutoPtr<MediaSegment> mSegment;
   };
 
   uint32_t AddTrack(MediaInputPort* aPort, StreamBuffer::Track* aTrack,
                     GraphTime aFrom)
   {
-    // Use the ID of the source track if it's not already assigned to a track,
-    // otherwise allocate a new unique ID.
-    TrackID id = aTrack->GetID();
-    TrackID maxTrackID = 0;
-    bool found = false;
-    for (uint32_t i = 0; i < mTrackMap.Length(); ++i) {
-      TrackID outID = mTrackMap[i].mOutputTrackID;
-      if (outID == id) {
-        found = true;
-      }
-      maxTrackID = std::max(maxTrackID, outID);
-    }
-    if (found) {
-      id = maxTrackID + 1;
-    }
+    // Use the ID of the source track if we can, otherwise allocate a new
+    // unique ID
+    TrackID id = std::max(mMaxTrackID + 1, aTrack->GetID());
+    mMaxTrackID = id;
 
     TrackRate rate = aTrack->GetRate();
     // Round up the track start time so the track, if anything, starts a
     // little later than the true time. This means we'll have enough
     // samples in our input stream to go just beyond the destination time.
     TrackTicks outputStart = TimeToTicksRoundUp(rate, GraphTimeToStreamTime(aFrom));
 
     nsAutoPtr<MediaSegment> segment;
@@ -349,13 +338,14 @@ protected:
                                     outputTrack->GetRate(), startTicks, 0,
                                     *segment);
       }
       outputTrack->GetSegment()->AppendFrom(segment);
     }
   }
 
   nsTArray<TrackMapEntry> mTrackMap;
+  TrackID mMaxTrackID;
 };
 
 }
 
 #endif /* MOZILLA_MEDIASTREAMGRAPH_H_ */