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 85ee0a196b442aba014fa2485fb74cea182f3525..804538f4b180589659861bd69a8d2dfcc24321a2 100644 |
| --- a/third_party/WebKit/Source/modules/webaudio/AudioParamTimeline.cpp |
| +++ b/third_party/WebKit/Source/modules/webaudio/AudioParamTimeline.cpp |
| @@ -337,7 +337,7 @@ void AudioParamTimeline::cancelScheduledValues(double startTime, ExceptionState& |
| } |
| } |
| -float AudioParamTimeline::valueForContextTime(AudioDestinationHandler& audioDestination, float defaultValue, bool& hasValue) |
| +float AudioParamTimeline::valueForContextTime(AudioDestinationHandler& audioDestination, float defaultValue, bool& hasValue, float minValue, float maxValue) |
| { |
| { |
| MutexTryLocker tryLocker(m_eventsLock); |
| @@ -352,7 +352,7 @@ float AudioParamTimeline::valueForContextTime(AudioDestinationHandler& audioDest |
| double sampleRate = audioDestination.sampleRate(); |
| size_t startFrame = audioDestination.currentSampleFrame(); |
| double controlRate = sampleRate / AudioHandler::ProcessingSizeInFrames; // one parameter change per render quantum |
| - value = valuesForFrameRange(startFrame, startFrame + 1, defaultValue, &value, 1, sampleRate, controlRate); |
| + value = valuesForFrameRange(startFrame, startFrame + 1, defaultValue, &value, 1, sampleRate, controlRate, minValue, maxValue); |
| hasValue = true; |
| return value; |
| @@ -365,7 +365,9 @@ float AudioParamTimeline::valuesForFrameRange( |
| float* values, |
| unsigned numberOfValues, |
| double sampleRate, |
| - double controlRate) |
| + double controlRate, |
| + float minValue, |
| + float maxValue) |
| { |
| // We can't contend the lock in the realtime audio thread. |
| MutexTryLocker tryLocker(m_eventsLock); |
| @@ -377,7 +379,13 @@ float AudioParamTimeline::valuesForFrameRange( |
| return defaultValue; |
| } |
|
hongchan
2016/06/17 17:00:40
Sorry to bring this up again, why this pattern is
Raymond Toy
2016/06/17 17:10:05
I didn't actually change this. Are you saying I s
hongchan
2016/06/17 17:55:06
Disregard my comment. They are different, but look
|
| - return valuesForFrameRangeImpl(startFrame, endFrame, defaultValue, values, numberOfValues, sampleRate, controlRate); |
| + float lastValue = valuesForFrameRangeImpl(startFrame, endFrame, defaultValue, values, numberOfValues, sampleRate, controlRate); |
| + |
| + // Clamp the values now to the nominal range |
| + for (unsigned k = 0; k < numberOfValues; ++k) |
| + values[k] = clampTo(values[k], minValue, maxValue); |
| + |
| + return lastValue; |
|
hongchan
2016/06/17 17:00:40
Are these safe outside of tryLock?
Raymond Toy
2016/06/17 17:10:05
I didn't really change the thread safety here. It
hongchan
2016/06/17 17:55:06
I misundstood the scope of tryLock. This looks saf
|
| } |
| float AudioParamTimeline::valuesForFrameRangeImpl( |