mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 23:20:20 +00:00
LibAudio: Initialize GainNode properly
That helps to pass WPT tests under /webaudio/the-audio-api/the-gainnode-interface/ctor-gain.html
This commit is contained in:
parent
5630a0d6b4
commit
4998385c7a
Notes:
github-actions[bot]
2024-10-30 16:31:47 +00:00
Author: https://github.com/shlyakpavel Commit: https://github.com/LadybirdBrowser/ladybird/commit/4998385c7ae Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2042 Reviewed-by: https://github.com/awesomekling
4 changed files with 19 additions and 8 deletions
|
@ -95,7 +95,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<DynamicsCompressorNode>> BaseAudioContext::
|
|||
}
|
||||
|
||||
// https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-creategain
|
||||
JS::NonnullGCPtr<GainNode> BaseAudioContext::create_gain()
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<GainNode>> BaseAudioContext::create_gain()
|
||||
{
|
||||
// Factory method for GainNode.
|
||||
return GainNode::create(realm(), *this);
|
||||
|
|
|
@ -59,7 +59,7 @@ public:
|
|||
WebIDL::ExceptionOr<JS::NonnullGCPtr<AudioBufferSourceNode>> create_buffer_source();
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<OscillatorNode>> create_oscillator();
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<DynamicsCompressorNode>> create_dynamics_compressor();
|
||||
JS::NonnullGCPtr<GainNode> create_gain();
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<GainNode>> create_gain();
|
||||
|
||||
JS::NonnullGCPtr<WebIDL::Promise> decode_audio_data(JS::Handle<WebIDL::BufferSource>, JS::GCPtr<WebIDL::CallbackType>, JS::GCPtr<WebIDL::CallbackType>);
|
||||
|
||||
|
|
|
@ -16,16 +16,27 @@ JS_DEFINE_ALLOCATOR(GainNode);
|
|||
|
||||
GainNode::~GainNode() = default;
|
||||
|
||||
JS::NonnullGCPtr<GainNode> GainNode::create(JS::Realm& realm, JS::NonnullGCPtr<BaseAudioContext> context, GainOptions const& options)
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<GainNode>> GainNode::create(JS::Realm& realm, JS::NonnullGCPtr<BaseAudioContext> context, GainOptions const& options)
|
||||
{
|
||||
return construct_impl(realm, context, options);
|
||||
}
|
||||
|
||||
// https://webaudio.github.io/web-audio-api/#dom-gainnode-gainnode
|
||||
JS::NonnullGCPtr<GainNode> GainNode::construct_impl(JS::Realm& realm, JS::NonnullGCPtr<BaseAudioContext> context, GainOptions const& options)
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<GainNode>> GainNode::construct_impl(JS::Realm& realm, JS::NonnullGCPtr<BaseAudioContext> context, GainOptions const& options)
|
||||
{
|
||||
// FIXME: Invoke "Initialize the AudioNode" steps.
|
||||
return realm.vm().heap().allocate<GainNode>(realm, realm, context, options);
|
||||
// Create the node and allocate memory
|
||||
auto node = realm.vm().heap().allocate<GainNode>(realm, realm, context, options);
|
||||
|
||||
// Default options for channel count and interpretation
|
||||
// https://webaudio.github.io/web-audio-api/#GainNode
|
||||
AudioNodeDefaultOptions default_options;
|
||||
default_options.channel_count_mode = Bindings::ChannelCountMode::Max;
|
||||
default_options.channel_interpretation = Bindings::ChannelInterpretation::Speakers;
|
||||
default_options.channel_count = 2;
|
||||
// FIXME: Set tail-time to no
|
||||
|
||||
TRY(node->initialize_audio_node_options(options, default_options));
|
||||
return node;
|
||||
}
|
||||
|
||||
GainNode::GainNode(JS::Realm& realm, JS::NonnullGCPtr<BaseAudioContext> context, GainOptions const& options)
|
||||
|
|
|
@ -24,8 +24,8 @@ class GainNode : public AudioNode {
|
|||
public:
|
||||
virtual ~GainNode() override;
|
||||
|
||||
static JS::NonnullGCPtr<GainNode> create(JS::Realm&, JS::NonnullGCPtr<BaseAudioContext>, GainOptions const& = {});
|
||||
static JS::NonnullGCPtr<GainNode> construct_impl(JS::Realm&, JS::NonnullGCPtr<BaseAudioContext>, GainOptions const& = {});
|
||||
static WebIDL::ExceptionOr<JS::NonnullGCPtr<GainNode>> create(JS::Realm&, JS::NonnullGCPtr<BaseAudioContext>, GainOptions const& = {});
|
||||
static WebIDL::ExceptionOr<JS::NonnullGCPtr<GainNode>> construct_impl(JS::Realm&, JS::NonnullGCPtr<BaseAudioContext>, GainOptions const& = {});
|
||||
|
||||
WebIDL::UnsignedLong number_of_inputs() override { return 1; }
|
||||
WebIDL::UnsignedLong number_of_outputs() override { return 1; }
|
||||
|
|
Loading…
Reference in a new issue