mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-09 17:49:40 +00:00
LibAudio: Manage channelCountMode in DynamicsCompressorNode
That helps to pass more WPT tests under /webaudio/the-audio-api/the-dynamicscompressornode-interface/ctor-dynamicscompressor.html
This commit is contained in:
parent
ed658154d2
commit
f2ed59879f
Notes:
github-actions[bot]
2024-10-29 13:32:57 +00:00
Author: https://github.com/shlyakpavel
Commit: f2ed59879f
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1735
Reviewed-by: https://github.com/ADKaster ✅
Reviewed-by: https://github.com/gmta
Reviewed-by: https://github.com/shannonbooth
6 changed files with 100 additions and 5 deletions
|
@ -23,10 +23,21 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<DynamicsCompressorNode>> DynamicsCompressor
|
|||
// https://webaudio.github.io/web-audio-api/#dom-dynamicscompressornode-dynamicscompressornode
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<DynamicsCompressorNode>> DynamicsCompressorNode::construct_impl(JS::Realm& realm, JS::NonnullGCPtr<BaseAudioContext> context, DynamicsCompressorOptions const& options)
|
||||
{
|
||||
// FIXME: Invoke "Initialize the AudioNode" steps.
|
||||
return realm.vm().heap().allocate<DynamicsCompressorNode>(realm, realm, context, options);
|
||||
// Create the node and allocate memory
|
||||
auto node = realm.vm().heap().allocate<DynamicsCompressorNode>(realm, realm, context, options);
|
||||
|
||||
// Default options for channel count and interpretation
|
||||
AudioNodeOptions default_options;
|
||||
default_options.channel_count_mode = Bindings::ChannelCountMode::ClampedMax;
|
||||
default_options.channel_interpretation = Bindings::ChannelInterpretation::Speakers;
|
||||
|
||||
// Initialize the AudioNode with the given options, default options, and context
|
||||
TRY(node->initialize_audio_node_options(context, options, default_options));
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
|
||||
DynamicsCompressorNode::DynamicsCompressorNode(JS::Realm& realm, JS::NonnullGCPtr<BaseAudioContext> context, DynamicsCompressorOptions const& options)
|
||||
: AudioNode(realm, context)
|
||||
, m_threshold(AudioParam::create(realm, options.threshold, -100, 0, Bindings::AutomationRate::KRate))
|
||||
|
@ -53,4 +64,16 @@ void DynamicsCompressorNode::visit_edges(Cell::Visitor& visitor)
|
|||
visitor.visit(m_release);
|
||||
}
|
||||
|
||||
// https://webaudio.github.io/web-audio-api/#dom-audionode-channelcountmode
|
||||
WebIDL::ExceptionOr<void> DynamicsCompressorNode::set_channel_count_mode(Bindings::ChannelCountMode mode)
|
||||
{
|
||||
if (mode == Bindings::ChannelCountMode::Max) {
|
||||
// Return a NotSupportedError if 'max' is used
|
||||
return WebIDL::NotSupportedError::create(realm(), "DynamicsCompressorNode does not support 'max' as channelCountMode."_string);
|
||||
}
|
||||
|
||||
// If the mode is valid, call the base class implementation
|
||||
return AudioNode::set_channel_count_mode(mode);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue