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

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

Issue 2000423008: Clamp AudioParam automations to the nominal range. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase 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/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 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(
« 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