Bug 1218694 - Return the AudioNode connected to when calling AudioNode.connect(). r=smaug

This commit is contained in:
Paul Adenot 2015-10-28 13:54:35 +09:00
parent 81fba50329
commit 2834e84fab
4 changed files with 13 additions and 10 deletions

View File

@ -177,25 +177,25 @@ AudioNode::DisconnectFromGraph()
DestroyMediaStream();
}
void
AudioNode*
AudioNode::Connect(AudioNode& aDestination, uint32_t aOutput,
uint32_t aInput, ErrorResult& aRv)
{
if (aOutput >= NumberOfOutputs() ||
aInput >= aDestination.NumberOfInputs()) {
aRv.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR);
return;
return nullptr;
}
if (Context() != aDestination.Context()) {
aRv.Throw(NS_ERROR_DOM_SYNTAX_ERR);
return;
return nullptr;
}
if (FindIndexOfNodeWithPorts(aDestination.mInputNodes, this, aInput, aOutput) !=
nsTArray<AudioNode::InputNode>::NoIndex) {
// connection already exists.
return;
return &aDestination;
}
// The MediaStreamGraph will handle cycle detection. We don't need to do it
@ -220,6 +220,8 @@ AudioNode::Connect(AudioNode& aDestination, uint32_t aOutput,
// This connection may have connected a panner and a source.
Context()->UpdatePannerSource();
return &aDestination;
}
void

View File

@ -89,8 +89,8 @@ public:
return mContext;
}
virtual void Connect(AudioNode& aDestination, uint32_t aOutput,
uint32_t aInput, ErrorResult& aRv);
virtual AudioNode* Connect(AudioNode& aDestination, uint32_t aOutput,
uint32_t aInput, ErrorResult& aRv);
virtual void Connect(AudioParam& aDestination, uint32_t aOutput,
ErrorResult& aRv);

View File

@ -33,13 +33,14 @@ public:
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
virtual void Connect(AudioNode& aDestination, uint32_t aOutput,
uint32_t aInput, ErrorResult& aRv) override
virtual AudioNode* Connect(AudioNode& aDestination, uint32_t aOutput,
uint32_t aInput, ErrorResult& aRv) override
{
AudioNode::Connect(aDestination, aOutput, aInput, aRv);
AudioNode* node = AudioNode::Connect(aDestination, aOutput, aInput, aRv);
if (!aRv.Failed()) {
UpdateConnectedStatus();
}
return node;
}
virtual void Connect(AudioParam& aDestination, uint32_t aOutput,

View File

@ -24,7 +24,7 @@ enum ChannelInterpretation {
interface AudioNode : EventTarget {
[Throws]
void connect(AudioNode destination, optional unsigned long output = 0, optional unsigned long input = 0);
AudioNode connect(AudioNode destination, optional unsigned long output = 0, optional unsigned long input = 0);
[Throws]
void connect(AudioParam destination, optional unsigned long output = 0);
[Throws]