Bug 952893. Part 3: Tighten TimeVarying invariants so that GetAt always returns an end time when the value actually changes. r=padenot
authorRobert O'Callahan <robert@ocallahan.org>
Thu, 16 Jan 2014 00:13:08 +1300
changeset 181776 780cba0f9f5979c810c54c08e3ff23456b63817b
parent 181775 887fe3a09c3dab4559f1ae6b9089cafb47b87e59
child 181777 f69689b1d01ea7e409d2f6d2368591ce5bd7a834
push id3343
push userffxbld
push dateMon, 17 Mar 2014 21:55:32 +0000
treeherdermozilla-beta@2f7d3415f79f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspadenot
bugs952893
milestone29.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 952893. Part 3: Tighten TimeVarying invariants so that GetAt always returns an end time when the value actually changes. r=padenot * * * Bug 952893 - Fix the rebase.
content/media/TimeVarying.h
content/media/webaudio/AudioDestinationNode.h
--- a/content/media/TimeVarying.h
+++ b/content/media/TimeVarying.h
@@ -39,16 +39,19 @@ protected:
  * 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:
   TimeVarying(const T& aInitial) : mCurrent(aInitial) {}
   /**
    * This constructor can only be called if mCurrent has a no-argument
    * constructor.
@@ -74,16 +77,19 @@ public:
           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
--- a/content/media/webaudio/AudioDestinationNode.h
+++ b/content/media/webaudio/AudioDestinationNode.h
@@ -88,25 +88,21 @@ private:
 
   SelfReference<AudioDestinationNode> mOfflineRenderingRef;
   uint32_t mFramesToProduce;
 
   nsCOMPtr<nsIAudioChannelAgent> mAudioChannelAgent;
 
   // Audio Channel Type.
   AudioChannel mAudioChannel;
-<<<<<<< /home/roc/mozilla-central/content/media/webaudio/AudioDestinationNode.h
   bool mIsOffline;
   bool mHasFinished;
-=======
-
   TimeStamp mStartedBlockingDueToBeingOnlyNode;
   double mExtraCurrentTime;
   double mExtraCurrentTimeSinceLastStartedBlocking;
   bool mExtraCurrentTimeUpdatedSinceLastStableState;
->>>>>>> /tmp/AudioDestinationNode.h~other.MvuUBx
 };
 
 }
 }
 
 #endif