LibWeb: Initialize AudioBufferSourceNode with correct defaults

This commit is contained in:
Tim Ledbetter 2025-01-04 02:21:16 +00:00 committed by Tim Ledbetter
commit a6ab9cc983
Notes: github-actions[bot] 2025-01-08 14:46:56 +00:00
4 changed files with 178 additions and 2 deletions

View file

@ -129,6 +129,17 @@ WebIDL::ExceptionOr<GC::Ref<AudioBufferSourceNode>> AudioBufferSourceNode::const
// MUST initialize the AudioNode this, with context and options as arguments.
auto node = realm.create<AudioBufferSourceNode>(realm, context, options);
// Default options for channel count and interpretation
// https://webaudio.github.io/web-audio-api/#AudioBufferSourceNode
AudioNodeDefaultOptions default_options;
default_options.channel_count = 2;
default_options.channel_count_mode = Bindings::ChannelCountMode::Max;
default_options.channel_interpretation = Bindings::ChannelInterpretation::Speakers;
// FIXME: Set tail-time to no
TRY(node->initialize_audio_node_options(options, default_options));
return node;
}

View file

@ -14,7 +14,7 @@
namespace Web::WebAudio {
// https://webaudio.github.io/web-audio-api/#AudioBufferSourceOptions
struct AudioBufferSourceOptions {
struct AudioBufferSourceOptions : AudioNodeOptions {
GC::Ptr<AudioBuffer> buffer;
float detune { 0 };
bool loop { false };
@ -42,7 +42,7 @@ public:
WebIDL::ExceptionOr<void> set_loop_end(double);
double loop_end() const;
WebIDL::UnsignedLong number_of_inputs() override { return 0; }
WebIDL::UnsignedLong number_of_outputs() override { return 2; }
WebIDL::UnsignedLong number_of_outputs() override { return 1; }
WebIDL::ExceptionOr<void> start(Optional<double>, Optional<double>, Optional<double>);