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

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

Issue 2028773002: setValueCurveAtTime has implicit setValueAtTime at end (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and expand comment. Created 4 years, 6 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
« no previous file with comments | « third_party/WebKit/LayoutTests/webaudio/audioparam-setValueCurve-exceptions-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 e31f39312506660df16f89bc0b40f01a4b78146e..85ee0a196b442aba014fa2485fb74cea182f3525 100644
--- a/third_party/WebKit/Source/modules/webaudio/AudioParamTimeline.cpp
+++ b/third_party/WebKit/Source/modules/webaudio/AudioParamTimeline.cpp
@@ -225,6 +225,11 @@ void AudioParamTimeline::setValueCurveAtTime(DOMFloat32Array* curve, double time
}
insertEvent(ParamEvent::createSetValueCurveEvent(curve, time, duration), exceptionState);
+
+ // Insert a setValueAtTime event too to establish an event so that all
+ // following events will process from the end of the curve instead of the
+ // beginning.
+ insertEvent(ParamEvent::createSetValueEvent(curve->data()[curve->length() - 1], time + duration), exceptionState);
}
void AudioParamTimeline::insertEvent(const ParamEvent& event, ExceptionState& exceptionState)
@@ -431,6 +436,19 @@ float AudioParamTimeline::valuesForFrameRangeImpl(
ParamEvent* nextEvent = i < n - 1 ? &(m_events[i + 1]) : 0;
// Wait until we get a more recent event.
+ //
+ // WARNING: due to round-off it might happen that nextEvent->time() is
+ // just larger than currentFrame/sampleRate. This means that we will end
+ // up running the |event| again. The code below had better be prepared
+ // for this case! What should happen is the fillToFrame should be 0 so
+ // that while the event is actually run again, nothing actually gets
+ // computed, and we move on to the next event.
+ //
+ // An example of this case is setValueCurveAtTime. The time at which
+ // setValueCurveAtTime ends (and the setValueAtTime begins) might be
+ // just past currentTime/sampleRate. Then setValueCurveAtTime will be
+ // processed again before advancing to setValueAtTime. The number of
+ // frames to be processed should be zero in this case.
if (nextEvent && nextEvent->time() < currentFrame / sampleRate) {
// But if the current event is a SetValue event and the event time is between
// currentFrame - 1 and curentFrame (in time). we don't want to skip it. If we do skip
@@ -875,7 +893,7 @@ float AudioParamTimeline::valuesForFrameRangeImpl(
values[writeIndex] = value;
// Re-adjust current time
- currentFrame = nextEventFillToFrame;
+ currentFrame += nextEventFillToFrame;
break;
}
« no previous file with comments | « third_party/WebKit/LayoutTests/webaudio/audioparam-setValueCurve-exceptions-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698