Backed out changeset 6943b5034e0c (bug 1173656) for OSX crashes/asserts.
authorRyan VanderMeulen <ryanvm@gmail.com>
Mon, 15 Jun 2015 11:55:30 -0400
changeset 279661 758269f1463cf81ac344cca34ca942f13c204d50
parent 279660 8f567d41d84914ced019ff57d03f3f87dba4517b
child 279662 f1617a11f15b7da0800d259b7d495c0ababee952
push id4932
push userjlund@mozilla.com
push dateMon, 10 Aug 2015 18:23:06 +0000
treeherdermozilla-beta@6dd5a4f5f745 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1173656
milestone41.0a1
backs out6943b5034e0c2fa9f7d25a4b623002d4678981b1
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 6943b5034e0c (bug 1173656) for OSX crashes/asserts.
dom/media/TrackUnionStream.cpp
dom/media/TrackUnionStream.h
--- a/dom/media/TrackUnionStream.cpp
+++ b/dom/media/TrackUnionStream.cpp
@@ -41,17 +41,17 @@ namespace mozilla {
 #ifdef STREAM_LOG
 #undef STREAM_LOG
 #endif
 
 PRLogModuleInfo* gTrackUnionStreamLog;
 #define STREAM_LOG(type, msg) MOZ_LOG(gTrackUnionStreamLog, type, msg)
 
 TrackUnionStream::TrackUnionStream(DOMMediaStream* aWrapper) :
-  ProcessedMediaStream(aWrapper), mNextAvailableTrackID(1)
+  ProcessedMediaStream(aWrapper)
 {
   if (!gTrackUnionStreamLog) {
     gTrackUnionStreamLog = PR_NewLogModule("TrackUnionStream");
   }
 }
 
   void TrackUnionStream::RemoveInput(MediaInputPort* aPort)
   {
@@ -156,33 +156,33 @@ TrackUnionStream::TrackUnionStream(DOMMe
           SetTrackEnabled(mTrackMap[i].mInputTrackID, aEnabled);
       }
     }
   }
 
   uint32_t TrackUnionStream::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();
-    if (id > mNextAvailableTrackID &&
-       mUsedTracks.BinaryIndexOf(id) == mUsedTracks.NoIndex) {
-      // Input id available. Mark it used in mUsedTracks.
-      mUsedTracks.InsertElementSorted(id);
-    } else {
-      // Input id taken, allocate a new one.
-      id = mNextAvailableTrackID;
-
-      // Update mNextAvailableTrackID and prune any mUsedTracks members it now
-      // covers.
-      while (1) {
-        if (!mUsedTracks.RemoveElementSorted(++mNextAvailableTrackID)) {
-          // Not in use. We're done.
-          break;
-        }
+    TrackID maxTrackID = 0;
+    for (uint32_t i = 0; i < mTrackMap.Length(); ++i) {
+      TrackID outID = mTrackMap[i].mOutputTrackID;
+      maxTrackID = std::max(maxTrackID, outID);
+    }
+    // Note: we might have removed it here, but it might still be in the
+    // StreamBuffer if the TrackUnionStream sees its input stream flip from
+    // A to B, where both A and B have a track with the same ID
+    while (1) {
+      // search until we find one not in use here, and not in mBuffer
+      if (!mBuffer.FindTrack(id)) {
+        break;
       }
+      id = ++maxTrackID;
     }
 
     // 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.
     StreamTime outputStart = GraphTimeToStreamTime(aFrom);
 
     nsAutoPtr<MediaSegment> segment;
--- a/dom/media/TrackUnionStream.h
+++ b/dom/media/TrackUnionStream.h
@@ -45,30 +45,21 @@ protected:
     // when a finished track is forgotten.) When we need a Track*,
     // we call StreamBuffer::FindTrack, which will return null if
     // the track has been deleted.
     TrackID mInputTrackID;
     TrackID mOutputTrackID;
     nsAutoPtr<MediaSegment> mSegment;
   };
 
-  // Add the track to this stream, retaining its TrackID if it has never
-  // been previously used in this stream, allocating a new TrackID otherwise.
   uint32_t AddTrack(MediaInputPort* aPort, StreamBuffer::Track* aTrack,
                     GraphTime aFrom);
   void EndTrack(uint32_t aIndex);
   void CopyTrackData(StreamBuffer::Track* aInputTrack,
                      uint32_t aMapIndex, GraphTime aFrom, GraphTime aTo,
                      bool* aOutputTrackFinished);
 
   nsTArray<TrackMapEntry> mTrackMap;
-
-  // The next available TrackID, starting at 1 and progressing upwards.
-  // All TrackIDs in [1, mNextAvailableTrackID) have implicitly been used.
-  TrackID mNextAvailableTrackID;
-
-  // Sorted array of used TrackIDs that require manual tracking.
-  nsTArray<TrackID> mUsedTracks;
 };
 
 }
 
 #endif /* MOZILLA_MEDIASTREAMGRAPH_H_ */