зеркало из https://github.com/mozilla/gecko-dev.git
Bug 859595 - Implement the alternate names for AudioBufferSourceNode, AudioContext and AudioParam; r=bzbarsky
Let this be mentioned in our code base history that I wrote this patch with tears in my eyes. This is the saddest thing I've ever had to do to Gecko. :( --HG-- extra : rebase_source : 798e5b1dc8af51a399189dd05bc59ac077670820
This commit is contained in:
Родитель
b40487a192
Коммит
c2ff4fe5ac
|
@ -54,7 +54,22 @@ public:
|
|||
|
||||
void Start(JSContext* aCx, double aWhen, double aOffset,
|
||||
const Optional<double>& aDuration, ErrorResult& aRv);
|
||||
void NoteOn(JSContext* aCx, double aWhen, ErrorResult& aRv)
|
||||
{
|
||||
Start(aCx, aWhen, 0.0, Optional<double>(), aRv);
|
||||
}
|
||||
void NoteGrainOn(JSContext* aCx, double aWhen, double aOffset,
|
||||
double aDuration, ErrorResult& aRv)
|
||||
{
|
||||
Optional<double> duration;
|
||||
duration.Construct(aDuration);
|
||||
Start(aCx, aWhen, aOffset, duration, aRv);
|
||||
}
|
||||
void Stop(double aWhen, ErrorResult& aRv);
|
||||
void NoteOff(double aWhen, ErrorResult& aRv)
|
||||
{
|
||||
Stop(aWhen, aRv);
|
||||
}
|
||||
|
||||
AudioBuffer* GetBuffer() const
|
||||
{
|
||||
|
|
|
@ -106,9 +106,21 @@ public:
|
|||
already_AddRefed<GainNode>
|
||||
CreateGain();
|
||||
|
||||
already_AddRefed<GainNode>
|
||||
CreateGainNode()
|
||||
{
|
||||
return CreateGain();
|
||||
}
|
||||
|
||||
already_AddRefed<DelayNode>
|
||||
CreateDelay(double aMaxDelayTime, ErrorResult& aRv);
|
||||
|
||||
already_AddRefed<DelayNode>
|
||||
CreateDelayNode(double aMaxDelayTime, ErrorResult& aRv)
|
||||
{
|
||||
return CreateDelay(aMaxDelayTime, aRv);
|
||||
}
|
||||
|
||||
already_AddRefed<PannerNode>
|
||||
CreatePanner();
|
||||
|
||||
|
|
|
@ -88,6 +88,10 @@ public:
|
|||
AudioParamTimeline::SetTargetAtTime(aTarget, aStartTime, aTimeConstant, aRv);
|
||||
mCallback(mNode);
|
||||
}
|
||||
void SetTargetValueAtTime(float aTarget, double aStartTime, double aTimeConstant, ErrorResult& aRv)
|
||||
{
|
||||
SetTargetAtTime(aTarget, aStartTime, aTimeConstant, aRv);
|
||||
}
|
||||
void CancelScheduledValues(double aStartTime)
|
||||
{
|
||||
AudioParamTimeline::CancelScheduledValues(aStartTime);
|
||||
|
|
|
@ -21,6 +21,7 @@ MOCHITEST_FILES := \
|
|||
test_AudioBuffer.html \
|
||||
test_AudioContext.html \
|
||||
test_AudioListener.html \
|
||||
test_AudioParam.html \
|
||||
test_badConnect.html \
|
||||
test_biquadFilterNode.html \
|
||||
test_currentTime.html \
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test AudioParam</title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="text/javascript" src="webaudio.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
SpecialPowers.setBoolPref("media.webaudio.enabled", true);
|
||||
|
||||
var context = new AudioContext();
|
||||
var gain = context.createGain().gain;
|
||||
|
||||
ok("value" in gain, "The value attr must exist");
|
||||
gain.value = 0.5;
|
||||
ok("defaultValue" in gain, "The defaultValue attr must exist");
|
||||
(function() {
|
||||
"use strict"; // in order to get the readOnly setter to throw
|
||||
expectTypeError(function() {
|
||||
gain.defaultValue = 0.5;
|
||||
});
|
||||
})();
|
||||
|
||||
gain.setValueAtTime(1, 0.25);
|
||||
gain.linearRampToValueAtTime(0.75, 0.5);
|
||||
gain.exponentialRampToValueAtTime(0.1, 0.75);
|
||||
gain.setTargetAtTime(0.2, 1, 0.5);
|
||||
gain.setTargetValueAtTime(0.3, 1.25, 0.5);
|
||||
gain.cancelScheduledValues(1.5);
|
||||
|
||||
SpecialPowers.clearUserPref("media.webaudio.enabled");
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
|
@ -26,6 +26,9 @@ addLoadEvent(function() {
|
|||
|
||||
var delay = context.createDelay();
|
||||
|
||||
var delay2 = context.createDelayNode();
|
||||
isnot(delay, delay2, "createDelayNode should create a different delay node");
|
||||
|
||||
source.buffer = buffer;
|
||||
|
||||
source.connect(delay);
|
||||
|
|
|
@ -25,6 +25,9 @@ addLoadEvent(function() {
|
|||
|
||||
var gain = context.createGain();
|
||||
|
||||
var gain2 = context.createGainNode();
|
||||
isnot(gain, gain2, "createGainNode should create a different gain node");
|
||||
|
||||
source.buffer = buffer;
|
||||
|
||||
source.connect(gain);
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
<head>
|
||||
<title>Test whether we can create an AudioContext interface</title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="text/javascript" src="webaudio.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
|
@ -25,6 +26,55 @@ addLoadEvent(function() {
|
|||
is(destination.numberOfInputs, 1, "Destination node has 1 inputs");
|
||||
is(destination.numberOfOutputs, 0, "Destination node has 0 outputs");
|
||||
|
||||
testWith(context, buffer, destination, function(source) {
|
||||
source.start(0);
|
||||
}, function(source) {
|
||||
source.stop();
|
||||
}, function() {
|
||||
testWith(context, buffer, destination, function(source) {
|
||||
source.start(0, 1);
|
||||
}, function(source) {
|
||||
expectTypeError(function() {
|
||||
source.noteOff();
|
||||
});
|
||||
source.noteOff(0);
|
||||
}, function() {
|
||||
testWith(context, buffer, destination, function(source) {
|
||||
source.start(0, 1, 0.5);
|
||||
}, function(source) {
|
||||
source.stop(0);
|
||||
}, function() {
|
||||
testWith(context, buffer, destination, function(source) {
|
||||
source.noteOn(0);
|
||||
}, function(source) {
|
||||
source.noteOff(0);
|
||||
}, function() {
|
||||
testWith(context, buffer, destination, function(source) {
|
||||
source.noteGrainOn(0, 1, 0.5);
|
||||
}, function(source) {
|
||||
source.stop();
|
||||
}, function() {
|
||||
SpecialPowers.clearUserPref("media.webaudio.enabled");
|
||||
SimpleTest.finish();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
function testWith(context, buffer, destination, start, stop, callback)
|
||||
{
|
||||
var source = createNode(context, buffer, destination);
|
||||
start(source);
|
||||
SimpleTest.executeSoon(function() {
|
||||
stop(source);
|
||||
callback();
|
||||
source.disconnect();
|
||||
});
|
||||
}
|
||||
|
||||
function createNode(context, buffer, destination) {
|
||||
var source = context.createBufferSource();
|
||||
is(source.context, context, "Source node has proper context");
|
||||
is(source.numberOfInputs, 0, "Source node has 0 inputs");
|
||||
|
@ -44,15 +94,8 @@ addLoadEvent(function() {
|
|||
is(destination.numberOfInputs, 1, "Destination node has 0 inputs");
|
||||
is(destination.numberOfOutputs, 0, "Destination node has 0 outputs");
|
||||
|
||||
source.start(0);
|
||||
SimpleTest.executeSoon(function() {
|
||||
source.stop(0);
|
||||
source.disconnect();
|
||||
|
||||
SpecialPowers.clearUserPref("media.webaudio.enabled");
|
||||
SimpleTest.finish();
|
||||
});
|
||||
});
|
||||
return source;
|
||||
}
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
|
|
|
@ -110,7 +110,7 @@ DOMInterfaces = {
|
|||
},
|
||||
|
||||
'AudioBufferSourceNode': {
|
||||
'implicitJSContext': [ 'start' ],
|
||||
'implicitJSContext': [ 'start', 'noteOn', 'noteGrainOn' ],
|
||||
'resultNotAddRefed': [ 'playbackRate' ],
|
||||
'wrapperCache': False
|
||||
},
|
||||
|
|
|
@ -36,3 +36,21 @@ interface AudioBufferSourceNode : AudioNode {
|
|||
[Throws]
|
||||
void stop(optional double when = 0);
|
||||
};
|
||||
|
||||
/*
|
||||
* The origin of this IDL file is
|
||||
* https://dvcs.w3.org/hg/audio/raw-file/tip/webaudio/specification.html#AlternateNames
|
||||
*/
|
||||
[PrefControlled]
|
||||
partial interface AudioBufferSourceNode {
|
||||
// Same as start()
|
||||
[Throws]
|
||||
void noteOn(double when);
|
||||
[Throws]
|
||||
void noteGrainOn(double when, double grainOffset, double grainDuration);
|
||||
|
||||
[Throws]
|
||||
// Same as stop()
|
||||
void noteOff(double when);
|
||||
};
|
||||
|
||||
|
|
|
@ -51,3 +51,25 @@ interface AudioContext {
|
|||
|
||||
};
|
||||
|
||||
/*
|
||||
* The origin of this IDL file is
|
||||
* https://dvcs.w3.org/hg/audio/raw-file/tip/webaudio/specification.html#AlternateNames
|
||||
*/
|
||||
[PrefControlled]
|
||||
partial interface AudioContext {
|
||||
// Same as createGain()
|
||||
[Creator]
|
||||
GainNode createGainNode();
|
||||
|
||||
// Same as createDelay()
|
||||
[Creator, Throws]
|
||||
DelayNode createDelayNode(optional double maxDelayTime = 1);
|
||||
|
||||
// Same as createScriptProcessor()
|
||||
// [Creator]
|
||||
// ScriptProcessorNode createJavaScriptNode(unsigned long bufferSize,
|
||||
// optional unsigned long numberOfInputChannels = 2,
|
||||
// optional unsigned long numberOfOutputChannels = 2);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -38,3 +38,14 @@ interface AudioParam {
|
|||
|
||||
};
|
||||
|
||||
/*
|
||||
* The origin of this IDL file is
|
||||
* https://dvcs.w3.org/hg/audio/raw-file/tip/webaudio/specification.html#AlternateNames
|
||||
*/
|
||||
[PrefControlled]
|
||||
partial interface AudioParam {
|
||||
// Same as setTargetAtTime()
|
||||
[Throws]
|
||||
void setTargetValueAtTime(float target, double startTime, double timeConstant);
|
||||
};
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче