Bug 1127203 - Rename aError to aTolerance. r=mattwoodrow, a=sledru
authorBobby Holley <bobbyholley@gmail.com>
Fri, 30 Jan 2015 17:45:49 -0800
changeset 243629 08954688351c
parent 243628 63e9ce6a9a45
child 243630 3dc1818e2427
push id4420
push userryanvm@gmail.com
push date2015-02-02 16:43 +0000
treeherdermozilla-beta@e98376bbdf79 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow, sledru
bugs1127203
milestone36.0
Bug 1127203 - Rename aError to aTolerance. r=mattwoodrow, a=sledru aError is a really misleading name.
dom/html/TimeRanges.cpp
dom/html/TimeRanges.h
dom/media/mediasource/MediaSourceReader.cpp
dom/media/mediasource/MediaSourceReader.h
--- a/dom/html/TimeRanges.cpp
+++ b/dom/html/TimeRanges.cpp
@@ -93,49 +93,49 @@ TimeRanges::GetEndTime()
 {
   if (mRanges.IsEmpty()) {
     return -1.0;
   }
   return mRanges[mRanges.Length() - 1].mEnd;
 }
 
 void
-TimeRanges::Normalize(double aError)
+TimeRanges::Normalize(double aTolerance)
 {
   if (mRanges.Length() >= 2) {
     nsAutoTArray<TimeRange,4> normalized;
 
     mRanges.Sort(CompareTimeRanges());
 
     // This merges the intervals.
     TimeRange current(mRanges[0]);
     for (uint32_t i = 1; i < mRanges.Length(); i++) {
       if (current.mStart <= mRanges[i].mStart &&
           current.mEnd >= mRanges[i].mEnd) {
         continue;
       }
-      if (current.mEnd + aError >= mRanges[i].mStart) {
+      if (current.mEnd + aTolerance >= mRanges[i].mStart) {
         current.mEnd = mRanges[i].mEnd;
       } else {
         normalized.AppendElement(current);
         current = mRanges[i];
       }
     }
 
     normalized.AppendElement(current);
 
     mRanges = normalized;
   }
 }
 
 void
-TimeRanges::Union(const TimeRanges* aOtherRanges, double aError)
+TimeRanges::Union(const TimeRanges* aOtherRanges, double aTolerance)
 {
   mRanges.AppendElements(aOtherRanges->mRanges);
-  Normalize(aError);
+  Normalize(aTolerance);
 }
 
 void
 TimeRanges::Intersection(const TimeRanges* aOtherRanges)
 {
   nsAutoTArray<TimeRange,4> intersection;
 
   const nsTArray<TimeRange>& otherRanges = aOtherRanges->mRanges;
@@ -151,20 +151,20 @@ TimeRanges::Intersection(const TimeRange
       j += 1;
     }
   }
 
   mRanges = intersection;
 }
 
 TimeRanges::index_type
-TimeRanges::Find(double aTime, double aError /* = 0 */)
+TimeRanges::Find(double aTime, double aTolerance /* = 0 */)
 {
   for (index_type i = 0; i < mRanges.Length(); ++i) {
-    if (aTime < mRanges[i].mEnd && (aTime + aError) >= mRanges[i].mStart) {
+    if (aTime < mRanges[i].mEnd && (aTime + aTolerance) >= mRanges[i].mStart) {
       return i;
     }
   }
   return NoIndex;
 }
 
 JSObject*
 TimeRanges::WrapObject(JSContext* aCx)
--- a/dom/html/TimeRanges.h
+++ b/dom/html/TimeRanges.h
@@ -37,20 +37,20 @@ public:
 
   // Returns the start time of the first range, or -1 if no ranges exist.
   double GetStartTime();
 
   // Returns the end time of the last range, or -1 if no ranges exist.
   double GetEndTime();
 
   // See http://www.whatwg.org/html/#normalized-timeranges-object
-  void Normalize(double aError = 0.0);
+  void Normalize(double aTolerance = 0.0);
 
   // Mutate this TimeRange to be the union of this and aOtherRanges.
-  void Union(const TimeRanges* aOtherRanges, double aError);
+  void Union(const TimeRanges* aOtherRanges, double aTolerance);
 
   // Mutate this TimeRange to be the intersection of this and aOtherRanges.
   void Intersection(const TimeRanges* aOtherRanges);
 
   JSObject* WrapObject(JSContext* aCx);
 
   uint32_t Length() const
   {
@@ -86,17 +86,17 @@ private:
   };
 
   nsAutoTArray<TimeRange,4> mRanges;
 
 public:
   typedef nsTArray<TimeRange>::index_type index_type;
   static const index_type NoIndex = index_type(-1);
 
-  index_type Find(double aTime, double aError = 0);
+  index_type Find(double aTime, double aTolerance = 0);
 
   bool Contains(double aStart, double aEnd) {
     index_type target = Find(aStart);
     if (target == NoIndex) {
       return false;
     }
 
     return mRanges[target].mEnd >= aEnd;
--- a/dom/media/mediasource/MediaSourceReader.cpp
+++ b/dom/media/mediasource/MediaSourceReader.cpp
@@ -435,30 +435,30 @@ MediaSourceReader::BreakCycles()
   for (uint32_t i = 0; i < mShutdownTrackBuffers.Length(); ++i) {
     mShutdownTrackBuffers[i]->BreakCycles();
   }
   mShutdownTrackBuffers.Clear();
 }
 
 already_AddRefed<MediaDecoderReader>
 MediaSourceReader::SelectReader(int64_t aTarget,
-                                int64_t aError,
+                                int64_t aTolerance,
                                 const nsTArray<nsRefPtr<SourceBufferDecoder>>& aTrackDecoders)
 {
   mDecoder->GetReentrantMonitor().AssertCurrentThreadIn();
 
   // Consider decoders in order of newest to oldest, as a newer decoder
   // providing a given buffered range is expected to replace an older one.
   for (int32_t i = aTrackDecoders.Length() - 1; i >= 0; --i) {
     nsRefPtr<MediaDecoderReader> newReader = aTrackDecoders[i]->GetReader();
 
     nsRefPtr<dom::TimeRanges> ranges = new dom::TimeRanges();
     aTrackDecoders[i]->GetBuffered(ranges);
     if (ranges->Find(double(aTarget) / USECS_PER_S,
-                     double(aError) / USECS_PER_S) == dom::TimeRanges::NoIndex) {
+                     double(aTolerance) / USECS_PER_S) == dom::TimeRanges::NoIndex) {
       MSE_DEBUGV("MediaSourceReader(%p)::SelectReader(%lld) newReader=%p target not in ranges=%s",
                  this, aTarget, newReader.get(), DumpTimeRanges(ranges).get());
       continue;
     }
 
     return newReader.forget();
   }
 
@@ -470,42 +470,42 @@ MediaSourceReader::HaveData(int64_t aTar
 {
   TrackBuffer* trackBuffer = aType == MediaData::AUDIO_DATA ? mAudioTrack : mVideoTrack;
   MOZ_ASSERT(trackBuffer);
   nsRefPtr<MediaDecoderReader> reader = SelectReader(aTarget, EOS_FUZZ_US, trackBuffer->Decoders());
   return !!reader;
 }
 
 MediaSourceReader::SwitchReaderResult
-MediaSourceReader::SwitchAudioReader(int64_t aTarget, int64_t aError)
+MediaSourceReader::SwitchAudioReader(int64_t aTarget, int64_t aTolerance)
 {
   ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
   // XXX: Can't handle adding an audio track after ReadMetadata.
   if (!mAudioTrack) {
     return READER_ERROR;
   }
-  nsRefPtr<MediaDecoderReader> newReader = SelectReader(aTarget, aError, mAudioTrack->Decoders());
+  nsRefPtr<MediaDecoderReader> newReader = SelectReader(aTarget, aTolerance, mAudioTrack->Decoders());
   if (newReader && newReader != mAudioReader) {
     mAudioReader->SetIdle();
     mAudioReader = newReader;
     MSE_DEBUGV("MediaSourceReader(%p)::SwitchAudioReader switched reader to %p", this, mAudioReader.get());
     return READER_NEW;
   }
   return newReader ? READER_EXISTING : READER_ERROR;
 }
 
 MediaSourceReader::SwitchReaderResult
-MediaSourceReader::SwitchVideoReader(int64_t aTarget, int64_t aError)
+MediaSourceReader::SwitchVideoReader(int64_t aTarget, int64_t aTolerance)
 {
   ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
   // XXX: Can't handle adding a video track after ReadMetadata.
   if (!mVideoTrack) {
     return READER_ERROR;
   }
-  nsRefPtr<MediaDecoderReader> newReader = SelectReader(aTarget, aError, mVideoTrack->Decoders());
+  nsRefPtr<MediaDecoderReader> newReader = SelectReader(aTarget, aTolerance, mVideoTrack->Decoders());
   if (newReader && newReader != mVideoReader) {
     mVideoReader->SetIdle();
     mVideoReader = newReader;
     MSE_DEBUGV("MediaSourceReader(%p)::SwitchVideoReader switched reader to %p", this, mVideoReader.get());
     return READER_NEW;
   }
   return newReader ? READER_EXISTING : READER_ERROR;
 }
--- a/dom/media/mediasource/MediaSourceReader.h
+++ b/dom/media/mediasource/MediaSourceReader.h
@@ -140,37 +140,38 @@ public:
            (!mVideoReader || mVideoReader->IsAsync());
   }
 
   // Returns true if aReader is a currently active audio or video
   bool IsActiveReader(MediaDecoderReader* aReader);
 
 private:
   // Switch the current audio/video reader to the reader that
-  // contains aTarget (or up to aError after target). Both
-  // aTarget and aError are in microseconds.
+  // contains aTarget (or up to aTolerance after target). Both
+  // aTarget and aTolerance are in microseconds.
   enum SwitchReaderResult {
     READER_ERROR = -1,
     READER_EXISTING = 0,
     READER_NEW = 1,
   };
-  SwitchReaderResult SwitchAudioReader(int64_t aTarget, int64_t aError = 0);
-  SwitchReaderResult SwitchVideoReader(int64_t aTarget, int64_t aError = 0);
+
+  SwitchReaderResult SwitchAudioReader(int64_t aTarget, int64_t aTolerance = 0);
+  SwitchReaderResult SwitchVideoReader(int64_t aTarget, int64_t aTolerance = 0);
   void RequestAudioDataComplete(int64_t aTime);
   void RequestAudioDataFailed(nsresult aResult);
   void RequestVideoDataComplete(int64_t aTime);
   void RequestVideoDataFailed(nsresult aResult);
   // Will reject the MediaPromise with END_OF_STREAM if mediasource has ended
   // or with WAIT_FOR_DATA otherwise.
   void CheckForWaitOrEndOfStream(MediaData::Type aType, int64_t aTime /* microseconds */);
 
   // Return a reader from the set available in aTrackDecoders that has data
   // available in the range requested by aTarget.
   already_AddRefed<MediaDecoderReader> SelectReader(int64_t aTarget,
-                                                    int64_t aError,
+                                                    int64_t aTolerance,
                                                     const nsTArray<nsRefPtr<SourceBufferDecoder>>& aTrackDecoders);
   bool HaveData(int64_t aTarget, MediaData::Type aType);
 
   void AttemptSeek();
 
   nsRefPtr<MediaDecoderReader> mAudioReader;
   nsRefPtr<MediaDecoderReader> mVideoReader;