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

Unified Diff: third_party/WebKit/Source/modules/webaudio/AudioParam.h

Issue 1803153002: Add min/max values for AudioParams (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add warnings for automations 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
Index: third_party/WebKit/Source/modules/webaudio/AudioParam.h
diff --git a/third_party/WebKit/Source/modules/webaudio/AudioParam.h b/third_party/WebKit/Source/modules/webaudio/AudioParam.h
index 86551572b463f1bb6846c99b2ae50d6407a5465e..e28fd386320c1b973247a695c3051115163930b6 100644
--- a/third_party/WebKit/Source/modules/webaudio/AudioParam.h
+++ b/third_party/WebKit/Source/modules/webaudio/AudioParam.h
@@ -84,9 +84,14 @@ public:
static const double DefaultSmoothingConstant;
static const double SnapThreshold;
- static PassRefPtr<AudioParamHandler> create(AbstractAudioContext& context, AudioParamType paramType, double defaultValue)
+ static PassRefPtr<AudioParamHandler> create(
+ AbstractAudioContext& context,
+ AudioParamType paramType,
+ double defaultValue,
+ float minValue,
+ float maxValue)
{
- return adoptRef(new AudioParamHandler(context, paramType, defaultValue));
+ return adoptRef(new AudioParamHandler(context, paramType, defaultValue, minValue, maxValue));
}
// This should be used only in audio rendering thread.
@@ -106,6 +111,8 @@ public:
float finalValue();
float defaultValue() const { return static_cast<float>(m_defaultValue); }
+ float minValue() const { return m_minValue; }
+ float maxValue() const { return m_maxValue; }
// Value smoothing:
@@ -135,7 +142,9 @@ public:
void updateHistograms(float newValue);
private:
- AudioParamHandler(AbstractAudioContext&, AudioParamType, double defaultValue);
+ AudioParamHandler(AbstractAudioContext&, AudioParamType, double defaultValue, float min, float max);
+
+ void warnIfOutsideRange(float value, float minValue, float maxValue);
// sampleAccurate corresponds to a-rate (audio rate) vs. k-rate in the Web Audio specification.
void calculateFinalValues(float* values, unsigned numberOfValues, bool sampleAccurate);
@@ -149,10 +158,14 @@ private:
// Intrinsic value
float m_intrinsicValue;
- void setIntrinsicValue(float newValue) { noBarrierStore(&m_intrinsicValue, newValue); }
+ void setIntrinsicValue(float newValue);
float m_defaultValue;
+ // Nominal range for the value
+ float m_minValue;
+ float m_maxValue;
+
// Smoothing (de-zippering)
float m_smoothedValue;
@@ -167,6 +180,8 @@ class AudioParam final : public GarbageCollectedFinalized<AudioParam>, public Sc
DEFINE_WRAPPERTYPEINFO();
public:
static AudioParam* create(AbstractAudioContext&, AudioParamType, double defaultValue);
+ static AudioParam* create(AbstractAudioContext&, AudioParamType, double defaultValue, float minValue, float maxValue);
+
DECLARE_TRACE();
// |handler| always returns a valid object.
AudioParamHandler& handler() const { return *m_handler; }
@@ -180,6 +195,10 @@ public:
float value() const;
void setValue(float);
float defaultValue() const;
+
+ float minValue() const;
+ float maxValue() const;
+
AudioParam* setValueAtTime(float value, double time, ExceptionState&);
AudioParam* linearRampToValueAtTime(float value, double time, ExceptionState&);
AudioParam* exponentialRampToValueAtTime(float value, double time, ExceptionState&);
@@ -188,7 +207,9 @@ public:
AudioParam* cancelScheduledValues(double startTime, ExceptionState&);
private:
- AudioParam(AbstractAudioContext&, AudioParamType, double defaultValue);
+ AudioParam(AbstractAudioContext&, AudioParamType, double defaultValue, float min, float max);
+
+ void warnIfOutsideRange(const String& paramMethd, float value);
RefPtr<AudioParamHandler> m_handler;
Member<AbstractAudioContext> m_context;

Powered by Google App Engine
This is Rietveld 408576698