mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-23 09:51:57 -05:00
WebAudio: Stub/implement more of AudioNode
(cherry picked from commit 6d33cc2b3a3e8b2c570c80866c5aa666927d0ad5)
This commit is contained in:
parent
4ee1e3d5a1
commit
e4959ef9f3
3 changed files with 82 additions and 9 deletions
|
@ -24,18 +24,26 @@ AudioNode::~AudioNode() = default;
|
|||
// https://webaudio.github.io/web-audio-api/#dom-audionode-connect
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<AudioNode>> AudioNode::connect(JS::NonnullGCPtr<AudioNode> destination_node, WebIDL::UnsignedLong output, WebIDL::UnsignedLong input)
|
||||
{
|
||||
// There can only be one connection between a given output of one specific node and a given input of another specific node.
|
||||
// Multiple connections with the same termini are ignored.
|
||||
|
||||
// If the destination parameter is an AudioNode that has been created using another AudioContext, an InvalidAccessError MUST be thrown.
|
||||
if (m_context != destination_node->m_context) {
|
||||
return WebIDL::InvalidAccessError::create(realm(), "Cannot connect to an AudioNode in a different AudioContext"_fly_string);
|
||||
}
|
||||
|
||||
(void)output;
|
||||
(void)input;
|
||||
dbgln("FIXME: Implement AudioNode::connect (AudioNode)");
|
||||
dbgln("FIXME: Implement Audio::connect(AudioNode)");
|
||||
return destination_node;
|
||||
}
|
||||
|
||||
// https://webaudio.github.io/web-audio-api/#dom-audionode-connect-destinationparam-output
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<AudioNode>> AudioNode::connect(JS::NonnullGCPtr<AudioParam> destination_param, WebIDL::UnsignedLong output)
|
||||
void AudioNode::connect(JS::NonnullGCPtr<AudioParam> destination_param, WebIDL::UnsignedLong output)
|
||||
{
|
||||
(void)destination_param;
|
||||
(void)output;
|
||||
return WebIDL::NotSupportedError::create(realm(), "FIXME: Implement AudioNode::connect (AudioParam)"_fly_string);
|
||||
dbgln("FIXME: Implement AudioNode::connect(AudioParam)");
|
||||
}
|
||||
|
||||
// https://webaudio.github.io/web-audio-api/#dom-audionode-disconnect
|
||||
|
@ -90,6 +98,60 @@ void AudioNode::disconnect(JS::NonnullGCPtr<AudioParam> destination_param, WebID
|
|||
dbgln("FIXME: Implement AudioNode::disconnect(destination_param, output)");
|
||||
}
|
||||
|
||||
// https://webaudio.github.io/web-audio-api/#dom-audionode-numberofinputs
|
||||
WebIDL::UnsignedLong AudioNode::number_of_inputs()
|
||||
{
|
||||
dbgln("FIXME: Implement AudioNode::number_of_inputs()");
|
||||
return 0;
|
||||
}
|
||||
|
||||
// https://webaudio.github.io/web-audio-api/#dom-audionode-numberofoutputs
|
||||
WebIDL::UnsignedLong AudioNode::number_of_outputs()
|
||||
{
|
||||
dbgln("FIXME: Implement AudioNode::number_of_outputs()");
|
||||
return 0;
|
||||
}
|
||||
|
||||
// https://webaudio.github.io/web-audio-api/#dom-audionode-channelcount
|
||||
WebIDL::ExceptionOr<void> AudioNode::set_channel_count(WebIDL::UnsignedLong channel_count)
|
||||
{
|
||||
(void)channel_count;
|
||||
return WebIDL::NotSupportedError::create(realm(), "FIXME: Implement AudioNode::set_channel_count(channel_count)"_fly_string);
|
||||
}
|
||||
|
||||
// https://webaudio.github.io/web-audio-api/#dom-audionode-channelcount
|
||||
WebIDL::UnsignedLong AudioNode::channel_count()
|
||||
{
|
||||
dbgln("FIXME: Implement AudioNode::channel_count()");
|
||||
return 2;
|
||||
}
|
||||
|
||||
// https://webaudio.github.io/web-audio-api/#dom-audionode-channelcountmode
|
||||
WebIDL::ExceptionOr<void> AudioNode::set_channel_count_mode(Bindings::ChannelCountMode channel_count_mode)
|
||||
{
|
||||
m_channel_count_mode = channel_count_mode;
|
||||
return {};
|
||||
}
|
||||
|
||||
// https://webaudio.github.io/web-audio-api/#dom-audionode-channelcountmode
|
||||
Bindings::ChannelCountMode AudioNode::channel_count_mode()
|
||||
{
|
||||
return m_channel_count_mode;
|
||||
}
|
||||
|
||||
// https://webaudio.github.io/web-audio-api/#dom-audionode-channelinterpretation
|
||||
WebIDL::ExceptionOr<void> AudioNode::set_channel_interpretation(Bindings::ChannelInterpretation channel_interpretation)
|
||||
{
|
||||
m_channel_interpretation = channel_interpretation;
|
||||
return {};
|
||||
}
|
||||
|
||||
// https://webaudio.github.io/web-audio-api/#dom-audionode-channelinterpretation
|
||||
Bindings::ChannelInterpretation AudioNode::channel_interpretation()
|
||||
{
|
||||
return m_channel_interpretation;
|
||||
}
|
||||
|
||||
void AudioNode::initialize(JS::Realm& realm)
|
||||
{
|
||||
Base::initialize(realm);
|
||||
|
|
|
@ -31,7 +31,7 @@ public:
|
|||
virtual ~AudioNode() override;
|
||||
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<AudioNode>> connect(JS::NonnullGCPtr<AudioNode> destination_node, WebIDL::UnsignedLong output = 0, WebIDL::UnsignedLong input = 0);
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<AudioNode>> connect(JS::NonnullGCPtr<AudioParam> destination_param, WebIDL::UnsignedLong output = 0);
|
||||
void connect(JS::NonnullGCPtr<AudioParam> destination_param, WebIDL::UnsignedLong output = 0);
|
||||
|
||||
void disconnect();
|
||||
void disconnect(WebIDL::UnsignedLong output);
|
||||
|
@ -48,6 +48,15 @@ public:
|
|||
return m_context;
|
||||
}
|
||||
|
||||
WebIDL::UnsignedLong number_of_inputs();
|
||||
WebIDL::UnsignedLong number_of_outputs();
|
||||
WebIDL::ExceptionOr<void> set_channel_count(WebIDL::UnsignedLong);
|
||||
WebIDL::UnsignedLong channel_count();
|
||||
WebIDL::ExceptionOr<void> set_channel_count_mode(Bindings::ChannelCountMode);
|
||||
Bindings::ChannelCountMode channel_count_mode();
|
||||
WebIDL::ExceptionOr<void> set_channel_interpretation(Bindings::ChannelInterpretation);
|
||||
Bindings::ChannelInterpretation channel_interpretation();
|
||||
|
||||
protected:
|
||||
AudioNode(JS::Realm&, JS::NonnullGCPtr<BaseAudioContext>);
|
||||
|
||||
|
@ -56,6 +65,8 @@ protected:
|
|||
|
||||
private:
|
||||
JS::NonnullGCPtr<BaseAudioContext> m_context;
|
||||
Bindings::ChannelCountMode m_channel_count_mode { Bindings::ChannelCountMode::Max };
|
||||
Bindings::ChannelInterpretation m_channel_interpretation { Bindings::ChannelInterpretation::Speakers };
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -38,9 +38,9 @@ interface AudioNode : EventTarget {
|
|||
undefined disconnect(AudioParam destinationParam);
|
||||
undefined disconnect(AudioParam destinationParam, unsigned long output);
|
||||
readonly attribute BaseAudioContext context;
|
||||
[FIXME] readonly attribute unsigned long numberOfInputs;
|
||||
[FIXME] readonly attribute unsigned long numberOfOutputs;
|
||||
[FIXME] attribute unsigned long channelCount;
|
||||
[FIXME] attribute ChannelCountMode channelCountMode;
|
||||
[FIXME] attribute ChannelInterpretation channelInterpretation;
|
||||
readonly attribute unsigned long numberOfInputs;
|
||||
readonly attribute unsigned long numberOfOutputs;
|
||||
attribute unsigned long channelCount;
|
||||
attribute ChannelCountMode channelCountMode;
|
||||
attribute ChannelInterpretation channelInterpretation;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue