Bug 859602 - Remove AudioParam.minValue/maxValue; r=bzbarsky

This commit is contained in:
Ehsan Akhgari 2013-04-08 21:57:54 -04:00
parent 6f3b411b8e
commit 112a55b741
11 changed files with 13 additions and 77 deletions

View File

@ -20,19 +20,12 @@ NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(AudioParam, Release)
AudioParam::AudioParam(AudioNode* aNode,
AudioParam::CallbackType aCallback,
float aDefaultValue,
float aMinValue,
float aMaxValue)
float aDefaultValue)
: AudioParamTimeline(aDefaultValue)
, mNode(aNode)
, mCallback(aCallback)
, mDefaultValue(aDefaultValue)
, mMinValue(aMinValue)
, mMaxValue(aMaxValue)
{
MOZ_ASSERT(aDefaultValue >= aMinValue);
MOZ_ASSERT(aDefaultValue <= aMaxValue);
MOZ_ASSERT(aMinValue < aMaxValue);
SetIsDOMBinding();
}

View File

@ -34,9 +34,7 @@ public:
AudioParam(AudioNode* aNode,
CallbackType aCallback,
float aDefaultValue,
float aMinValue,
float aMaxValue);
float aDefaultValue);
virtual ~AudioParam();
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(AudioParam)
@ -96,16 +94,6 @@ public:
mCallback(mNode);
}
float MinValue() const
{
return mMinValue;
}
float MaxValue() const
{
return mMaxValue;
}
float DefaultValue() const
{
return mDefaultValue;
@ -115,8 +103,6 @@ private:
nsRefPtr<AudioNode> mNode;
CallbackType mCallback;
const float mDefaultValue;
const float mMinValue;
const float mMaxValue;
};
}

View File

@ -96,18 +96,12 @@ private:
AudioParamTimeline mGain;
};
static float
Nyquist(AudioContext* aContext)
{
return 0.5f * aContext->SampleRate();
}
BiquadFilterNode::BiquadFilterNode(AudioContext* aContext)
: AudioNode(aContext)
, mType(BiquadTypeEnum::LOWPASS)
, mFrequency(new AudioParam(this, SendFrequencyToStream, 350.f, 10.f, Nyquist(aContext)))
, mQ(new AudioParam(this, SendQToStream, 1.f, 0.0001f, 1000.f))
, mGain(new AudioParam(this, SendGainToStream, 0.f, -40.f, 40.f))
, mFrequency(new AudioParam(this, SendFrequencyToStream, 350.f))
, mQ(new AudioParam(this, SendQToStream, 1.f))
, mGain(new AudioParam(this, SendGainToStream, 0.f))
{
BiquadFilterNodeEngine* engine = new BiquadFilterNodeEngine(aContext->Destination());
mStream = aContext->Graph()->CreateAudioNodeStream(engine, MediaStreamGraph::INTERNAL_STREAM);

View File

@ -201,7 +201,7 @@ public:
DelayNode::DelayNode(AudioContext* aContext, double aMaxDelay)
: AudioNode(aContext)
, mDelay(new AudioParam(this, SendDelayToStream, 0.0f, 0.0f, float(aMaxDelay)))
, mDelay(new AudioParam(this, SendDelayToStream, 0.0f))
{
DelayNodeEngine* engine = new DelayNodeEngine(aContext->Destination());
mStream = aContext->Graph()->CreateAudioNodeStream(engine, MediaStreamGraph::INTERNAL_STREAM);

View File

@ -113,12 +113,12 @@ private:
DynamicsCompressorNode::DynamicsCompressorNode(AudioContext* aContext)
: AudioNode(aContext)
, mThreshold(new AudioParam(this, SendThresholdToStream, -24.f, -100.f, 0.f))
, mKnee(new AudioParam(this, SendKneeToStream, 30.f, 0.f, 40.f))
, mRatio(new AudioParam(this, SendRatioToStream, 12.f, 1.f, 20.f))
, mReduction(new AudioParam(this, SendReductionToStream, 0.f, -20.f, 0.f))
, mAttack(new AudioParam(this, SendAttackToStream, 0.003f, 0.f, 1.f))
, mRelease(new AudioParam(this, SendReleaseToStream, 0.25f, 0.f, 1.f))
, mThreshold(new AudioParam(this, SendThresholdToStream, -24.f))
, mKnee(new AudioParam(this, SendKneeToStream, 30.f))
, mRatio(new AudioParam(this, SendRatioToStream, 12.f))
, mReduction(new AudioParam(this, SendReductionToStream, 0.f))
, mAttack(new AudioParam(this, SendAttackToStream, 0.003f))
, mRelease(new AudioParam(this, SendReleaseToStream, 0.25f))
{
DynamicsCompressorNodeEngine* engine = new DynamicsCompressorNodeEngine(aContext->Destination());
mStream = aContext->Graph()->CreateAudioNodeStream(engine, MediaStreamGraph::INTERNAL_STREAM);

View File

@ -95,7 +95,7 @@ public:
GainNode::GainNode(AudioContext* aContext)
: AudioNode(aContext)
, mGain(new AudioParam(this, SendGainToStream, 1.0f, 0.0f, 1.0f))
, mGain(new AudioParam(this, SendGainToStream, 1.0f))
{
GainNodeEngine* engine = new GainNodeEngine(aContext->Destination());
mStream = aContext->Graph()->CreateAudioNodeStream(engine, MediaStreamGraph::INTERNAL_STREAM);

View File

@ -37,14 +37,8 @@ addLoadEvent(function() {
// Verify default values
is(filter.type, 0, "Correct default value for type");
near(filter.frequency.minValue, 10, "Correct min value for filter frequency");
near(filter.frequency.maxValue, context.sampleRate/2, "Correct max value for filter frequency");
near(filter.frequency.defaultValue, 350, "Correct default value for filter frequency");
near(filter.Q.minValue, 0.001, "Correct min value for filter Q");
near(filter.Q.maxValue, 1000, "Correct max value for filter Q");
near(filter.Q.defaultValue, 1, "Correct default value for filter Q");
near(filter.gain.minValue, -40, "Correct min value for filter gain");
near(filter.gain.maxValue, 40, "Correct max value for filter gain");
near(filter.gain.defaultValue, 0, "Correct default value for filter gain");
// Make sure that we can set all of the valid type values

View File

@ -34,24 +34,16 @@ addLoadEvent(function() {
ok(delay.delayTime, "The audioparam member must exist");
is(delay.delayTime.value, 0, "Correct initial value");
is(delay.delayTime.defaultValue, 0, "Correct default value");
is(delay.delayTime.minValue, 0, "Correct min value");
is(delay.delayTime.maxValue, 1.0, "Correct max value");
delay.delayTime.value = 0.5;
is(delay.delayTime.value, 0.5, "Correct initial value");
is(delay.delayTime.defaultValue, 0, "Correct default value");
is(delay.delayTime.minValue, 0, "Correct min value");
is(delay.delayTime.maxValue, 1.0, "Correct max value");
var delay2 = context.createDelay(2);
is(delay2.delayTime.value, 0, "Correct initial value");
is(delay2.delayTime.defaultValue, 0, "Correct default value");
is(delay2.delayTime.minValue, 0, "Correct min value");
is(delay2.delayTime.maxValue, 2.0, "Correct max value");
delay2.delayTime.value = 0.5;
is(delay2.delayTime.value, 0.5, "Correct initial value");
is(delay2.delayTime.defaultValue, 0, "Correct default value");
is(delay2.delayTime.minValue, 0, "Correct min value");
is(delay2.delayTime.maxValue, 2.0, "Correct max value");
expectException(function() {
context.createDelay(0);

View File

@ -44,22 +44,6 @@ addLoadEvent(function() {
near(release.defaultValue, 0.25, "Correct default value for release");
}
// Verify min/max values
with (compressor) {
near(threshold.minValue, -100, "Correct min value for threshold");
near(knee.minValue, 0, "Correct min value for knee");
near(ratio.minValue, 1, "Correct min value for ratio");
near(reduction.minValue, -20, "Correct min value for reduction");
near(attack.minValue, 0, "Correct min value for attack");
near(release.minValue, 0, "Correct min value for release");
near(threshold.maxValue, 0, "Correct max value for threshold");
near(knee.maxValue, 40, "Correct max value for knee");
near(ratio.maxValue, 20, "Correct max value for ratio");
near(reduction.maxValue, 0, "Correct max value for reduction");
near(attack.maxValue, 1, "Correct max value for attack");
near(release.maxValue, 1, "Correct max value for release");
}
source.start(0);
SimpleTest.executeSoon(function() {
source.stop(0);

View File

@ -33,13 +33,9 @@ addLoadEvent(function() {
ok(gain.gain, "The audioparam member must exist");
is(gain.gain.value, 1.0, "Correct initial value");
is(gain.gain.defaultValue, 1.0, "Correct default value");
is(gain.gain.minValue, 0, "Correct min value");
is(gain.gain.maxValue, 1.0, "Correct max value");
gain.gain.value = 0.5;
is(gain.gain.value, 0.5, "Correct initial value");
is(gain.gain.defaultValue, 1.0, "Correct default value");
is(gain.gain.minValue, 0, "Correct min value");
is(gain.gain.maxValue, 1.0, "Correct max value");
source.start(0);
SimpleTest.executeSoon(function() {

View File

@ -14,9 +14,6 @@
interface AudioParam {
attribute float value;
// readonly attribute float computedValue;
readonly attribute float minValue;
readonly attribute float maxValue;
readonly attribute float defaultValue;
// Parameter automation.