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

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

Issue 2016563002: AudioParam.setValueCurveAtTime() should copy the curve data (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address review comments Created 4 years, 7 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/Source/modules/webaudio/AudioParamTimeline.h ('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 54068c6a3b81c2422a1e44129231095271c94822..15e9958ffe4a50cad2369083befe2884ce65fc6b 100644
--- a/third_party/WebKit/Source/modules/webaudio/AudioParamTimeline.cpp
+++ b/third_party/WebKit/Source/modules/webaudio/AudioParamTimeline.cpp
@@ -109,6 +109,26 @@ String AudioParamTimeline::eventToString(const ParamEvent& event)
return s + "(" + args + ")";
}
+AudioParamTimeline::ParamEvent::ParamEvent(
+ Type type, float value, double time,
+ double timeConstant, double duration, const DOMFloat32Array* curve,
+ float initialValue, double callTime)
+ : m_type(type)
+ , m_value(value)
+ , m_time(time)
+ , m_timeConstant(timeConstant)
+ , m_duration(duration)
+ , m_initialValue(initialValue)
+ , m_callTime(callTime)
+{
+ if (curve) {
+ // Copy the curve data
+ unsigned curveLength = curve->length();
+ m_curve.resize(curveLength);
+ memcpy(m_curve.data(), curve->data(), curveLength * sizeof(float));
+ }
+}
+
AudioParamTimeline::ParamEvent AudioParamTimeline::ParamEvent::createSetValueEvent(float value, double time)
{
return ParamEvent(ParamEvent::SetValue, value, time, 0, 0, nullptr);
@@ -129,7 +149,7 @@ AudioParamTimeline::ParamEvent AudioParamTimeline::ParamEvent::createSetTargetEv
return ParamEvent(ParamEvent::SetTarget, value, time, timeConstant, 0, nullptr);
}
-AudioParamTimeline::ParamEvent AudioParamTimeline::ParamEvent::createSetValueCurveEvent(DOMFloat32Array* curve, double time, double duration)
+AudioParamTimeline::ParamEvent AudioParamTimeline::ParamEvent::createSetValueCurveEvent(const DOMFloat32Array* curve, double time, double duration)
{
return ParamEvent(ParamEvent::SetValueCurve, 0, time, 0, duration, curve);
}
@@ -699,9 +719,9 @@ float AudioParamTimeline::valuesForFrameRangeImpl(
case ParamEvent::SetValueCurve:
{
- DOMFloat32Array* curve = event.curve();
- float* curveData = curve ? curve->data() : 0;
- unsigned numberOfCurvePoints = curve ? curve->length() : 0;
+ Vector<float> curve = event.curve();
+ float* curveData = curve.data();
+ unsigned numberOfCurvePoints = curve.size();
// Curve events have duration, so don't just use next event time.
double duration = event.duration();
@@ -709,7 +729,7 @@ float AudioParamTimeline::valuesForFrameRangeImpl(
// (N - 1)/Td in the specification.
double curvePointsPerFrame = (numberOfCurvePoints - 1) / duration / sampleRate;
- if (!curve || !curveData || !numberOfCurvePoints || duration <= 0 || sampleRate <= 0) {
+ if (!numberOfCurvePoints || duration <= 0 || sampleRate <= 0) {
// Error condition - simply propagate previous value.
currentFrame = fillToEndFrame;
for (; writeIndex < fillToFrame; ++writeIndex)
« no previous file with comments | « third_party/WebKit/Source/modules/webaudio/AudioParamTimeline.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698