Bug 857793 - Always return the defaultValue before the first scheduled event on an AudioParam; r=roc
authorEhsan Akhgari <ehsan@mozilla.com>
Wed, 03 Apr 2013 17:31:42 -0400
changeset 127566 66ff22df8956d7416a5764831903b6375d11c696
parent 127565 8084f411a027748411643040c44b21a156ed810f
child 127567 0673f4718ee2d6df39b4efb829882d15f79f7129
push id25859
push usereakhgari@mozilla.com
push dateWed, 03 Apr 2013 22:58:05 +0000
treeherdermozilla-inbound@66ff22df8956 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs857793
milestone23.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 857793 - Always return the defaultValue before the first scheduled event on an AudioParam; r=roc
content/media/AudioEventTimeline.h
content/media/webaudio/compiledtest/TestAudioEventTimeline.cpp
--- a/content/media/AudioEventTimeline.h
+++ b/content/media/AudioEventTimeline.h
@@ -244,32 +244,17 @@ public:
 
     // Just return the default value if we did not find anything
     if (!previous && !next) {
       return mValue;
     }
 
     // If the requested time is before all of the existing events
     if (!previous) {
-      switch (next->mType) {
-      case AudioTimelineEvent::SetValue:
-      case AudioTimelineEvent::SetTarget:
-        // The requested time is before the first event
-        return mValue;
-      case AudioTimelineEvent::LinearRamp:
-        // Use t=0 as T0 and v=defaultValue as V0
-        return LinearInterpolate(0.0, mValue, next->template Time<TimeType>(), next->mValue, aTime);
-      case AudioTimelineEvent::ExponentialRamp:
-        // Use t=0 as T0 and v=defaultValue as V0
-        return ExponentialInterpolate(0.0, mValue, next->template Time<TimeType>(), next->mValue, aTime);
-      case AudioTimelineEvent::SetValueCurve:
-        // TODO: implement
-        return 0.0f;
-      }
-      MOZ_ASSERT(false, "unreached");
+      return mValue;
     }
 
     // SetTarget nodes can be handled no matter what their next node is (if they have one)
     if (previous->mType == AudioTimelineEvent::SetTarget) {
       // Follow the curve, without regard to the next node
       return ExponentialApproach(previous->template Time<TimeType>(), mValue, previous->mValue,
                                  previous->mTimeConstant, aTime);
     }
--- a/content/media/webaudio/compiledtest/TestAudioEventTimeline.cpp
+++ b/content/media/webaudio/compiledtest/TestAudioEventTimeline.cpp
@@ -210,26 +210,56 @@ void TestEventRemoval()
   timeline.CancelScheduledValues(0.4);
   is(timeline.GetEventCount(), 4u, "Trying to delete past the end of the array should have no effect");
   timeline.CancelScheduledValues(0.3);
   is(timeline.GetEventCount(), 3u, "Should successfully delete one event");
   timeline.CancelScheduledValues(0.12);
   is(timeline.GetEventCount(), 1u, "Should successfully delete two events");
 }
 
-void TestBeforeFirstEvent()
+void TestBeforeFirstEventSetValue()
 {
   Timeline timeline(10.0f);
 
   ErrorResultMock rv;
 
   timeline.SetValueAtTime(20.0f, 1.0, rv);
   is(timeline.GetValueAtTime(0.5), 10.0f, "Retrun the default value before the first event");
 }
 
+void TestBeforeFirstEventSetTarget()
+{
+  Timeline timeline(10.0f);
+
+  ErrorResultMock rv;
+
+  timeline.SetTargetAtTime(20.0f, 1.0, 5.0, rv);
+  is(timeline.GetValueAtTime(0.5), 10.0f, "Retrun the default value before the first event");
+}
+
+void TestBeforeFirstEventLinearRamp()
+{
+  Timeline timeline(10.0f);
+
+  ErrorResultMock rv;
+
+  timeline.LinearRampToValueAtTime(20.0f, 1.0, rv);
+  is(timeline.GetValueAtTime(0.5), 10.0f, "Retrun the default value before the first event");
+}
+
+void TestBeforeFirstEventExponentialRamp()
+{
+  Timeline timeline(10.0f);
+
+  ErrorResultMock rv;
+
+  timeline.ExponentialRampToValueAtTime(20.0f, 1.0, rv);
+  is(timeline.GetValueAtTime(0.5), 10.0f, "Retrun the default value before the first event");
+}
+
 void TestAfterLastValueEvent()
 {
   Timeline timeline(10.0f);
 
   ErrorResultMock rv;
 
   timeline.SetValueAtTime(20.0f, 1.0, rv);
   is(timeline.GetValueAtTime(1.5), 20.0f, "Return the last value after the last SetValue event");
@@ -356,17 +386,20 @@ int main()
   if (xpcom.failed()) {
     return 1;
   }
 
   TestSpecExample();
   TestInvalidEvents();
   TestEventReplacement();
   TestEventRemoval();
-  TestBeforeFirstEvent();
+  TestBeforeFirstEventSetValue();
+  TestBeforeFirstEventSetTarget();
+  TestBeforeFirstEventLinearRamp();
+  TestBeforeFirstEventExponentialRamp();
   TestAfterLastValueEvent();
   TestAfterLastTargetValueEvent();
   TestAfterLastTargetValueEventWithValueSet();
   TestValue();
   TestLinearRampAtZero();
   TestExponentialRampAtZero();
   TestLinearRampAtSameTime();
   TestExponentialRampAtSameTime();