Bug 1134034 - Add a chrome-only parentId and name on AudioParam for devtools. r=ehsan

This commit is contained in:
Paul Adenot 2015-04-14 17:03:52 +02:00
parent 9ac2974974
commit 438010fba4
12 changed files with 91 additions and 18 deletions

View File

@ -558,8 +558,8 @@ AudioBufferSourceNode::AudioBufferSourceNode(AudioContext* aContext)
, mLoopStart(0.0)
, mLoopEnd(0.0)
// mOffset and mDuration are initialized in Start().
, mPlaybackRate(new AudioParam(this, SendPlaybackRateToStream, 1.0f))
, mDetune(new AudioParam(this, SendDetuneToStream, 0.0f))
, mPlaybackRate(new AudioParam(this, SendPlaybackRateToStream, 1.0f, "playbackRate"))
, mDetune(new AudioParam(this, SendDetuneToStream, 0.0f, "detune"))
, mLoop(false)
, mStartCalled(false)
, mStopped(false)

View File

@ -45,11 +45,13 @@ NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(AudioParam, Release)
AudioParam::AudioParam(AudioNode* aNode,
AudioParam::CallbackType aCallback,
float aDefaultValue)
float aDefaultValue,
const char* aName)
: AudioParamTimeline(aDefaultValue)
, mNode(aNode)
, mCallback(aCallback)
, mDefaultValue(aDefaultValue)
, mName(aName)
{
}

View File

@ -30,7 +30,8 @@ public:
AudioParam(AudioNode* aNode,
CallbackType aCallback,
float aDefaultValue);
float aDefaultValue,
const char* aName);
NS_IMETHOD_(MozExternalRefCountType) AddRef(void);
NS_IMETHOD_(MozExternalRefCountType) Release(void);
@ -121,6 +122,16 @@ public:
mCallback(mNode);
}
uint32_t ParentNodeId()
{
return mNode->Id();
}
void GetName(nsAString& aName)
{
aName.AssignASCII(mName);
}
float DefaultValue() const
{
return mDefaultValue;
@ -183,6 +194,7 @@ private:
nsTArray<AudioNode::InputNode> mInputNodes;
CallbackType mCallback;
const float mDefaultValue;
const char* mName;
// The input port used to connect the AudioParam's stream to its node's stream
nsRefPtr<MediaInputPort> mNodeStreamPort;
};

View File

@ -244,10 +244,10 @@ BiquadFilterNode::BiquadFilterNode(AudioContext* aContext)
ChannelCountMode::Max,
ChannelInterpretation::Speakers)
, mType(BiquadFilterType::Lowpass)
, mFrequency(new AudioParam(this, SendFrequencyToStream, 350.f))
, mDetune(new AudioParam(this, SendDetuneToStream, 0.f))
, mQ(new AudioParam(this, SendQToStream, 1.f))
, mGain(new AudioParam(this, SendGainToStream, 0.f))
, mFrequency(new AudioParam(this, SendFrequencyToStream, 350.f, "frequency"))
, mDetune(new AudioParam(this, SendDetuneToStream, 0.f, "detune"))
, mQ(new AudioParam(this, SendQToStream, 1.f, "Q"))
, mGain(new AudioParam(this, SendGainToStream, 0.f, "gain"))
{
BiquadFilterNodeEngine* engine = new BiquadFilterNodeEngine(this, aContext->Destination());
mStream = aContext->Graph()->CreateAudioNodeStream(engine, MediaStreamGraph::INTERNAL_STREAM);

View File

@ -190,7 +190,7 @@ DelayNode::DelayNode(AudioContext* aContext, double aMaxDelay)
2,
ChannelCountMode::Max,
ChannelInterpretation::Speakers)
, mDelay(new AudioParam(this, SendDelayToStream, 0.0f))
, mDelay(new AudioParam(this, SendDelayToStream, 0.0f, "delayTime"))
{
DelayNodeEngine* engine =
new DelayNodeEngine(this, aContext->Destination(),

View File

@ -201,12 +201,12 @@ DynamicsCompressorNode::DynamicsCompressorNode(AudioContext* aContext)
2,
ChannelCountMode::Explicit,
ChannelInterpretation::Speakers)
, mThreshold(new AudioParam(this, SendThresholdToStream, -24.f))
, mKnee(new AudioParam(this, SendKneeToStream, 30.f))
, mRatio(new AudioParam(this, SendRatioToStream, 12.f))
, mThreshold(new AudioParam(this, SendThresholdToStream, -24.f, "threshold"))
, mKnee(new AudioParam(this, SendKneeToStream, 30.f, "knee"))
, mRatio(new AudioParam(this, SendRatioToStream, 12.f, "ratio"))
, mReduction(0)
, mAttack(new AudioParam(this, SendAttackToStream, 0.003f))
, mRelease(new AudioParam(this, SendReleaseToStream, 0.25f))
, mAttack(new AudioParam(this, SendAttackToStream, 0.003f, "attack"))
, mRelease(new AudioParam(this, SendReleaseToStream, 0.25f, "release"))
{
DynamicsCompressorNodeEngine* engine = new DynamicsCompressorNodeEngine(this, aContext->Destination());
mStream = aContext->Graph()->CreateAudioNodeStream(engine, MediaStreamGraph::INTERNAL_STREAM);

View File

@ -125,7 +125,7 @@ GainNode::GainNode(AudioContext* aContext)
2,
ChannelCountMode::Max,
ChannelInterpretation::Speakers)
, mGain(new AudioParam(this, SendGainToStream, 1.0f))
, mGain(new AudioParam(this, SendGainToStream, 1.0f, "gain"))
{
GainNodeEngine* engine = new GainNodeEngine(this, aContext->Destination());
mStream = aContext->Graph()->CreateAudioNodeStream(engine, MediaStreamGraph::INTERNAL_STREAM);

View File

@ -381,8 +381,8 @@ OscillatorNode::OscillatorNode(AudioContext* aContext)
ChannelCountMode::Max,
ChannelInterpretation::Speakers)
, mType(OscillatorType::Sine)
, mFrequency(new AudioParam(this, SendFrequencyToStream, 440.0f))
, mDetune(new AudioParam(this, SendDetuneToStream, 0.0f))
, mFrequency(new AudioParam(this, SendFrequencyToStream, 440.0f, "frequency"))
, mDetune(new AudioParam(this, SendDetuneToStream, 0.0f, "detune"))
, mStartCalled(false)
, mStopped(false)
{

View File

@ -176,7 +176,7 @@ StereoPannerNode::StereoPannerNode(AudioContext* aContext)
2,
ChannelCountMode::Clamped_max,
ChannelInterpretation::Speakers)
, mPan(new AudioParam(this, SendPanToStream, 0.f))
, mPan(new AudioParam(this, SendPanToStream, 0.f, "pan"))
{
StereoPannerNodeEngine* engine = new StereoPannerNodeEngine(this, aContext->Destination());
mStream = aContext->Graph()->CreateAudioNodeStream(engine,

View File

@ -2,3 +2,4 @@
skip-if = buildapp == 'b2g'
[test_AudioNodeDevtoolsAPI.html]
[test_AudioParamDevtoolsAPI.html]

View File

@ -0,0 +1,48 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Test the devtool AudioParam API</title>
<script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
</head>
<body>
<pre id="test">
<script class="testbody" type="text/javascript">
Components.utils.import('resource://gre/modules/Services.jsm');
function checkIdAndName(node, name) {
is(node.id, node[name].parentNodeId, "The parent id should be correct");
is(node[name].name, name, "The name of the AudioParam should be correct.");
}
var ac = new AudioContext(),
gain = ac.createGain(),
osc = ac.createOscillator(),
del = ac.createDelay(),
source = ac.createBufferSource(),
stereoPanner = ac.createStereoPanner(),
comp = ac.createDynamicsCompressor(),
biquad = ac.createBiquadFilter();
checkIdAndName(gain, "gain");
checkIdAndName(osc, "frequency");
checkIdAndName(osc, "detune");
checkIdAndName(del, "delayTime");
checkIdAndName(source, "playbackRate");
checkIdAndName(source, "detune");
checkIdAndName(stereoPanner, "pan");
checkIdAndName(comp, "threshold");
checkIdAndName(comp, "knee");
checkIdAndName(comp, "ratio");
checkIdAndName(comp, "attack");
checkIdAndName(comp, "release");
checkIdAndName(biquad, "frequency");
checkIdAndName(biquad, "detune");
checkIdAndName(biquad, "Q");
checkIdAndName(biquad, "gain");
</script>
</pre>
</body>
</html>

View File

@ -37,3 +37,13 @@ interface AudioParam {
void cancelScheduledValues(double startTime);
};
// Mozilla extension
partial interface AudioParam {
// The ID of the AudioNode this AudioParam belongs to.
[ChromeOnly]
readonly attribute unsigned long parentNodeId;
// The name of the AudioParam
[ChromeOnly]
readonly attribute DOMString name;
};