Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1494)

Unified Diff: third_party/WebKit/Source/modules/webaudio/AudioParamTimeline.cpp

Issue 2426893003: Allow timeConstant=0 for setTargetAtTime (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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,

Powered by Google App Engine
This is Rietveld 408576698