LibWeb: Add BaseAudioContext::createScriptProcessor()
Some checks are pending
CI / Linux, x86_64, Fuzzers, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer, Clang (push) Waiting to run
Package the js repl as a binary artifact / Linux, arm64 (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / Linux, x86_64 (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Push notes / build (push) Waiting to run
CI / macOS, arm64, Sanitizer, Clang (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run

This is a deprecated node, but it's still widely used on the web.
This commit is contained in:
Jelle Raaijmakers 2025-07-25 09:45:13 +02:00 committed by Andreas Kling
commit 35ca7f82b0
Notes: github-actions[bot] 2025-07-25 09:49:28 +00:00
17 changed files with 2614 additions and 6 deletions

View file

@ -0,0 +1,51 @@
/*
* Copyright (c) 2025, Jelle Raaijmakers <jelle@ladybird.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibWeb/WebAudio/AudioNode.h>
namespace Web::WebAudio {
// https://webaudio.github.io/web-audio-api/#ScriptProcessorNode
class ScriptProcessorNode final : public AudioNode {
WEB_PLATFORM_OBJECT(ScriptProcessorNode, AudioNode);
GC_DECLARE_ALLOCATOR(ScriptProcessorNode);
public:
static constexpr WebIDL::Long DEFAULT_BUFFER_SIZE = 1024;
virtual ~ScriptProcessorNode() override;
static WebIDL::ExceptionOr<GC::Ref<ScriptProcessorNode>> create(JS::Realm&, GC::Ref<BaseAudioContext>,
WebIDL::Long buffer_size, WebIDL::UnsignedLong number_of_input_channels,
WebIDL::UnsignedLong number_of_output_channel);
// ^AudioNode
virtual WebIDL::UnsignedLong channel_count() const override;
virtual WebIDL::ExceptionOr<void> set_channel_count(WebIDL::UnsignedLong) override;
virtual WebIDL::ExceptionOr<void> set_channel_count_mode(Bindings::ChannelCountMode) override;
virtual WebIDL::UnsignedLong number_of_inputs() override { return 1; }
virtual WebIDL::UnsignedLong number_of_outputs() override { return 1; }
GC::Ptr<WebIDL::CallbackType> onaudioprocess();
void set_onaudioprocess(GC::Ptr<WebIDL::CallbackType>);
WebIDL::Long buffer_size() const { return m_buffer_size; }
WebIDL::ExceptionOr<void> set_buffer_size(WebIDL::Long buffer_size);
private:
ScriptProcessorNode(JS::Realm&, GC::Ref<BaseAudioContext>, u8 number_of_input_channels,
u8 number_of_output_channels);
virtual void initialize(JS::Realm&) override;
WebIDL::Long m_buffer_size { 0 };
u8 m_number_of_input_channels { 0 };
u8 m_number_of_output_channels { 0 };
};
}