зеркало из https://github.com/mozilla/gecko-dev.git
Bug 11130010 - Backout new AudioNode.disconnect methods; r=mreavy,karlt,smaug
MozReview-Commit-ID: AgHScRbICYU --HG-- extra : rebase_source : 9ee0a1b35e5e292059f47fdea9f3782943b2ba5f extra : amend_source : 40c16a7338c89cbce9ad550453fadbe1b7963aa0
This commit is contained in:
Родитель
b7a8c77ac6
Коммит
de25516000
|
@ -291,9 +291,14 @@ AudioNode::SendChannelMixingParametersToStream()
|
|||
}
|
||||
}
|
||||
|
||||
bool
|
||||
AudioNode::DisconnectFromOutputIfConnected(AudioNode& aDestination, uint32_t aOutputIndex, uint32_t aInputIndex)
|
||||
void
|
||||
AudioNode::Disconnect(uint32_t aOutput, ErrorResult& aRv)
|
||||
{
|
||||
if (aOutput >= NumberOfOutputs()) {
|
||||
aRv.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR);
|
||||
return;
|
||||
}
|
||||
|
||||
WEB_AUDIO_API_LOG("%f: %s %u Disconnect()", Context()->CurrentTime(),
|
||||
NodeType(), Id());
|
||||
|
||||
|
@ -317,220 +322,47 @@ AudioNode::DisconnectFromOutputIfConnected(AudioNode& aDestination, uint32_t aOu
|
|||
RefPtr<AudioNode> mNode;
|
||||
};
|
||||
|
||||
InputNode& input = aDestination.mInputNodes[aInputIndex];
|
||||
if (input.mInputNode != this) {
|
||||
return false;
|
||||
}
|
||||
// RunAfterPendingUpdates() call below.
|
||||
aDestination.mInputNodes.RemoveElementAt(aInputIndex);
|
||||
// Remove one instance of 'dest' from mOutputNodes. There could be
|
||||
// others, and it's not correct to remove them all since some of them
|
||||
// could be for different output ports.
|
||||
RefPtr<AudioNode> output = mOutputNodes[aOutputIndex].forget();
|
||||
mOutputNodes.RemoveElementAt(aOutputIndex);
|
||||
if (mStream) {
|
||||
nsCOMPtr<nsIRunnable> runnable = new RunnableRelease(output.forget());
|
||||
mStream->RunAfterPendingUpdates(runnable.forget());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
AudioNode::DisconnectFromParamIfConnected(AudioParam& aDestination, uint32_t aOutputIndex, uint32_t aInputIndex)
|
||||
{
|
||||
MOZ_ASSERT(aOutputIndex < mOutputParams.Length());
|
||||
MOZ_ASSERT(aInputIndex < aDestination.InputNodes().Length());
|
||||
|
||||
const InputNode& input = aDestination.InputNodes()[aInputIndex];
|
||||
if (input.mInputNode != this) {
|
||||
return false;
|
||||
}
|
||||
aDestination.RemoveInputNode(aInputIndex);
|
||||
// Remove one instance of 'dest' from mOutputParams. There could be
|
||||
// others, and it's not correct to remove them all since some of them
|
||||
// could be for different output ports.
|
||||
mOutputParams.RemoveElementAt(aOutputIndex);
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
AudioNode::Disconnect(ErrorResult& aRv)
|
||||
{
|
||||
for (int32_t outputIndex = mOutputNodes.Length() - 1; outputIndex >= 0; --outputIndex) {
|
||||
AudioNode* dest = mOutputNodes[outputIndex];
|
||||
for (int32_t inputIndex = dest->mInputNodes.Length() - 1; inputIndex >= 0; --inputIndex) {
|
||||
DisconnectFromOutputIfConnected(*dest, outputIndex, inputIndex);
|
||||
}
|
||||
}
|
||||
|
||||
for (int32_t outputIndex = mOutputParams.Length() - 1; outputIndex >= 0; --outputIndex) {
|
||||
AudioParam* dest = mOutputParams[outputIndex];
|
||||
for (int32_t inputIndex = dest->InputNodes().Length() - 1; inputIndex >= 0; --inputIndex) {
|
||||
DisconnectFromParamIfConnected(*dest, outputIndex, inputIndex);
|
||||
}
|
||||
}
|
||||
|
||||
// This disconnection may have disconnected a panner and a source.
|
||||
Context()->UpdatePannerSource();
|
||||
}
|
||||
|
||||
void
|
||||
AudioNode::Disconnect(uint32_t aOutput, ErrorResult& aRv)
|
||||
{
|
||||
if (aOutput >= NumberOfOutputs()) {
|
||||
aRv.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR);
|
||||
return;
|
||||
}
|
||||
|
||||
for (int32_t outputIndex = mOutputNodes.Length() - 1; outputIndex >= 0; --outputIndex) {
|
||||
AudioNode* dest = mOutputNodes[outputIndex];
|
||||
for (int32_t inputIndex = dest->mInputNodes.Length() - 1; inputIndex >= 0; --inputIndex) {
|
||||
InputNode& input = dest->mInputNodes[inputIndex];
|
||||
if (input.mOutputPort == aOutput) {
|
||||
DisconnectFromOutputIfConnected(*dest, outputIndex, inputIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int32_t outputIndex = mOutputParams.Length() - 1; outputIndex >= 0; --outputIndex) {
|
||||
AudioParam* dest = mOutputParams[outputIndex];
|
||||
for (int32_t inputIndex = dest->InputNodes().Length() - 1; inputIndex >= 0; --inputIndex) {
|
||||
const InputNode& input = dest->InputNodes()[inputIndex];
|
||||
if (input.mOutputPort == aOutput) {
|
||||
DisconnectFromParamIfConnected(*dest, outputIndex, inputIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// This disconnection may have disconnected a panner and a source.
|
||||
Context()->UpdatePannerSource();
|
||||
}
|
||||
|
||||
void
|
||||
AudioNode::Disconnect(AudioNode& aDestination, ErrorResult& aRv)
|
||||
{
|
||||
bool wasConnected = false;
|
||||
|
||||
size_t outputIndex = mOutputNodes.IndexOf(&aDestination);
|
||||
if (outputIndex == nsTArray<InputNode>::NoIndex) {
|
||||
aRv.Throw(NS_ERROR_DOM_INVALID_ACCESS_ERR);
|
||||
return;
|
||||
}
|
||||
for (int32_t inputIndex = aDestination.mInputNodes.Length() - 1; inputIndex >= 0; --inputIndex) {
|
||||
wasConnected |= DisconnectFromOutputIfConnected(aDestination, outputIndex, inputIndex);
|
||||
}
|
||||
|
||||
if (!wasConnected) {
|
||||
aRv.Throw(NS_ERROR_DOM_INVALID_ACCESS_ERR);
|
||||
return;
|
||||
}
|
||||
|
||||
// This disconnection may have disconnected a panner and a source.
|
||||
Context()->UpdatePannerSource();
|
||||
}
|
||||
|
||||
void
|
||||
AudioNode::Disconnect(AudioNode& aDestination, uint32_t aOutput, ErrorResult& aRv)
|
||||
{
|
||||
if (aOutput >= NumberOfOutputs()) {
|
||||
aRv.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR);
|
||||
return;
|
||||
}
|
||||
|
||||
bool wasConnected = false;
|
||||
|
||||
for (int32_t outputIndex = mOutputNodes.Length() - 1; outputIndex >= 0; --outputIndex) {
|
||||
for (int32_t inputIndex = aDestination.mInputNodes.Length() - 1; inputIndex >= 0; --inputIndex) {
|
||||
InputNode& input = aDestination.mInputNodes[inputIndex];
|
||||
if (input.mOutputPort == aOutput) {
|
||||
wasConnected |= DisconnectFromOutputIfConnected(aDestination, outputIndex, inputIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!wasConnected) {
|
||||
aRv.Throw(NS_ERROR_DOM_INVALID_ACCESS_ERR);
|
||||
return;
|
||||
}
|
||||
|
||||
// This disconnection may have disconnected a panner and a source.
|
||||
Context()->UpdatePannerSource();
|
||||
}
|
||||
|
||||
void
|
||||
AudioNode::Disconnect(AudioNode& aDestination, uint32_t aOutput, uint32_t aInput, ErrorResult& aRv)
|
||||
{
|
||||
if (aOutput >= NumberOfOutputs()) {
|
||||
aRv.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR);
|
||||
return;
|
||||
}
|
||||
|
||||
if (aInput >= aDestination.NumberOfInputs()) {
|
||||
aRv.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR);
|
||||
return;
|
||||
}
|
||||
|
||||
bool wasConnected = false;
|
||||
|
||||
for (int32_t outputIndex = mOutputNodes.Length() - 1; outputIndex >= 0; --outputIndex) {
|
||||
for (int32_t inputIndex = aDestination.mInputNodes.Length() - 1; inputIndex >= 0; --inputIndex) {
|
||||
InputNode& input = aDestination.mInputNodes[inputIndex];
|
||||
if (input.mOutputPort == aOutput && input.mInputPort == aInput) {
|
||||
wasConnected |= DisconnectFromOutputIfConnected(aDestination, outputIndex, inputIndex);
|
||||
for (int32_t i = mOutputNodes.Length() - 1; i >= 0; --i) {
|
||||
AudioNode* dest = mOutputNodes[i];
|
||||
for (int32_t j = dest->mInputNodes.Length() - 1; j >= 0; --j) {
|
||||
InputNode& input = dest->mInputNodes[j];
|
||||
if (input.mInputNode == this && input.mOutputPort == aOutput) {
|
||||
// Destroying the InputNode here sends a message to the graph thread
|
||||
// to disconnect the streams, which should be sent before the
|
||||
// RunAfterPendingUpdates() call below.
|
||||
dest->mInputNodes.RemoveElementAt(j);
|
||||
// Remove one instance of 'dest' from mOutputNodes. There could be
|
||||
// others, and it's not correct to remove them all since some of them
|
||||
// could be for different output ports.
|
||||
RefPtr<AudioNode> output = mOutputNodes[i].forget();
|
||||
mOutputNodes.RemoveElementAt(i);
|
||||
output->NotifyInputsChanged();
|
||||
if (mStream) {
|
||||
RefPtr<nsIRunnable> runnable = new RunnableRelease(output.forget());
|
||||
mStream->RunAfterPendingUpdates(runnable.forget());
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!wasConnected) {
|
||||
aRv.Throw(NS_ERROR_DOM_INVALID_ACCESS_ERR);
|
||||
return;
|
||||
}
|
||||
|
||||
// This disconnection may have disconnected a panner and a source.
|
||||
Context()->UpdatePannerSource();
|
||||
}
|
||||
|
||||
void
|
||||
AudioNode::Disconnect(AudioParam& aDestination, ErrorResult& aRv)
|
||||
{
|
||||
bool wasConnected = false;
|
||||
|
||||
for (int32_t outputIndex = mOutputParams.Length() - 1; outputIndex >= 0; --outputIndex) {
|
||||
for (int32_t inputIndex = aDestination.InputNodes().Length() - 1; inputIndex >= 0; --inputIndex) {
|
||||
wasConnected |= DisconnectFromParamIfConnected(aDestination, outputIndex, inputIndex);
|
||||
}
|
||||
}
|
||||
|
||||
if (!wasConnected) {
|
||||
aRv.Throw(NS_ERROR_DOM_INVALID_ACCESS_ERR);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
AudioNode::Disconnect(AudioParam& aDestination, uint32_t aOutput, ErrorResult& aRv)
|
||||
{
|
||||
if (aOutput >= NumberOfOutputs()) {
|
||||
aRv.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR);
|
||||
return;
|
||||
}
|
||||
|
||||
bool wasConnected = false;
|
||||
|
||||
for (int32_t outputIndex = mOutputParams.Length() - 1; outputIndex >= 0; --outputIndex) {
|
||||
for (int32_t inputIndex = aDestination.InputNodes().Length() - 1; inputIndex >= 0; --inputIndex) {
|
||||
const InputNode& input = aDestination.InputNodes()[inputIndex];
|
||||
if (input.mOutputPort == aOutput) {
|
||||
wasConnected |= DisconnectFromParamIfConnected(aDestination, outputIndex, inputIndex);
|
||||
for (int32_t i = mOutputParams.Length() - 1; i >= 0; --i) {
|
||||
AudioParam* dest = mOutputParams[i];
|
||||
for (int32_t j = dest->InputNodes().Length() - 1; j >= 0; --j) {
|
||||
const InputNode& input = dest->InputNodes()[j];
|
||||
if (input.mInputNode == this && input.mOutputPort == aOutput) {
|
||||
dest->RemoveInputNode(j);
|
||||
// Remove one instance of 'dest' from mOutputParams. There could be
|
||||
// others, and it's not correct to remove them all since some of them
|
||||
// could be for different output ports.
|
||||
mOutputParams.RemoveElementAt(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!wasConnected) {
|
||||
aRv.Throw(NS_ERROR_DOM_INVALID_ACCESS_ERR);
|
||||
return;
|
||||
}
|
||||
// This disconnection may have disconnected a panner and a source.
|
||||
Context()->UpdatePannerSource();
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -94,17 +94,7 @@ public:
|
|||
virtual void Connect(AudioParam& aDestination, uint32_t aOutput,
|
||||
ErrorResult& aRv);
|
||||
|
||||
virtual void Disconnect(ErrorResult& aRv);
|
||||
virtual void Disconnect(uint32_t aOutput, ErrorResult& aRv);
|
||||
virtual void Disconnect(AudioNode& aDestination, ErrorResult& aRv);
|
||||
virtual void Disconnect(AudioNode& aDestination, uint32_t aOutput,
|
||||
ErrorResult& aRv);
|
||||
virtual void Disconnect(AudioNode& aDestination,
|
||||
uint32_t aOutput, uint32_t aInput,
|
||||
ErrorResult& aRv);
|
||||
virtual void Disconnect(AudioParam& aDestination, ErrorResult& aRv);
|
||||
virtual void Disconnect(AudioParam& aDestination, uint32_t aOutput,
|
||||
ErrorResult& aRv);
|
||||
|
||||
// Called after input nodes have been explicitly added or removed through
|
||||
// the Connect() or Disconnect() methods.
|
||||
|
@ -230,8 +220,6 @@ private:
|
|||
}
|
||||
// Callers must hold a reference to 'this'.
|
||||
void DisconnectFromGraph();
|
||||
bool DisconnectFromOutputIfConnected(AudioNode& aDestination, uint32_t aOutputIndex, uint32_t aInputIndex);
|
||||
bool DisconnectFromParamIfConnected(AudioParam& aDestination, uint32_t aOutputIndex, uint32_t aInputIndex);
|
||||
|
||||
protected:
|
||||
// Helpers for sending different value types to streams
|
||||
|
|
|
@ -50,15 +50,13 @@ public:
|
|||
UpdateConnectedStatus();
|
||||
}
|
||||
}
|
||||
void Disconnect(ErrorResult& aRv) override
|
||||
{
|
||||
AudioNode::Disconnect(aRv);
|
||||
UpdateConnectedStatus();
|
||||
}
|
||||
|
||||
void Disconnect(uint32_t aOutput, ErrorResult& aRv) override
|
||||
{
|
||||
AudioNode::Disconnect(aOutput, aRv);
|
||||
UpdateConnectedStatus();
|
||||
if (!aRv.Failed()) {
|
||||
UpdateConnectedStatus();
|
||||
}
|
||||
}
|
||||
void NotifyInputsChanged() override
|
||||
{
|
||||
|
@ -70,31 +68,7 @@ public:
|
|||
// No need to UpdateConnectedStatus() because there was previously an
|
||||
// input in InputNodes().
|
||||
}
|
||||
void Disconnect(AudioNode& aDestination, ErrorResult& aRv) override
|
||||
{
|
||||
AudioNode::Disconnect(aDestination, aRv);
|
||||
UpdateConnectedStatus();
|
||||
}
|
||||
void Disconnect(AudioNode& aDestination, uint32_t aOutput, ErrorResult& aRv) override
|
||||
{
|
||||
AudioNode::Disconnect(aDestination, aOutput, aRv);
|
||||
UpdateConnectedStatus();
|
||||
}
|
||||
void Disconnect(AudioNode& aDestination, uint32_t aOutput, uint32_t aInput, ErrorResult& aRv) override
|
||||
{
|
||||
AudioNode::Disconnect(aDestination, aOutput, aInput, aRv);
|
||||
UpdateConnectedStatus();
|
||||
}
|
||||
void Disconnect(AudioParam& aDestination, ErrorResult& aRv) override
|
||||
{
|
||||
AudioNode::Disconnect(aDestination, aRv);
|
||||
UpdateConnectedStatus();
|
||||
}
|
||||
void Disconnect(AudioParam& aDestination, uint32_t aOutput, ErrorResult& aRv) override
|
||||
{
|
||||
AudioNode::Disconnect(aDestination, aOutput, aRv);
|
||||
UpdateConnectedStatus();
|
||||
}
|
||||
|
||||
void SetChannelCount(uint32_t aChannelCount, ErrorResult& aRv) override
|
||||
{
|
||||
if (aChannelCount != ChannelCount()) {
|
||||
|
|
|
@ -123,14 +123,6 @@ skip-if = toolkit == 'android' # bug 1056706
|
|||
[test_delayNodeTailWithGain.html]
|
||||
[test_delayNodeTailWithReconnect.html]
|
||||
[test_delayNodeWithGain.html]
|
||||
[test_disconnectAll.html]
|
||||
[test_disconnectAudioParam.html]
|
||||
[test_disconnectAudioParamFromOutput.html]
|
||||
[test_disconnectExceptions.html]
|
||||
[test_disconnectFromAudioNode.html]
|
||||
[test_disconnectFromAudioNodeAndOutput.html]
|
||||
[test_disconnectFromAudioNodeAndOutputAndInput.html]
|
||||
[test_disconnectFromOutput.html]
|
||||
[test_dynamicsCompressorNode.html]
|
||||
[test_dynamicsCompressorNodePassThrough.html]
|
||||
[test_dynamicsCompressorNodeWithGain.html]
|
||||
|
|
|
@ -1,51 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test whether we can disconnect an AudioNode</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">
|
||||
var gTest = {
|
||||
length: 256,
|
||||
numberOfChannels: 1,
|
||||
createGraph: function(context) {
|
||||
var sourceBuffer = context.createBuffer(1, 256, context.sampleRate);
|
||||
var data = sourceBuffer.getChannelData(0);
|
||||
for (var j = 0; j < data.length; j++) {
|
||||
data[j] = 1;
|
||||
}
|
||||
|
||||
var source = context.createBufferSource();
|
||||
source.buffer = sourceBuffer;
|
||||
|
||||
var source = context.createBufferSource();
|
||||
source.buffer = sourceBuffer;
|
||||
|
||||
var gain1 = context.createGain();
|
||||
var gain2 = context.createGain();
|
||||
var gain3 = context.createGain();
|
||||
var merger = context.createChannelMerger(3);
|
||||
|
||||
source.connect(gain1);
|
||||
source.connect(gain2);
|
||||
source.connect(gain3);
|
||||
gain1.connect(merger);
|
||||
gain2.connect(merger);
|
||||
gain3.connect(merger);
|
||||
source.start();
|
||||
|
||||
source.disconnect();
|
||||
|
||||
return merger;
|
||||
}
|
||||
};
|
||||
|
||||
runTest();
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
|
@ -1,58 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test whether we can disconnect an 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">
|
||||
var gTest = {
|
||||
length: 256,
|
||||
numberOfChannels: 1,
|
||||
createGraph: function(context) {
|
||||
var sourceBuffer = context.createBuffer(1, 256, context.sampleRate);
|
||||
var data = sourceBuffer.getChannelData(0);
|
||||
for (var j = 0; j < data.length; j++) {
|
||||
data[j] = 1;
|
||||
}
|
||||
|
||||
var source = context.createBufferSource();
|
||||
source.buffer = sourceBuffer;
|
||||
|
||||
var half = context.createGain();
|
||||
var gain1 = context.createGain();
|
||||
var gain2 = context.createGain();
|
||||
|
||||
half.gain.value = 0.5;
|
||||
|
||||
source.connect(gain1);
|
||||
gain1.connect(gain2);
|
||||
source.connect(half);
|
||||
|
||||
half.connect(gain1.gain);
|
||||
half.connect(gain2.gain);
|
||||
|
||||
half.disconnect(gain2.gain);
|
||||
|
||||
source.start();
|
||||
|
||||
return gain2;
|
||||
},
|
||||
createExpectedBuffers: function(context) {
|
||||
expectedBuffer = context.createBuffer(1, 256, context.sampleRate);
|
||||
for (var i = 0; i < 256; ++i) {
|
||||
expectedBuffer.getChannelData(0)[i] = 1.5;
|
||||
}
|
||||
|
||||
return expectedBuffer;
|
||||
}
|
||||
};
|
||||
|
||||
runTest();
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
|
@ -1,67 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test whether we can disconnect an 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">
|
||||
var gTest = {
|
||||
length: 256,
|
||||
numberOfChannels: 2,
|
||||
createGraph: function(context) {
|
||||
var sourceBuffer = context.createBuffer(2, 256, context.sampleRate);
|
||||
for (var i = 1; i <= 2; i++) {
|
||||
var data = sourceBuffer.getChannelData(i-1);
|
||||
for (var j = 0; j < data.length; j++) {
|
||||
data[j] = i;
|
||||
}
|
||||
}
|
||||
|
||||
var source = context.createBufferSource();
|
||||
source.buffer = sourceBuffer;
|
||||
|
||||
var source = context.createBufferSource();
|
||||
source.buffer = sourceBuffer;
|
||||
|
||||
var half = context.createGain();
|
||||
var gain1 = context.createGain();
|
||||
var gain2 = context.createGain();
|
||||
var splitter = context.createChannelSplitter(2);
|
||||
|
||||
half.gain.value = 0.5;
|
||||
|
||||
source.connect(gain1);
|
||||
gain1.connect(gain2);
|
||||
source.connect(half);
|
||||
half.connect(splitter);
|
||||
splitter.connect(gain1.gain, 0);
|
||||
splitter.connect(gain2.gain, 1);
|
||||
|
||||
splitter.disconnect(gain2.gain, 1);
|
||||
|
||||
source.start();
|
||||
|
||||
return gain2;
|
||||
},
|
||||
createExpectedBuffers: function(context) {
|
||||
var expectedBuffer = context.createBuffer(2, 256, context.sampleRate);
|
||||
for (var i = 1; i <= 2; i++) {
|
||||
var data = expectedBuffer.getChannelData(i-1);
|
||||
for (var j = 0; j < data.length; j++) {
|
||||
data[j] = (i == 1) ? 1.5 : 3.0;
|
||||
}
|
||||
}
|
||||
|
||||
return expectedBuffer;
|
||||
}
|
||||
};
|
||||
|
||||
runTest();
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
|
@ -1,75 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test whether we can disconnect an AudioNode</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">
|
||||
var ctx = new AudioContext();
|
||||
var sourceBuffer = ctx.createBuffer(2, 256, ctx.sampleRate);
|
||||
for (var i = 1; i <= 2; i++) {
|
||||
var data = sourceBuffer.getChannelData(i-1);
|
||||
for (var j = 0; j < data.length; j++) {
|
||||
data[j] = i;
|
||||
}
|
||||
}
|
||||
|
||||
var source = ctx.createBufferSource();
|
||||
source.buffer = sourceBuffer;
|
||||
|
||||
var gain1 = ctx.createGain();
|
||||
var splitter = ctx.createChannelSplitter(2);
|
||||
var merger = ctx.createChannelMerger(2);
|
||||
var gain2 = ctx.createGain();
|
||||
var gain3 = ctx.createGain();
|
||||
|
||||
gain1.connect(splitter);
|
||||
splitter.connect(gain2, 0);
|
||||
splitter.connect(gain3, 1);
|
||||
splitter.connect(merger, 0, 0);
|
||||
splitter.connect(merger, 1, 1);
|
||||
gain2.connect(gain3);
|
||||
gain3.connect(ctx.destination);
|
||||
merger.connect(ctx.destination);
|
||||
|
||||
expectException(function() {
|
||||
splitter.disconnect(2);
|
||||
}, DOMException.INDEX_SIZE_ERR);
|
||||
|
||||
expectNoException(function() {
|
||||
splitter.disconnect(1);
|
||||
splitter.disconnect(1);
|
||||
});
|
||||
|
||||
expectException(function() {
|
||||
gain1.disconnect(gain2);
|
||||
}, DOMException.INVALID_ACCESS_ERR);
|
||||
|
||||
expectException(function() {
|
||||
gain1.disconnect(gain3);
|
||||
ok(false, 'Should get InvalidAccessError exception');
|
||||
}, DOMException.INVALID_ACCESS_ERR);
|
||||
|
||||
expectException(function() {
|
||||
splitter.disconnect(gain2, 2);
|
||||
}, DOMException.INDEX_SIZE_ERR);
|
||||
|
||||
expectException(function() {
|
||||
splitter.disconnect(gain1, 0);
|
||||
}, DOMException.INVALID_ACCESS_ERR);
|
||||
|
||||
expectException(function() {
|
||||
splitter.disconnect(gain3, 0, 0);
|
||||
}, DOMException.INVALID_ACCESS_ERR);
|
||||
|
||||
expectException(function() {
|
||||
splitter.disconnect(merger, 3, 0);
|
||||
}, DOMException.INDEX_SIZE_ERR);
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
|
@ -1,55 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test whether we can disconnect an AudioNode</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">
|
||||
var gTest = {
|
||||
length: 256,
|
||||
numberOfChannels: 1,
|
||||
createGraph: function(context) {
|
||||
var sourceBuffer = context.createBuffer(1, 256, context.sampleRate);
|
||||
var data = sourceBuffer.getChannelData(0);
|
||||
for (var j = 0; j < data.length; j++) {
|
||||
data[j] = 1;
|
||||
}
|
||||
|
||||
var source = context.createBufferSource();
|
||||
source.buffer = sourceBuffer;
|
||||
|
||||
var gain1 = context.createGain();
|
||||
var gain2 = context.createGain();
|
||||
var gain3 = context.createGain();
|
||||
|
||||
source.connect(gain1);
|
||||
source.connect(gain2);
|
||||
|
||||
gain1.connect(gain3);
|
||||
gain2.connect(gain3);
|
||||
|
||||
source.start();
|
||||
|
||||
source.disconnect(gain2);
|
||||
|
||||
return gain3;
|
||||
},
|
||||
createExpectedBuffers: function(context) {
|
||||
expectedBuffer = context.createBuffer(1, 256, context.sampleRate);
|
||||
for (var i = 0; i < 256; ++i) {
|
||||
expectedBuffer.getChannelData(0)[i] = 1.0;
|
||||
}
|
||||
|
||||
return expectedBuffer;
|
||||
}
|
||||
};
|
||||
|
||||
runTest();
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
|
@ -1,59 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test whether we can disconnect an AudioNode</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">
|
||||
var gTest = {
|
||||
length: 256,
|
||||
numberOfChannels: 2,
|
||||
createGraph: function(context) {
|
||||
var sourceBuffer = context.createBuffer(2, 256, context.sampleRate);
|
||||
for (var i = 1; i <= 2; i++) {
|
||||
var data = sourceBuffer.getChannelData(i-1);
|
||||
for (var j = 0; j < data.length; j++) {
|
||||
data[j] = i;
|
||||
}
|
||||
}
|
||||
|
||||
var source = context.createBufferSource();
|
||||
source.buffer = sourceBuffer;
|
||||
|
||||
var splitter = context.createChannelSplitter(2);
|
||||
var gain1 = context.createGain();
|
||||
var gain2 = context.createGain();
|
||||
var merger = context.createChannelMerger(2);
|
||||
|
||||
source.connect(splitter);
|
||||
splitter.connect(gain1, 0);
|
||||
splitter.connect(gain2, 0);
|
||||
splitter.connect(gain2, 1);
|
||||
gain1.connect(merger, 0, 1);
|
||||
gain2.connect(merger, 0, 1);
|
||||
source.start();
|
||||
|
||||
splitter.disconnect(gain2, 0);
|
||||
|
||||
return merger;
|
||||
},
|
||||
createExpectedBuffers: function(context) {
|
||||
expectedBuffer = context.createBuffer(2, 256, context.sampleRate);
|
||||
for (var i = 0; i < 256; ++i) {
|
||||
expectedBuffer.getChannelData(0)[i] = 0;
|
||||
expectedBuffer.getChannelData(1)[i] = 3;
|
||||
}
|
||||
|
||||
return expectedBuffer;
|
||||
}
|
||||
};
|
||||
|
||||
runTest();
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
|
@ -1,57 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test whether we can disconnect an AudioNode</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">
|
||||
var gTest = {
|
||||
length: 256,
|
||||
numberOfChannels: 3,
|
||||
createGraph: function(context) {
|
||||
var sourceBuffer = context.createBuffer(3, 256, context.sampleRate);
|
||||
for (var i = 1; i <= 3; i++) {
|
||||
var data = sourceBuffer.getChannelData(i-1);
|
||||
for (var j = 0; j < data.length; j++) {
|
||||
data[j] = i;
|
||||
}
|
||||
}
|
||||
|
||||
var source = context.createBufferSource();
|
||||
source.buffer = sourceBuffer;
|
||||
|
||||
var splitter = context.createChannelSplitter(3);
|
||||
var merger = context.createChannelMerger(3);
|
||||
|
||||
source.connect(splitter);
|
||||
splitter.connect(merger, 0, 0);
|
||||
splitter.connect(merger, 1, 1);
|
||||
splitter.connect(merger, 2, 2);
|
||||
source.start();
|
||||
|
||||
splitter.disconnect(merger, 2, 2);
|
||||
|
||||
return merger;
|
||||
},
|
||||
createExpectedBuffers: function(context) {
|
||||
var expectedBuffer = context.createBuffer(3, 256, context.sampleRate);
|
||||
for (var i = 1; i <= 3; i++) {
|
||||
var data = expectedBuffer.getChannelData(i-1);
|
||||
for (var j = 0; j < data.length; j++) {
|
||||
data[j] = (i == 3) ? 0 : i;
|
||||
}
|
||||
}
|
||||
|
||||
return expectedBuffer;
|
||||
}
|
||||
};
|
||||
|
||||
runTest();
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
|
@ -1,54 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test whether we can disconnect an AudioNode</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">
|
||||
var gTest = {
|
||||
length: 256,
|
||||
numberOfChannels: 1,
|
||||
createGraph: function(context) {
|
||||
var sourceBuffer = context.createBuffer(3, 256, context.sampleRate);
|
||||
for (var i = 1; i <= 3; i++) {
|
||||
var data = sourceBuffer.getChannelData(i-1);
|
||||
for (var j = 0; j < data.length; j++) {
|
||||
data[j] = i;
|
||||
}
|
||||
}
|
||||
|
||||
var source = context.createBufferSource();
|
||||
source.buffer = sourceBuffer;
|
||||
|
||||
var splitter = context.createChannelSplitter(3);
|
||||
var sum = context.createGain();
|
||||
|
||||
source.connect(splitter);
|
||||
splitter.connect(sum, 0);
|
||||
splitter.connect(sum, 1);
|
||||
splitter.connect(sum, 2);
|
||||
source.start();
|
||||
|
||||
splitter.disconnect(1);
|
||||
|
||||
return sum;
|
||||
},
|
||||
createExpectedBuffers: function(context) {
|
||||
expectedBuffer = context.createBuffer(1, 256, context.sampleRate);
|
||||
for (var i = 0; i < 256; ++i) {
|
||||
expectedBuffer.getChannelData(0)[i] = 4;
|
||||
}
|
||||
|
||||
return expectedBuffer;
|
||||
},
|
||||
};
|
||||
|
||||
runTest();
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
|
@ -28,19 +28,7 @@ interface AudioNode : EventTarget {
|
|||
[Throws]
|
||||
void connect(AudioParam destination, optional unsigned long output = 0);
|
||||
[Throws]
|
||||
void disconnect();
|
||||
[Throws]
|
||||
void disconnect(unsigned long output);
|
||||
[Throws]
|
||||
void disconnect(AudioNode destination);
|
||||
[Throws]
|
||||
void disconnect(AudioNode destination, unsigned long output);
|
||||
[Throws]
|
||||
void disconnect(AudioNode destination, unsigned long output, unsigned long input);
|
||||
[Throws]
|
||||
void disconnect(AudioParam destination);
|
||||
[Throws]
|
||||
void disconnect(AudioParam destination, unsigned long output);
|
||||
void disconnect(optional unsigned long output = 0);
|
||||
|
||||
readonly attribute AudioContext context;
|
||||
readonly attribute unsigned long numberOfInputs;
|
||||
|
|
Загрузка…
Ссылка в новой задаче