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

--HG--
extra : rebase_source : 1133e35b74249f5457d1584601e8d4c64cb154cc
This commit is contained in:
Paul Adenot 2018-05-29 18:15:29 +02:00
Родитель 80a1f3c079
Коммит a97337d7fc
1 изменённых файлов: 16 добавлений и 2 удалений

Просмотреть файл

@ -82,8 +82,22 @@ ChannelSplitterNode::Create(AudioContext& aAudioContext,
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;
}