Bug 1523817 - Fix tracks that start at StreamTime t > 0. r=padenot a=lizzard
authorAndreas Pehrson <pehrsons@mozilla.com>
Fri, 01 Feb 2019 13:44:44 +0000
changeset 515758 32e42cfd5f75027335205e600bf4cd241d6de773
parent 515757 1079d285dd4006cf27fd867d29c7e408a7627365
child 515759 da01ba6f951a3f1acdc475c73ba03ed8efc640e7
push id1953
push userffxbld-merge
push dateMon, 11 Mar 2019 12:10:20 +0000
treeherdermozilla-release@9c35dcbaa899 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspadenot, lizzard
bugs1523817
milestone66.0
Bug 1523817 - Fix tracks that start at StreamTime t > 0. r=padenot a=lizzard Differential Revision: https://phabricator.services.mozilla.com/D18312
dom/media/MediaStreamGraph.cpp
--- a/dom/media/MediaStreamGraph.cpp
+++ b/dom/media/MediaStreamGraph.cpp
@@ -2548,20 +2548,27 @@ bool SourceMediaStream::PullNewData(Grap
       streamPullingEnabled = true;
       break;
     }
   }
   // Compute how much stream time we'll need assuming we don't block
   // the stream at all.
   StreamTime t = GraphTimeToStreamTime(aDesiredUpToTime);
   for (const TrackData& track : mUpdateTracks) {
-    if (track.mCommands & TrackEventCommand::TRACK_EVENT_ENDED) {
+    if (track.mCommands & TRACK_END) {
       continue;
     }
-    StreamTime current = track.mEndOfFlushedData + track.mData->GetDuration();
+    StreamTime current;
+    if (track.mCommands & TRACK_CREATE) {
+      // This track hasn't been created yet. Use the stream's current time
+      // (which the track will get as its start time later).
+      current = GraphTimeToStreamTime(GraphImpl()->mStateComputedTime);
+    } else {
+      current = track.mEndOfFlushedData + track.mData->GetDuration();
+    }
     if (t <= current) {
       continue;
     }
     if (!track.mPullingEnabled) {
       if (streamPullingEnabled) {
         LOG(LogLevel::Verbose,
             ("%p: Pulling disabled for track but enabled for stream, append "
              "null data; stream=%p track=%d t=%f current end=%f",
@@ -2612,18 +2619,18 @@ void SourceMediaStream::ExtractPendingIn
     if (data->mCommands & SourceMediaStream::TRACK_CREATE) {
       MediaSegment* segment = data->mData.forget();
       LOG(LogLevel::Debug,
           ("%p: SourceMediaStream %p creating track %d, start %" PRId64
            ", initial end %" PRId64,
            GraphImpl(), this, data->mID, int64_t(streamCurrentTime),
            int64_t(segment->GetDuration())));
 
+      segment->InsertNullDataAtStart(streamCurrentTime);
       data->mEndOfFlushedData += segment->GetDuration();
-      segment->InsertNullDataAtStart(streamCurrentTime);
       mTracks.AddTrack(data->mID, streamCurrentTime, segment);
       // The track has taken ownership of data->mData, so let's replace
       // data->mData with an empty clone.
       data->mData = segment->CreateEmptyClone();
       data->mCommands &= ~SourceMediaStream::TRACK_CREATE;
     } else if (data->mData->GetDuration() > 0) {
       MediaSegment* dest = mTracks.FindTrack(data->mID)->GetSegment();
       LOG(LogLevel::Verbose,