LibWeb: Implement BaseAudioContext.createOscillator

Which currently will always throw an exception as it is unimplemented
under the hood - but this gives all of the plumbing we need in order to
create a oscillator node as used in the reduced turnstyle testcase.
This commit is contained in:
Shannon Booth 2024-04-28 12:07:14 +12:00 committed by Andreas Kling
parent a83f4216a5
commit 1678f43c38
Notes: sideshowbarker 2024-07-17 03:16:02 +09:00
3 changed files with 12 additions and 1 deletions

View file

@ -9,6 +9,7 @@
#include <LibWeb/Bindings/Intrinsics.h>
#include <LibWeb/HTML/EventNames.h>
#include <LibWeb/WebAudio/BaseAudioContext.h>
#include <LibWeb/WebAudio/OscillatorNode.h>
namespace Web::WebAudio {
@ -35,6 +36,13 @@ WebIDL::CallbackType* BaseAudioContext::onstatechange()
return event_handler_attribute(HTML::EventNames::statechange);
}
// https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-createoscillator
WebIDL::ExceptionOr<JS::NonnullGCPtr<OscillatorNode>> BaseAudioContext::create_oscillator()
{
// Factory method for an OscillatorNode.
return OscillatorNode::create(realm(), *this);
}
// https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-createbuffer
WebIDL::ExceptionOr<void> BaseAudioContext::verify_audio_options_inside_nominal_range(JS::Realm& realm, WebIDL::UnsignedLong number_of_channels, WebIDL::UnsignedLong length, float sample_rate)
{

View file

@ -44,6 +44,8 @@ public:
static WebIDL::ExceptionOr<void> verify_audio_options_inside_nominal_range(JS::Realm&, WebIDL::UnsignedLong number_of_channels, WebIDL::UnsignedLong length, float sample_rate);
WebIDL::ExceptionOr<JS::NonnullGCPtr<OscillatorNode>> create_oscillator();
protected:
explicit BaseAudioContext(JS::Realm&);

View file

@ -1,5 +1,6 @@
#import <DOM/EventTarget.idl>
#import <DOM/EventHandler.idl>
#import <WebAudio/OscillatorNode.idl>
// https://www.w3.org/TR/webaudio/#enumdef-audiocontextstate
enum AudioContextState { "suspended", "running", "closed" };
@ -32,7 +33,7 @@ interface BaseAudioContext : EventTarget {
// FIXME: DynamicsCompressorNode createDynamicsCompressor ();
// FIXME: GainNode createGain ();
// FIXME: IIRFilterNode createIIRFilter (sequence<double> feedforward, sequence<double> feedback);
// FIXME: OscillatorNode createOscillator ();
OscillatorNode createOscillator();
// FIXME: PannerNode createPanner ();
// FIXME: PeriodicWave createPeriodicWave (sequence<float> real, sequence<float> imag, optional PeriodicWaveConstraints constraints = {});
// FIXME: ScriptProcessorNode createScriptProcessor(optional unsigned long bufferSize = 0, optional unsigned long numberOfInputChannels = 2, optional unsigned long numberOfOutputChannels = 2);