Skip to content

Commit

Permalink
Bug 1541311 add support for AudioWorkletNode.numberOfInputs/Outputs r…
Browse files Browse the repository at this point in the history
…=padenot

There is no specified limit on the number of inputs or outputs, except that
the webidl parameter is unsigned long, but Gecko has an implementation-defined
limit.

Differential Revision: https://phabricator.services.mozilla.com/D25898

--HG--
extra : moz-landing-system : lando
  • Loading branch information
karlt committed Apr 3, 2019
1 parent b03aa4e commit fe0b4da
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 17 deletions.
21 changes: 18 additions & 3 deletions dom/media/webaudio/AudioWorkletNode.cpp
Expand Up @@ -16,10 +16,13 @@ namespace dom {
NS_IMPL_ISUPPORTS_CYCLE_COLLECTION_INHERITED_0(AudioWorkletNode, AudioNode)

AudioWorkletNode::AudioWorkletNode(AudioContext* aAudioContext,
const nsAString& aName)
const nsAString& aName,
const AudioWorkletNodeOptions& aOptions)
: AudioNode(aAudioContext, 2, ChannelCountMode::Max,
ChannelInterpretation::Speakers),
mNodeName(aName) {}
mNodeName(aName),
mInputCount(aOptions.mNumberOfInputs),
mOutputCount(aOptions.mNumberOfOutputs) {}

/* static */
already_AddRefed<AudioWorkletNode> AudioWorkletNode::Constructor(
Expand Down Expand Up @@ -57,8 +60,20 @@ already_AddRefed<AudioWorkletNode> AudioWorkletNode::Constructor(
return nullptr;
}

// MSG does not support more than UINT16_MAX inputs or outputs.
if (aOptions.mNumberOfInputs > UINT16_MAX) {
aRv.ThrowRangeError<MSG_VALUE_OUT_OF_RANGE>(
NS_LITERAL_STRING("numberOfInputs"));
return nullptr;
}
if (aOptions.mNumberOfOutputs > UINT16_MAX) {
aRv.ThrowRangeError<MSG_VALUE_OUT_OF_RANGE>(
NS_LITERAL_STRING("numberOfOutputs"));
return nullptr;
}

RefPtr<AudioWorkletNode> audioWorkletNode =
new AudioWorkletNode(&aAudioContext, aName);
new AudioWorkletNode(&aAudioContext, aName, aOptions);

audioWorkletNode->Initialize(aOptions, aRv);
if (NS_WARN_IF(aRv.Failed())) {
Expand Down
10 changes: 8 additions & 2 deletions dom/media/webaudio/AudioWorkletNode.h
Expand Up @@ -34,19 +34,25 @@ class AudioWorkletNode : public AudioNode {
JSObject* WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto) override;

// AudioNode methods
uint16_t NumberOfInputs() const override { return mInputCount; }
uint16_t NumberOfOutputs() const override { return mOutputCount; }
const char* NodeType() const override { return "AudioWorkletNode"; }

size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const override;
size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const override;

private:
AudioWorkletNode(AudioContext* aAudioContext, const nsAString& aName);
AudioWorkletNode(AudioContext* aAudioContext, const nsAString& aName,
const AudioWorkletNodeOptions& aOptions);
~AudioWorkletNode() = default;

nsString mNodeName;
uint16_t mInputCount;
uint16_t mOutputCount;
};

} // namespace dom
} // namespace mozilla

#endif // AudioWorkletNode_h_
#endif // AudioWorkletNode_h_
@@ -1,15 +1,3 @@
[audioworkletnode-constructor-options.https.html]
expected:
if release_or_beta: ERROR
[X testNode.numberOfOutputs is not equal to 18. Got 1.]
expected: FAIL

[# AUDIT TASK RUNNER FINISHED: 1 out of 6 tasks were failed.]
expected: FAIL

[< [audio-node-options\] 2 out of 6 assertions were failed.]
expected: FAIL

[X testNode.numberOfInputs is not equal to 7. Got 1.]
expected: FAIL

0 comments on commit fe0b4da

Please sign in to comment.