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

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

Issue 1928163002: Add a name attribute for each AudioParam (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix compilation error Created 4 years, 8 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 ca19b338b1091abac85586456c6d1638ab53e32a..42bffe793b960d2e3a94a66092b39c76a47f341a 100644
--- a/third_party/WebKit/Source/modules/webaudio/AudioParam.h
+++ b/third_party/WebKit/Source/modules/webaudio/AudioParam.h
@@ -43,6 +43,28 @@ namespace blink {
class AudioNodeOutput;
+// Each AudioParam gets an identifier here. This is mostly for instrospection if warnings or
+// other messages need to be printed. It's useful to know what the AudioParam represents. The
+// name should include the node type and the name of the AudioParam.
+enum AudioParamType {
+ ParamTypeAudioBufferSourcePlaybackRate,
+ ParamTypeAudioBufferSourceDetune,
+ ParamTypeBiquadFilterFrequency,
+ ParamTypeBiquadFilterQ,
+ ParamTypeBiquadFilterGain,
+ ParamTypeBiquadFilterDetune,
+ ParamTypeDelayDelayTime,
+ ParamTypeDynamicsCompressorThreshold,
+ ParamTypeDynamicsCompressorKnee,
+ ParamTypeDynamicsCompressorRatio,
+ ParamTypeDynamicsCompressorAttack,
+ ParamTypeDynamicsCompressorRelease,
+ ParamTypeGainGain,
+ ParamTypeOscillatorFrequency,
+ ParamTypeOscillatorDetune,
+ ParamTypeStereoPannerPan
+};
+
// AudioParamHandler is an actual implementation of web-exposed AudioParam
// interface. Each of AudioParam object creates and owns an AudioParamHandler,
// and it is responsible for all of AudioParam tasks. An AudioParamHandler
@@ -52,12 +74,16 @@ class AudioNodeOutput;
// dies.
class AudioParamHandler final : public ThreadSafeRefCounted<AudioParamHandler>, public AudioSummingJunction {
public:
+ AudioParamType getParamType() const { return m_paramType; }
+ // Return a nice name for the AudioParam.
+ String getParamName() const;
+
static const double DefaultSmoothingConstant;
static const double SnapThreshold;
- static PassRefPtr<AudioParamHandler> create(AbstractAudioContext& context, double defaultValue)
+ static PassRefPtr<AudioParamHandler> create(AbstractAudioContext& context, AudioParamType paramType, double defaultValue)
{
- return adoptRef(new AudioParamHandler(context, defaultValue));
+ return adoptRef(new AudioParamHandler(context, paramType, defaultValue));
}
// This should be used only in audio rendering thread.
@@ -102,8 +128,9 @@ public:
float intrinsicValue() const { return noBarrierLoad(&m_intrinsicValue); }
private:
- AudioParamHandler(AbstractAudioContext& context, double defaultValue)
+ AudioParamHandler(AbstractAudioContext& context, AudioParamType paramType, double defaultValue)
: AudioSummingJunction(context.deferredTaskHandler())
+ , m_paramType(paramType)
, m_intrinsicValue(defaultValue)
, m_defaultValue(defaultValue)
, m_smoothedValue(defaultValue)
@@ -114,6 +141,10 @@ private:
void calculateFinalValues(float* values, unsigned numberOfValues, bool sampleAccurate);
void calculateTimelineValues(float* values, unsigned numberOfValues);
+ // The type of AudioParam, indicating what this AudioParam represents and what node it belongs
+ // to. Mostly for informational purposes and doesn't affect implementation.
+ AudioParamType m_paramType;
+
// Intrinsic value
float m_intrinsicValue;
void setIntrinsicValue(float newValue) { noBarrierStore(&m_intrinsicValue, newValue); }
@@ -133,13 +164,16 @@ private:
class AudioParam final : public GarbageCollectedFinalized<AudioParam>, public ScriptWrappable {
DEFINE_WRAPPERTYPEINFO();
public:
- static AudioParam* create(AbstractAudioContext&, double defaultValue);
+ static AudioParam* create(AbstractAudioContext&, AudioParamType, double defaultValue);
DECLARE_TRACE();
// |handler| always returns a valid object.
AudioParamHandler& handler() const { return *m_handler; }
// |context| always returns a valid object.
AbstractAudioContext* context() const { return m_context; }
+ AudioParamType getParamType() const { return handler().getParamType(); }
+ String getParamName() const;
+
float value() const;
void setValue(float);
float defaultValue() const;
@@ -151,7 +185,7 @@ public:
AudioParam* cancelScheduledValues(double startTime, ExceptionState&);
private:
- AudioParam(AbstractAudioContext&, double defaultValue);
+ AudioParam(AbstractAudioContext&, AudioParamType, double defaultValue);
RefPtr<AudioParamHandler> m_handler;
Member<AbstractAudioContext> m_context;

Powered by Google App Engine
This is Rietveld 408576698