Bug 857793 - Always return the defaultValue before the first scheduled event on an AudioParam; r=roc

This commit is contained in:
Ehsan Akhgari 2013-04-03 17:31:42 -04:00
parent 425c80f927
commit 5e9cc4e408
2 changed files with 36 additions and 18 deletions

View File

@ -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<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)

View File

@ -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();