Chromium Code Reviews| 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 4f120b5bb65cceb6e9da08b792a657024302dbe2..6b95a0aa2217fa972ba26b6e2cd572f396ce305a 100644 |
| --- a/third_party/WebKit/Source/modules/webaudio/AudioParamTimeline.cpp |
| +++ b/third_party/WebKit/Source/modules/webaudio/AudioParamTimeline.cpp |
| @@ -405,6 +405,19 @@ float AudioParamTimeline::valuesForFrameRangeImpl( |
| continue; |
| } |
| + ParamEvent::Type nextEventType = nextEvent ? static_cast<ParamEvent::Type>(nextEvent->type()) : ParamEvent::LastType /* unknown */; |
|
hongchan
2016/04/27 21:40:09
Are we okay with the comment style here? I've neve
Raymond Toy
2016/04/27 21:43:15
Don't know. I just basically moved this line up f
Raymond Toy
2016/04/27 22:57:03
It means a nextEventType equal to LastType indicat
|
| + |
| + // If the current event is SetTarget and the next event is a LinearRampToValue or |
| + // ExponentialRampToValue, special handling is needed. In this case, the linear and |
| + // exponential ramp should start at wherever the SetTarget processing has reached. |
| + if (event.type() == ParamEvent::SetTarget |
| + && (nextEventType == ParamEvent::LinearRampToValue |
| + || nextEventType == ParamEvent::ExponentialRampToValue)) { |
| + // Replace the SetTarget with a SetValue to set the starting time and value for the ramp |
| + // using the current frame and value. |
| + m_events[i] = ParamEvent::createSetValueEvent(value, currentFrame / sampleRate); |
| + } |
| + |
| float value1 = event.value(); |
| double time1 = event.time(); |
| @@ -433,7 +446,6 @@ float AudioParamTimeline::valuesForFrameRangeImpl( |
| size_t fillToFrame = fillToEndFrame - startFrame; |
| fillToFrame = std::min(fillToFrame, static_cast<size_t>(numberOfValues)); |
| - ParamEvent::Type nextEventType = nextEvent ? static_cast<ParamEvent::Type>(nextEvent->type()) : ParamEvent::LastType /* unknown */; |
| // First handle linear and exponential ramps which require looking ahead to the next event. |
| if (nextEventType == ParamEvent::LinearRampToValue) { |
| @@ -517,6 +529,10 @@ float AudioParamTimeline::valuesForFrameRangeImpl( |
| value *= multiplier; |
| ++currentFrame; |
| } |
| + // Due to roundoff it's possible that value exceeds value2. Clip value to value2 if |
| + // we are within 1/2 frame of time2. |
| + if (currentFrame > time2 * sampleRate - 0.5) |
| + value = value2; |
| } |
| } else { |
| // Handle event types not requiring looking ahead to the next event. |