diff --git a/content/media/AudioEventTimeline.h b/content/media/AudioEventTimeline.h index dff1871c147..e42b670ecff 100644 --- a/content/media/AudioEventTimeline.h +++ b/content/media/AudioEventTimeline.h @@ -249,22 +249,7 @@ public: // 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(), next->mValue, aTime); - case AudioTimelineEvent::ExponentialRamp: - // Use t=0 as T0 and v=defaultValue as V0 - return ExponentialInterpolate(0.0, mValue, next->template Time(), 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) diff --git a/content/media/webaudio/compiledtest/TestAudioEventTimeline.cpp b/content/media/webaudio/compiledtest/TestAudioEventTimeline.cpp index 6e0cabe17f9..7ff0bed8361 100644 --- a/content/media/webaudio/compiledtest/TestAudioEventTimeline.cpp +++ b/content/media/webaudio/compiledtest/TestAudioEventTimeline.cpp @@ -215,7 +215,7 @@ void TestEventRemoval() is(timeline.GetEventCount(), 1u, "Should successfully delete two events"); } -void TestBeforeFirstEvent() +void TestBeforeFirstEventSetValue() { Timeline timeline(10.0f); @@ -225,6 +225,36 @@ void TestBeforeFirstEvent() 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); @@ -361,7 +391,10 @@ int main() TestInvalidEvents(); TestEventReplacement(); TestEventRemoval(); - TestBeforeFirstEvent(); + TestBeforeFirstEventSetValue(); + TestBeforeFirstEventSetTarget(); + TestBeforeFirstEventLinearRamp(); + TestBeforeFirstEventExponentialRamp(); TestAfterLastValueEvent(); TestAfterLastTargetValueEvent(); TestAfterLastTargetValueEventWithValueSet();