bug 1190285 remove unused HaveEnoughBuffered r=padenot
authorKarl Tomlinson <karlt+@karlt.net>
Fri, 31 Jul 2015 18:54:05 +1200
changeset 287726 9db3e1d16ff58fd900d94f8d3a9482d255b0c251
parent 287725 2bcb21c74b7438c6587466ab60b92692633b87f8
child 287727 e0fc6c3f48a74316f3f1010d2ab6429650564b87
push id5067
push userraliiev@mozilla.com
push dateMon, 21 Sep 2015 14:04:52 +0000
treeherdermozilla-beta@14221ffe5b2f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspadenot
bugs1190285
milestone42.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 1190285 remove unused HaveEnoughBuffered r=padenot
dom/media/GraphDriver.h
dom/media/MediaDecoderStateMachine.cpp
dom/media/MediaStreamGraph.cpp
dom/media/MediaStreamGraph.h
--- a/dom/media/GraphDriver.h
+++ b/dom/media/GraphDriver.h
@@ -45,25 +45,16 @@ static const int SCHEDULE_SAFETY_MARGIN_
  * is 2*MEDIA_GRAPH_TARGET_PERIOD_MS + SCHEDULE_SAFETY_MARGIN_MS.
  * There is no point in buffering more audio than this in a stream at any
  * given time (until we add processing).
  * This is not optimal yet.
  */
 static const int AUDIO_TARGET_MS = 2*MEDIA_GRAPH_TARGET_PERIOD_MS +
     SCHEDULE_SAFETY_MARGIN_MS;
 
-/**
- * Try have this much video buffered. Video frames are set
- * near the end of the iteration of the control loop. The maximum delay
- * to the setting of the next video frame is 2*MEDIA_GRAPH_TARGET_PERIOD_MS +
- * SCHEDULE_SAFETY_MARGIN_MS. This is not optimal yet.
- */
-static const int VIDEO_TARGET_MS = 2*MEDIA_GRAPH_TARGET_PERIOD_MS +
-    SCHEDULE_SAFETY_MARGIN_MS;
-
 class MediaStreamGraphImpl;
 
 /**
  * Microseconds relative to the start of the graph timeline.
  */
 typedef int64_t GraphTime;
 const GraphTime GRAPH_TIME_MAX = MEDIA_TIME_MAX;
 
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -409,19 +409,18 @@ bool MediaDecoderStateMachine::HaveEnoug
   MOZ_ASSERT(OnTaskQueue());
   AssertCurrentThreadInMonitor();
 
   if (AudioQueue().GetSize() == 0 ||
       GetDecodedAudioDuration() < aAmpleAudioUSecs) {
     return false;
   }
 
-  // We don't have to check SourceMediaStream::HaveEnoughBuffered() in the
-  // case of stream-capture for MDSM will ensure buffering level is high enough
-  // for playback speed at 1x at which the DecodedStream is playing.
+  // MDSM will ensure buffering level is high enough for playback speed at 1x
+  // at which the DecodedStream is playing.
   return true;
 }
 
 bool MediaDecoderStateMachine::HaveEnoughDecodedVideo()
 {
   MOZ_ASSERT(OnTaskQueue());
   AssertCurrentThreadInMonitor();
 
--- a/dom/media/MediaStreamGraph.cpp
+++ b/dom/media/MediaStreamGraph.cpp
@@ -66,27 +66,16 @@ static nsDataHashtable<nsUint32HashKey, 
 MediaStreamGraphImpl::~MediaStreamGraphImpl()
 {
   NS_ASSERTION(IsEmpty(),
                "All streams should have been destroyed by messages from the main thread");
   STREAM_LOG(LogLevel::Debug, ("MediaStreamGraph %p destroyed", this));
   LIFECYCLE_LOG("MediaStreamGraphImpl::~MediaStreamGraphImpl\n");
 }
 
-
-StreamTime
-MediaStreamGraphImpl::GetDesiredBufferEnd(MediaStream* aStream)
-{
-  StreamTime current = IterationEnd() - aStream->mBufferStartTime;
-  // When waking up media decoders, we need a longer safety margin, as it can
-  // take more time to get new samples. A factor of two seem to work.
-  return current +
-      2 * MillisecondsToMediaTime(std::max(AUDIO_TARGET_MS, VIDEO_TARGET_MS));
-}
-
 void
 MediaStreamGraphImpl::FinishStream(MediaStream* aStream)
 {
   if (aStream->mFinished)
     return;
   STREAM_LOG(LogLevel::Debug, ("MediaStream %p will finish", aStream));
   aStream->mFinished = true;
   aStream->mBuffer.AdvanceKnownTracksTime(STREAM_TIME_MAX);
@@ -256,44 +245,16 @@ MediaStreamGraphImpl::ExtractPendingInpu
   if (aStream->mBuffer.GetEnd() > 0) {
     aStream->mHasCurrentData = true;
   }
   if (finished) {
     FinishStream(aStream);
   }
 }
 
-void
-MediaStreamGraphImpl::UpdateBufferSufficiencyState(SourceMediaStream* aStream)
-{
-  StreamTime desiredEnd = GetDesiredBufferEnd(aStream);
-  {
-    MutexAutoLock lock(aStream->mMutex);
-    for (uint32_t i = 0; i < aStream->mUpdateTracks.Length(); ++i) {
-      SourceMediaStream::TrackData* data = &aStream->mUpdateTracks[i];
-      if (data->mCommands & SourceMediaStream::TRACK_CREATE) {
-        // This track hasn't been created yet, so we have no sufficiency
-        // data. The track will be created in the next iteration of the
-        // control loop and then we'll fire insufficiency notifications
-        // if necessary.
-        continue;
-      }
-      if (data->mCommands & SourceMediaStream::TRACK_END) {
-        // This track will end, so no point updating.
-        continue;
-      }
-      StreamBuffer::Track* track = aStream->mBuffer.FindTrack(data->mID);
-      // Note that track->IsEnded() must be false, otherwise we would have
-      // removed the track from mUpdateTracks already.
-      NS_ASSERTION(!track->IsEnded(), "What is this track doing here?");
-      data->mHaveEnough = track->GetEnd() >= desiredEnd;
-    }
-  }
-}
-
 StreamTime
 MediaStreamGraphImpl::GraphTimeToStreamTime(MediaStream* aStream,
                                             GraphTime aTime)
 {
   MOZ_ASSERT(aTime <= CurrentDriver()->StateComputedTime(),
                "Don't ask about times where we haven't made blocking decisions yet");
   if (aTime <= IterationEnd()) {
     return std::max<StreamTime>(0, aTime - aStream->mBufferStartTime);
@@ -1433,20 +1394,16 @@ MediaStreamGraphImpl::Process(GraphTime 
           ticksPlayed = ticksPlayedForThisStream;
         } else {
           MOZ_ASSERT(!ticksPlayedForThisStream || ticksPlayedForThisStream == ticksPlayed,
               "Each stream should have the same number of frame.");
         }
       }
       PlayVideo(stream);
     }
-    SourceMediaStream* is = stream->AsSourceStream();
-    if (is) {
-      UpdateBufferSufficiencyState(is);
-    }
     GraphTime end;
     if (!stream->mBlocked.GetAt(aTo, &end) || end < GRAPH_TIME_MAX) {
       allBlockedForever = false;
     }
   }
 
   if (CurrentDriver()->AsAudioCallbackDriver() && ticksPlayed) {
     mMixer.FinishMixing();
@@ -2466,17 +2423,16 @@ SourceMediaStream::AddTrackInternal(Trac
                                     &mPendingTracks : &mUpdateTracks;
   TrackData* data = track_data->AppendElement();
   data->mID = aID;
   data->mInputRate = aRate;
   data->mStart = aStart;
   data->mEndOfFlushedData = aStart;
   data->mCommands = TRACK_CREATE;
   data->mData = aSegment;
-  data->mHaveEnough = false;
   if (!(aFlags & ADDTRACK_QUEUED) && GraphImpl()) {
     GraphImpl()->EnsureNextIteration();
   }
 }
 
 void
 SourceMediaStream::FinishAddTracks()
 {
@@ -2627,27 +2583,16 @@ SourceMediaStream::RemoveDirectListener(
   }
 
   if (isEmpty) {
     // Async
     NotifyListenersEvent(MediaStreamListener::EVENT_HAS_NO_DIRECT_LISTENERS);
   }
 }
 
-bool
-SourceMediaStream::HaveEnoughBuffered(TrackID aID)
-{
-  MutexAutoLock lock(mMutex);
-  TrackData *track = FindDataForTrack(aID);
-  if (track) {
-    return track->mHaveEnough;
-  }
-  return false;
-}
-
 StreamTime
 SourceMediaStream::GetEndOfAppendedData(TrackID aID)
 {
   MutexAutoLock lock(mMutex);
   TrackData *track = FindDataForTrack(aID);
   if (track) {
     return track->mEndOfFlushedData + track->mData->GetDuration();
   }
--- a/dom/media/MediaStreamGraph.h
+++ b/dom/media/MediaStreamGraph.h
@@ -811,21 +811,16 @@ public:
   /**
    * Append media data to a track. Ownership of aSegment remains with the caller,
    * but aSegment is emptied.
    * Returns false if the data was not appended because no such track exists
    * or the stream was already finished.
    */
   bool AppendToTrack(TrackID aID, MediaSegment* aSegment, MediaSegment *aRawSegment = nullptr);
   /**
-   * Returns true if the buffer currently has enough data.
-   * Returns false if there isn't enough data or if no such track exists.
-   */
-  bool HaveEnoughBuffered(TrackID aID);
-  /**
    * Get the stream time of the end of the data that has been appended so far.
    * Can be called from any thread but won't be useful if it can race with
    * an AppendToTrack call, so should probably just be called from the thread
    * that also calls AppendToTrack.
    */
   StreamTime GetEndOfAppendedData(TrackID aID);
   /**
    * Indicate that a track has ended. Do not do any more API calls
@@ -920,17 +915,16 @@ protected:
     // End-time of data already flushed to the track (excluding mData)
     StreamTime mEndOfFlushedData;
     // Each time the track updates are flushed to the media graph thread,
     // the segment buffer is emptied.
     nsAutoPtr<MediaSegment> mData;
     // Each time the track updates are flushed to the media graph thread,
     // this is cleared.
     uint32_t mCommands;
-    bool mHaveEnough;
   };
 
   bool NeedsMixing();
 
   void ResampleAudioToGraphSampleRate(TrackData* aTrackData, MediaSegment* aSegment);
 
   void AddTrackInternal(TrackID aID, TrackRate aRate,
                         StreamTime aStart, MediaSegment* aSegment,