LibWeb: Add stub IDL interface for AudioScheduledSourceNode

This is a base class of a few different audio nodes, most notably for
our immediate needs - OscillatorNode.
This commit is contained in:
Shannon Booth 2024-04-28 13:17:44 +12:00 committed by Andreas Kling
parent 6661c68b28
commit c9b2c1c747
7 changed files with 101 additions and 0 deletions

View file

@ -35,6 +35,7 @@ static bool is_platform_object(Type const& type)
"Attr"sv,
"AudioNode"sv,
"AudioParam"sv,
"AudioScheduledSourceNode"sv,
"AudioTrack"sv,
"BaseAudioContext"sv,
"Blob"sv,

View file

@ -661,6 +661,7 @@ set(SOURCES
WebAudio/AudioContext.cpp
WebAudio/AudioNode.cpp
WebAudio/AudioParam.cpp
WebAudio/AudioScheduledSourceNode.cpp
WebAudio/BaseAudioContext.cpp
WebAudio/OfflineAudioContext.cpp
WebAudio/PeriodicWave.cpp

View file

@ -683,6 +683,7 @@ namespace Web::WebAudio {
class AudioContext;
class AudioNode;
class AudioParam;
class AudioScheduledSourceNode;
class BaseAudioContext;
class OfflineAudioContext;
class PeriodicWave;

View file

@ -0,0 +1,55 @@
/*
* Copyright (c) 2024, Shannon Booth <shannon@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/Bindings/AudioScheduledSourceNodePrototype.h>
#include <LibWeb/Bindings/Intrinsics.h>
#include <LibWeb/HTML/EventNames.h>
#include <LibWeb/WebAudio/AudioScheduledSourceNode.h>
namespace Web::WebAudio {
JS_DEFINE_ALLOCATOR(AudioScheduledSourceNode);
AudioScheduledSourceNode::~AudioScheduledSourceNode() = default;
// https://webaudio.github.io/web-audio-api/#dom-audioscheduledsourcenode-onended
JS::GCPtr<WebIDL::CallbackType> AudioScheduledSourceNode::onended()
{
return event_handler_attribute(HTML::EventNames::ended);
}
// https://webaudio.github.io/web-audio-api/#dom-audioscheduledsourcenode-onended
void AudioScheduledSourceNode::set_onended(JS::GCPtr<WebIDL::CallbackType> value)
{
set_event_handler_attribute(HTML::EventNames::ended, value);
}
// https://webaudio.github.io/web-audio-api/#dom-audioscheduledsourcenode-start
WebIDL::ExceptionOr<void> AudioScheduledSourceNode::start(double when)
{
(void)when;
return WebIDL::NotSupportedError::create(realm(), "FIXME: Implement AudioScheduledSourceNode::start"_fly_string);
}
// https://webaudio.github.io/web-audio-api/#dom-audioscheduledsourcenode-stop
WebIDL::ExceptionOr<void> AudioScheduledSourceNode::stop(double when)
{
(void)when;
return WebIDL::NotSupportedError::create(realm(), "FIXME: Implement AudioScheduledSourceNode::stop"_fly_string);
}
void AudioScheduledSourceNode::initialize(JS::Realm& realm)
{
Base::initialize(realm);
WEB_SET_PROTOTYPE_FOR_INTERFACE(AudioScheduledSourceNode);
}
void AudioScheduledSourceNode::visit_edges(Cell::Visitor& visitor)
{
Base::visit_edges(visitor);
}
}

View file

@ -0,0 +1,32 @@
/*
* Copyright (c) 2024, Shannon Booth <shannon@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibWeb/WebAudio/AudioNode.h>
namespace Web::WebAudio {
// https://webaudio.github.io/web-audio-api/#AudioScheduledSourceNode
class AudioScheduledSourceNode : public AudioNode {
WEB_PLATFORM_OBJECT(AudioScheduledSourceNode, AudioNode);
JS_DECLARE_ALLOCATOR(AudioScheduledSourceNode);
public:
virtual ~AudioScheduledSourceNode() override;
JS::GCPtr<WebIDL::CallbackType> onended();
void set_onended(JS::GCPtr<WebIDL::CallbackType>);
WebIDL::ExceptionOr<void> start(double when = 0);
WebIDL::ExceptionOr<void> stop(double when = 0);
protected:
virtual void initialize(JS::Realm&) override;
virtual void visit_edges(Cell::Visitor&) override;
};
}

View file

@ -0,0 +1,10 @@
#import <DOM/EventHandler.idl>
#import <WebAudio/AudioNode.idl>
// https://webaudio.github.io/web-audio-api/#AudioScheduledSourceNode
[Exposed=Window]
interface AudioScheduledSourceNode : AudioNode {
attribute EventHandler onended;
undefined start(optional double when = 0);
undefined stop(optional double when = 0);
};

View file

@ -297,6 +297,7 @@ libweb_js_bindings(WebAudio/AudioBuffer)
libweb_js_bindings(WebAudio/AudioContext)
libweb_js_bindings(WebAudio/AudioNode)
libweb_js_bindings(WebAudio/AudioParam)
libweb_js_bindings(WebAudio/AudioScheduledSourceNode)
libweb_js_bindings(WebAudio/BaseAudioContext)
libweb_js_bindings(WebAudio/OfflineAudioContext)
libweb_js_bindings(WebAudio/PeriodicWave)