Bug 1456946 - Don't call AudioNode::Initialize on an ChannelSplitterNode during construction to avoid throwing. r=achronop
☠☠ backed out by 21e2f0577dee ☠ ☠
authorPaul Adenot <paul@paul.cx>
Tue, 29 May 2018 18:15:29 +0200
changeset 475018 9a085b0513f78344b07724c049860b089c313894
parent 475017 ebfc3c04016ab0cce5489973e63cdb6dfdee191c
child 475019 9af1ffb437be63b6956970b47eebc78e6e2310af
push id9374
push userjlund@mozilla.com
push dateMon, 18 Jun 2018 21:43:20 +0000
treeherdermozilla-beta@160e085dfb0b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersachronop
bugs1456946
milestone62.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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, the channelCount and channelInterpretation have not been passed, or are not incorrect. MozReview-Commit-ID: 4YdYfaGqKqn
dom/media/webaudio/ChannelSplitterNode.cpp
--- 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)