Bug 1259274: [MSE] P2. Remove unused code path. r=gerald
authorJean-Yves Avenard <jyavenard@mozilla.com>
Sun, 27 Mar 2016 18:44:10 +1100
changeset 290586 8498ca83977b7e846a64136ada2a9425c3b0b69e
parent 290585 d26a81fecde9ef4ea756c02b4f9fcf6934a395fb
child 290587 99c24e7caa30e609cce70a31db481beb232cb7df
push id19656
push usergwagner@mozilla.com
push dateMon, 04 Apr 2016 13:43:23 +0000
treeherderb2g-inbound@e99061fde28a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgerald
bugs1259274
milestone48.0a1
Bug 1259274: [MSE] P2. Remove unused code path. r=gerald MozReview-Commit-ID: FHj3u1WL1ul
dom/media/mediasource/MediaSource.cpp
dom/media/mediasource/MediaSource.h
dom/media/mediasource/SourceBuffer.cpp
dom/media/mediasource/SourceBuffer.h
dom/media/mediasource/SourceBufferList.cpp
dom/media/mediasource/SourceBufferList.h
dom/media/mediasource/TrackBuffersManager.cpp
dom/media/mediasource/TrackBuffersManager.h
--- a/dom/media/mediasource/MediaSource.cpp
+++ b/dom/media/mediasource/MediaSource.cpp
@@ -476,26 +476,16 @@ MediaSource::DurationChange(double aOldD
   if (aNewDuration < aOldDuration) {
     // Remove all buffered data from aNewDuration.
     mSourceBuffers->RangeRemoval(aNewDuration, PositiveInfinity<double>());
   }
   // TODO: If partial audio frames/text cues exist, clamp duration based on mSourceBuffers.
 }
 
 void
-MediaSource::NotifyEvicted(double aStart, double aEnd)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-  MSE_DEBUG("NotifyEvicted(aStart=%f, aEnd=%f)", aStart, aEnd);
-  // Cycle through all SourceBuffers and tell them to evict data in
-  // the given range.
-  mSourceBuffers->Evict(aStart, aEnd);
-}
-
-void
 MediaSource::GetMozDebugReaderData(nsAString& aString)
 {
   mDecoder->GetMozDebugReaderData(aString);
 }
 
 nsPIDOMWindowInner*
 MediaSource::GetParentObject() const
 {
--- a/dom/media/mediasource/MediaSource.h
+++ b/dom/media/mediasource/MediaSource.h
@@ -90,21 +90,16 @@ public:
     return mDecoder;
   }
 
   nsIPrincipal* GetPrincipal()
   {
     return mPrincipal;
   }
 
-  // Called by SourceBuffers to notify this MediaSource that data has
-  // been evicted from the buffered data. The start and end times
-  // that were evicted are provided.
-  void NotifyEvicted(double aStart, double aEnd);
-
   // Returns a string describing the state of the MediaSource internal
   // buffered data. Used for debugging purposes.
   void GetMozDebugReaderData(nsAString& aString);
 
 private:
   // MediaSourceDecoder uses DurationChange to set the duration
   // without hitting the checks in SetDuration.
   friend class mozilla::MediaSourceDecoder;
--- a/dom/media/mediasource/SourceBuffer.cpp
+++ b/dom/media/mediasource/SourceBuffer.cpp
@@ -532,24 +532,16 @@ SourceBuffer::PrepareAppend(const uint8_
   // TODO: Drive evictions off memory pressure notifications.
   // TODO: Consider a global eviction threshold  rather than per TrackBuffer.
   TimeUnit newBufferStartTime;
   // Attempt to evict the amount of data we are about to add by lowering the
   // threshold.
   Result evicted =
     mTrackBuffersManager->EvictData(TimeUnit::FromSeconds(mMediaSource->GetDecoder()->GetCurrentTime()),
                                     aLength, &newBufferStartTime);
-  if (evicted == Result::DATA_EVICTED) {
-    MSE_DEBUG("AppendData Evict; current buffered start=%f",
-              GetBufferedStart());
-
-    // We notify that we've evicted from the time range 0 through to
-    // the current start point.
-    mMediaSource->NotifyEvicted(0.0, newBufferStartTime.ToSeconds());
-  }
 
   // See if we have enough free space to append our new data.
   // As we can only evict once we have playable data, we must give a chance
   // to the DASH player to provide a complete media segment.
   if (aLength > mTrackBuffersManager->EvictionThreshold() ||
       evicted == Result::BUFFER_FULL) {
     aRv.Throw(NS_ERROR_DOM_QUOTA_EXCEEDED_ERR);
     return nullptr;
@@ -576,30 +568,16 @@ double
 SourceBuffer::GetBufferedEnd()
 {
   MOZ_ASSERT(NS_IsMainThread());
   ErrorResult dummy;
   RefPtr<TimeRanges> ranges = GetBuffered(dummy);
   return ranges->Length() > 0 ? ranges->GetEndTime() : 0;
 }
 
-void
-SourceBuffer::Evict(double aStart, double aEnd)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-  MSE_DEBUG("Evict(aStart=%f, aEnd=%f)", aStart, aEnd);
-  double currentTime = mMediaSource->GetDecoder()->GetCurrentTime();
-  double evictTime = aEnd;
-  const double safety_threshold = 5;
-  if (currentTime + safety_threshold >= evictTime) {
-    evictTime -= safety_threshold;
-  }
-  mTrackBuffersManager->EvictBefore(TimeUnit::FromSeconds(evictTime));
-}
-
 NS_IMPL_CYCLE_COLLECTION_CLASS(SourceBuffer)
 
 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(SourceBuffer)
   // Tell the TrackBuffer to end its current SourceBufferResource.
   TrackBuffersManager* manager = tmp->mTrackBuffersManager;
   if (manager) {
     manager->Detach();
   }
--- a/dom/media/mediasource/SourceBuffer.h
+++ b/dom/media/mediasource/SourceBuffer.h
@@ -193,19 +193,16 @@ public:
   void Detach();
   bool IsAttached() const
   {
     return mMediaSource != nullptr;
   }
 
   void Ended();
 
-  // Evict data in the source buffer in the given time range.
-  void Evict(double aStart, double aEnd);
-
   double GetBufferedStart();
   double GetBufferedEnd();
 
   // Runs the range removal algorithm as defined by the MSE spec.
   void RangeRemoval(double aStart, double aEnd);
 
   bool IsActive() const
   {
--- a/dom/media/mediasource/SourceBufferList.cpp
+++ b/dom/media/mediasource/SourceBufferList.cpp
@@ -126,26 +126,16 @@ SourceBufferList::RangeRemoval(double aS
   MOZ_ASSERT(NS_IsMainThread());
   MSE_DEBUG("RangeRemoval(aStart=%f, aEnd=%f)", aStart, aEnd);
   for (uint32_t i = 0; i < mSourceBuffers.Length(); ++i) {
     mSourceBuffers[i]->RangeRemoval(aStart, aEnd);
   }
 }
 
 void
-SourceBufferList::Evict(double aStart, double aEnd)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-  MSE_DEBUG("Evict(aStart=%f, aEnd=%f)", aStart, aEnd);
-  for (uint32_t i = 0; i < mSourceBuffers.Length(); ++i) {
-    mSourceBuffers[i]->Evict(aStart, aEnd);
-  }
-}
-
-void
 SourceBufferList::Ended()
 {
   MOZ_ASSERT(NS_IsMainThread());
   for (uint32_t i = 0; i < mSourceBuffers.Length(); ++i) {
     mSourceBuffers[i]->Ended();
   }
 }
 
--- a/dom/media/mediasource/SourceBufferList.h
+++ b/dom/media/mediasource/SourceBufferList.h
@@ -66,19 +66,16 @@ public:
   bool AnyUpdating();
 
   // Runs the range removal steps from the MSE specification on each SourceBuffer.
   void RangeRemoval(double aStart, double aEnd);
 
   // Mark all SourceBuffers input buffers as ended.
   void Ended();
 
-  // Evicts data for the given time range from each SourceBuffer in the list.
-  void Evict(double aStart, double aEnd);
-
   // Returns the highest end time of any of the Sourcebuffers.
   double GetHighestBufferedEndTime();
 
   // Append a SourceBuffer to the list. No event is fired.
   void AppendSimple(SourceBuffer* aSourceBuffer);
 
   // Remove all SourceBuffers from mSourceBuffers.
   //  No event is fired and no action is performed on the sourcebuffers.
--- a/dom/media/mediasource/TrackBuffersManager.cpp
+++ b/dom/media/mediasource/TrackBuffersManager.cpp
@@ -229,29 +229,16 @@ TrackBuffersManager::EvictData(TimeUnit 
     NS_NewRunnableMethodWithArgs<TimeUnit, uint32_t>(
       this, &TrackBuffersManager::DoEvictData,
       aPlaybackTime, toEvict);
   GetTaskQueue()->Dispatch(task.forget());
 
   return EvictDataResult::NO_DATA_EVICTED;
 }
 
-void
-TrackBuffersManager::EvictBefore(TimeUnit aTime)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-  MSE_DEBUG("");
-
-  nsCOMPtr<nsIRunnable> task =
-    NS_NewRunnableMethodWithArg<TimeInterval>(
-      this, &TrackBuffersManager::CodedFrameRemoval,
-      TimeInterval(TimeUnit::FromSeconds(0), aTime));
-  GetTaskQueue()->Dispatch(task.forget());
-}
-
 TimeIntervals
 TrackBuffersManager::Buffered()
 {
   MSE_DEBUG("");
   MonitorAutoLock mon(mMonitor);
   // http://w3c.github.io/media-source/index.html#widl-SourceBuffer-buffered
   // 2. Let highest end time be the largest track buffer ranges end time across all the track buffers managed by this SourceBuffer object.
   TimeUnit highestEndTime;
--- a/dom/media/mediasource/TrackBuffersManager.h
+++ b/dom/media/mediasource/TrackBuffersManager.h
@@ -39,17 +39,16 @@ public:
   NS_INLINE_DECL_THREADSAFE_REFCOUNTING(TrackBuffersManager);
 
   typedef MozPromise<bool, nsresult, /* IsExclusive = */ true> AppendPromise;
   typedef AppendPromise RangeRemovalPromise;
 
   enum class EvictDataResult : int8_t
   {
     NO_DATA_EVICTED,
-    DATA_EVICTED,
     CANT_EVICT,
     BUFFER_FULL,
   };
 
   // Current state as per Segment Parser Loop Algorithm
   // http://w3c.github.io/media-source/index.html#sourcebuffer-segment-parser-loop
   enum class AppendState : int32_t
   {
@@ -93,19 +92,16 @@ public:
   // bound the data being evicted. It will not evict more than aThreshold
   // bytes. aBufferStartTime contains the new start time of the data after the
   // eviction.
   EvictDataResult
   EvictData(media::TimeUnit aPlaybackTime,
             int64_t aThresholdReduct,
             media::TimeUnit* aBufferStartTime);
 
-  // Evicts data up to aTime.
-  void EvictBefore(media::TimeUnit aTime);
-
   // Returns the buffered range currently managed.
   // This may be called on any thread.
   // Buffered must conform to http://w3c.github.io/media-source/index.html#widl-SourceBuffer-buffered
   media::TimeIntervals Buffered();
 
   // Return the size of the data managed by this SourceBufferContentManager.
   int64_t GetSize();