Bug 1456946 - Don't call AudioNode::Initialize on an ChannelSplitterNode during construction to avoid throwing. r?achronop
We initialize the channelCountMode and channelInterpretation (that cannot be
changed) appropriately in the C++ ctor, and the channelCount manually as well.
Then we check manually that the options for the channelCountMode and
channelInterpretation have not been passed, and are not incorrect.
MozReview-Commit-ID: 4YdYfaGqKqn
--- a/dom/media/webaudio/ChannelSplitterNode.cpp
+++ b/dom/media/webaudio/ChannelSplitterNode.cpp
@@ -77,18 +77,32 @@ ChannelSplitterNode::Create(AudioContext
aOptions.mNumberOfOutputs > WebAudioUtils::MaxChannelCount) {
aRv.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR);
return nullptr;
}
RefPtr<ChannelSplitterNode> audioNode =
new ChannelSplitterNode(&aAudioContext, aOptions.mNumberOfOutputs);
- audioNode->Initialize(aOptions, aRv);
- if (NS_WARN_IF(aRv.Failed())) {
+ // Manually check that the other options are valid, this node has channelCount,
+ // channelCountMode and channelInterpretation constraints: they cannot be
+ // changed from the default.
+ if (aOptions.mChannelCount.WasPassed() &&
+ aOptions.mChannelCount.Value() != audioNode->ChannelCount()) {
+ aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
+ return nullptr;
+ }
+ if (aOptions.mChannelInterpretation.WasPassed() &&
+ aOptions.mChannelInterpretation.Value() != audioNode->ChannelInterpretationValue()) {
+ aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
+ return nullptr;
+ }
+ if (aOptions.mChannelCountMode.WasPassed() &&
+ aOptions.mChannelCountMode.Value() != audioNode->ChannelCountModeValue()) {
+ aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
return nullptr;
}
return audioNode.forget();
}
JSObject*
ChannelSplitterNode::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)