Index: third_party/WebKit/Source/modules/webaudio/AudioParamTimeline.cpp |
diff --git a/third_party/WebKit/Source/modules/webaudio/AudioParamTimeline.cpp b/third_party/WebKit/Source/modules/webaudio/AudioParamTimeline.cpp |
index 35731182aa8088b21deb7f47a87c1c8cdf21436e..8af3567c9949ea90f488513c67fb65234e07e7b1 100644 |
--- a/third_party/WebKit/Source/modules/webaudio/AudioParamTimeline.cpp |
+++ b/third_party/WebKit/Source/modules/webaudio/AudioParamTimeline.cpp |
@@ -164,6 +164,10 @@ AudioParamTimeline::ParamEvent |
AudioParamTimeline::ParamEvent::createSetTargetEvent(float value, |
double time, |
double timeConstant) { |
+ // The time line code does not expect a timeConstant of 0. (IT |
hongchan
2016/10/31 20:50:43
typo: "(IT" -> "It"
|
+ // returns NaN or Infinity due to division by zero. The caller |
+ // should have converted this to a SetValueEvent. |
+ DCHECK_NE(timeConstant, 0); |
return ParamEvent(ParamEvent::SetTarget, value, time, timeConstant, 0, |
nullptr); |
} |
@@ -236,11 +240,18 @@ void AudioParamTimeline::setTargetAtTime(float target, |
DCHECK(isMainThread()); |
if (!isNonNegativeAudioParamTime(time, exceptionState) || |
- !isPositiveAudioParamTime(timeConstant, exceptionState, "Time constant")) |
+ !isNonNegativeAudioParamTime(timeConstant, exceptionState, |
+ "Time constant")) |
return; |
- insertEvent(ParamEvent::createSetTargetEvent(target, time, timeConstant), |
- exceptionState); |
+ // If timeConstant = 0, we instantly jump to the target value, so |
+ // insert a SetValueEvent instead of SetTargetEvent. |
+ if (timeConstant == 0) { |
+ insertEvent(ParamEvent::createSetValueEvent(target, time), exceptionState); |
+ } else { |
+ insertEvent(ParamEvent::createSetTargetEvent(target, time, timeConstant), |
+ exceptionState); |
+ } |
} |
void AudioParamTimeline::setValueCurveAtTime(DOMFloat32Array* curve, |