Bug 1189506. Remove no-longer-used TimeVarying.h. r=karlt
authorRobert O'Callahan <robert@ocallahan.org>
Fri, 04 Sep 2015 18:49:27 +1200
changeset 295505 7fd85ebb56de0f67fa36843f4d360f94276b0b8c
parent 295504 309eaacef6878dde2e15e7b4e1d4354c9d3e33c5
child 295506 3311210c41e5693e1f174009b8c4b8a622426e5d
push id5245
push userraliiev@mozilla.com
push dateThu, 29 Oct 2015 11:30:51 +0000
treeherdermozilla-beta@dac831dc1bd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskarlt
bugs1189506
milestone43.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 1189506. Remove no-longer-used TimeVarying.h. r=karlt
dom/media/MediaStreamGraph.h
dom/media/StreamBuffer.h
dom/media/TimeVarying.h
dom/media/moz.build
--- a/dom/media/MediaStreamGraph.h
+++ b/dom/media/MediaStreamGraph.h
@@ -12,17 +12,16 @@
 
 #include "mozilla/dom/AudioChannelBinding.h"
 
 #include "AudioSegment.h"
 #include "AudioStream.h"
 #include "nsTArray.h"
 #include "nsIRunnable.h"
 #include "StreamBuffer.h"
-#include "TimeVarying.h"
 #include "VideoFrameContainer.h"
 #include "VideoSegment.h"
 #include "MainThreadUtils.h"
 #include "nsAutoRef.h"
 #include <speex/speex_resampler.h>
 #include "DOMMediaStream.h"
 #include "AudioContext.h"
 
--- a/dom/media/StreamBuffer.h
+++ b/dom/media/StreamBuffer.h
@@ -56,17 +56,16 @@ public:
   /**
    * Every track has a start time --- when it started in the StreamBuffer.
    * It has an end flag; when false, no end point is known; when true,
    * the track ends when the data we have for the track runs out.
    * Tracks have a unique ID assigned at creation. This allows us to identify
    * the same track across StreamBuffers. A StreamBuffer should never have
    * two tracks with the same ID (even if they don't overlap in time).
    * TODO Tracks can also be enabled and disabled over time.
-   * TODO Add TimeVarying<StreamTime,bool> mEnabled.
    * Takes ownership of aSegment.
    */
   class Track final
   {
     Track(TrackID aID, StreamTime aStart, MediaSegment* aSegment)
       : mStart(aStart),
         mSegment(aSegment),
         mID(aID),
deleted file mode 100644
--- a/dom/media/TimeVarying.h
+++ /dev/null
@@ -1,237 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-*/
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef MOZILLA_TIMEVARYING_H_
-#define MOZILLA_TIMEVARYING_H_
-
-#include "nsTArray.h"
-
-namespace mozilla {
-
-/**
- * This is just for CTOR/DTOR tracking. We can't put this in
- * TimeVarying directly because the different template instances have
- * different sizes and that confuses things.
- */
-class TimeVaryingBase {
-protected:
-  TimeVaryingBase()
-  {
-    MOZ_COUNT_CTOR(TimeVaryingBase);
-  }
-  ~TimeVaryingBase()
-  {
-    MOZ_COUNT_DTOR(TimeVaryingBase);
-  }
-};
-
-/**
- * Objects of this class represent values that can change over time ---
- * a mathematical function of time.
- * Time is the type of time values, T is the value that changes over time.
- * There are a finite set of "change times"; at each change time, the function
- * instantly changes to a new value. ReservedChanges should be set to the
- * expected number of change events that the object is likely to contain.
- * This value should be 0 for all consumers unless you know that a higher value
- * would be a benefit.
- * There is also a "current time" which must always advance (not go backward).
- * The function is constant for all times less than the current time.
- * When the current time is advanced, the value of the function at the new
- * current time replaces the values for all previous times.
- *
- * The implementation records a mCurrent (the value at the current time)
- * and an array of "change times" (greater than the current time) and the
- * new value for each change time. This is a simple but dumb implementation.
- * We maintain the invariant that each change entry in the array must have
- * a different value to the value in the previous change entry (or, for
- * the first change entry, mCurrent).
- */
-template <typename Time, typename T, uint32_t ReservedChanges>
-class TimeVarying : public TimeVaryingBase {
-public:
-  explicit TimeVarying(const T& aInitial) : mCurrent(aInitial) {}
-  /**
-   * This constructor can only be called if mCurrent has a no-argument
-   * constructor.
-   */
-  TimeVarying() : mCurrent() {}
-
-  /**
-   * Sets the value for all times >= aTime to aValue.
-   */
-  void SetAtAndAfter(Time aTime, const T& aValue)
-  {
-    for (int32_t i = mChanges.Length() - 1; i >= 0; --i) {
-      NS_ASSERTION(i == int32_t(mChanges.Length() - 1),
-                   "Always considering last element of array");
-      if (aTime > mChanges[i].mTime) {
-        if (mChanges[i].mValue != aValue) {
-          mChanges.AppendElement(Entry(aTime, aValue));
-        }
-        return;
-      }
-      if (aTime == mChanges[i].mTime) {
-        if ((i > 0 ? mChanges[i - 1].mValue : mCurrent) == aValue) {
-          mChanges.RemoveElementAt(i);
-          return;
-        }
-        mChanges[i].mValue = aValue;
-        return;
-      }
-      mChanges.RemoveElementAt(i);
-    }
-    if (mCurrent == aValue) {
-      return;
-    }
-    mChanges.InsertElementAt(0, Entry(aTime, aValue));
-  }
-  /**
-   * Returns the final value of the function. If aTime is non-null,
-   * sets aTime to the time at which the function changes to that final value.
-   * If there are no changes after the current time, returns INT64_MIN in aTime.
-   */
-  const T& GetLast(Time* aTime = nullptr) const
-  {
-    if (mChanges.IsEmpty()) {
-      if (aTime) {
-        *aTime = INT64_MIN;
-      }
-      return mCurrent;
-    }
-    if (aTime) {
-      *aTime = mChanges[mChanges.Length() - 1].mTime;
-    }
-    return mChanges[mChanges.Length() - 1].mValue;
-  }
-  /**
-   * Returns the value of the function just before time aTime.
-   */
-  const T& GetBefore(Time aTime) const
-  {
-    if (mChanges.IsEmpty() || aTime <= mChanges[0].mTime) {
-      return mCurrent;
-    }
-    int32_t changesLength = mChanges.Length();
-    if (mChanges[changesLength - 1].mTime < aTime) {
-      return mChanges[changesLength - 1].mValue;
-    }
-    for (uint32_t i = 1; ; ++i) {
-      if (aTime <= mChanges[i].mTime) {
-        NS_ASSERTION(mChanges[i].mValue != mChanges[i - 1].mValue,
-                     "Only changed values appear in array");
-        return mChanges[i - 1].mValue;
-      }
-    }
-  }
-  /**
-   * Returns the value of the function at time aTime.
-   * If aEnd is non-null, sets *aEnd to the time at which the function will
-   * change from the returned value to a new value, or INT64_MAX if that
-   * never happens.
-   * If aStart is non-null, sets *aStart to the time at which the function
-   * changed to the returned value, or INT64_MIN if that happened at or
-   * before the current time.
-   *
-   * Currently uses a linear search, but could use a binary search.
-   */
-  const T& GetAt(Time aTime, Time* aEnd = nullptr, Time* aStart = nullptr) const
-  {
-    if (mChanges.IsEmpty() || aTime < mChanges[0].mTime) {
-      if (aStart) {
-        *aStart = INT64_MIN;
-      }
-      if (aEnd) {
-        *aEnd = mChanges.IsEmpty() ? INT64_MAX : mChanges[0].mTime;
-      }
-      return mCurrent;
-    }
-    int32_t changesLength = mChanges.Length();
-    if (mChanges[changesLength - 1].mTime <= aTime) {
-      if (aEnd) {
-        *aEnd = INT64_MAX;
-      }
-      if (aStart) {
-        *aStart = mChanges[changesLength - 1].mTime;
-      }
-      return mChanges[changesLength - 1].mValue;
-    }
-
-    for (uint32_t i = 1; ; ++i) {
-      if (aTime < mChanges[i].mTime) {
-        if (aEnd) {
-          *aEnd = mChanges[i].mTime;
-        }
-        if (aStart) {
-          *aStart = mChanges[i - 1].mTime;
-        }
-        NS_ASSERTION(mChanges[i].mValue != mChanges[i - 1].mValue,
-                     "Only changed values appear in array");
-        return mChanges[i - 1].mValue;
-      }
-    }
-  }
-  /**
-   * Advance the current time to aTime.
-   */
-  void AdvanceCurrentTime(Time aTime)
-  {
-    for (uint32_t i = 0; i < mChanges.Length(); ++i) {
-      if (aTime < mChanges[i].mTime) {
-        mChanges.RemoveElementsAt(0, i);
-        return;
-      }
-      mCurrent = mChanges[i].mValue;
-    }
-    mChanges.Clear();
-  }
-  /**
-   * Make all currently pending changes happen aDelta later than their
-   * current change times.
-   */
-  void InsertTimeAtStart(Time aDelta)
-  {
-    for (uint32_t i = 0; i < mChanges.Length(); ++i) {
-      mChanges[i].mTime += aDelta;
-    }
-  }
-
-  /**
-   * Replace the values of this function at aTimeOffset and later with the
-   * values of aOther taken from zero, so if aOther is V at time T >= 0
-   * then this function will be V at time T + aTimeOffset. aOther's current
-   * time must be >= 0.
-   */
-  void Append(const TimeVarying& aOther, Time aTimeOffset)
-  {
-    NS_ASSERTION(aOther.mChanges.IsEmpty() || aOther.mChanges[0].mTime >= 0,
-                 "Negative time not allowed here");
-    NS_ASSERTION(&aOther != this, "Can't self-append");
-    SetAtAndAfter(aTimeOffset, aOther.mCurrent);
-    for (uint32_t i = 0; i < aOther.mChanges.Length(); ++i) {
-      const Entry& e = aOther.mChanges[i];
-      SetAtAndAfter(aTimeOffset + e.mTime, e.mValue);
-    }
-  }
-
-  size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const
-  {
-    return mChanges.ShallowSizeOfExcludingThis(aMallocSizeOf);
-  }
-
-private:
-  struct Entry {
-    Entry(Time aTime, const T& aValue) : mTime(aTime), mValue(aValue) {}
-
-    // The time at which the value changes to mValue
-    Time mTime;
-    T mValue;
-  };
-  nsAutoTArray<Entry, ReservedChanges> mChanges;
-  T mCurrent;
-};
-
-} // namespace mozilla
-
-#endif /* MOZILLA_TIMEVARYING_H_ */
--- a/dom/media/moz.build
+++ b/dom/media/moz.build
@@ -139,17 +139,16 @@ EXPORTS += [
     'MP3FrameParser.h',
     'nsIDocumentActivity.h',
     'RtspMediaResource.h',
     'SelfRef.h',
     'SharedBuffer.h',
     'StreamBuffer.h',
     'ThreadPoolCOMListener.h',
     'TimeUnits.h',
-    'TimeVarying.h',
     'TrackUnionStream.h',
     'VideoFrameContainer.h',
     'VideoSegment.h',
     'VideoUtils.h',
     'VorbisUtils.h',
     'XiphExtradata.h',
 ]