mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 12:19:54 +00:00
LibWeb/WebAudio: Implement automation rate constraints
Some nodes have parameters whose automation rate is not allowed to be changed. This change enforces that constraint for all parameters it applies to.
This commit is contained in:
parent
575edf8a90
commit
c87f80454b
Notes:
github-actions[bot]
2025-01-19 16:25:50 +00:00
Author: https://github.com/tcl3
Commit: c87f80454b
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3301
6 changed files with 316 additions and 13 deletions
|
@ -14,7 +14,7 @@ namespace Web::WebAudio {
|
|||
|
||||
GC_DEFINE_ALLOCATOR(AudioParam);
|
||||
|
||||
AudioParam::AudioParam(JS::Realm& realm, GC::Ref<BaseAudioContext> context, float default_value, float min_value, float max_value, Bindings::AutomationRate automation_rate)
|
||||
AudioParam::AudioParam(JS::Realm& realm, GC::Ref<BaseAudioContext> context, float default_value, float min_value, float max_value, Bindings::AutomationRate automation_rate, FixedAutomationRate fixed_automation_rate)
|
||||
: Bindings::PlatformObject(realm)
|
||||
, m_context(context)
|
||||
, m_current_value(default_value)
|
||||
|
@ -22,12 +22,13 @@ AudioParam::AudioParam(JS::Realm& realm, GC::Ref<BaseAudioContext> context, floa
|
|||
, m_min_value(min_value)
|
||||
, m_max_value(max_value)
|
||||
, m_automation_rate(automation_rate)
|
||||
, m_fixed_automation_rate(fixed_automation_rate)
|
||||
{
|
||||
}
|
||||
|
||||
GC::Ref<AudioParam> AudioParam::create(JS::Realm& realm, GC::Ref<BaseAudioContext> context, float default_value, float min_value, float max_value, Bindings::AutomationRate automation_rate)
|
||||
GC::Ref<AudioParam> AudioParam::create(JS::Realm& realm, GC::Ref<BaseAudioContext> context, float default_value, float min_value, float max_value, Bindings::AutomationRate automation_rate, FixedAutomationRate fixed_automation_rate)
|
||||
{
|
||||
return realm.create<AudioParam>(realm, context, default_value, min_value, max_value, automation_rate);
|
||||
return realm.create<AudioParam>(realm, context, default_value, min_value, max_value, automation_rate, fixed_automation_rate);
|
||||
}
|
||||
|
||||
AudioParam::~AudioParam() = default;
|
||||
|
@ -56,7 +57,9 @@ Bindings::AutomationRate AudioParam::automation_rate() const
|
|||
// https://webaudio.github.io/web-audio-api/#dom-audioparam-automationrate
|
||||
WebIDL::ExceptionOr<void> AudioParam::set_automation_rate(Bindings::AutomationRate automation_rate)
|
||||
{
|
||||
dbgln("FIXME: Fully implement AudioParam::set_automation_rate");
|
||||
if (automation_rate != m_automation_rate && m_fixed_automation_rate == FixedAutomationRate::Yes)
|
||||
return WebIDL::InvalidStateError::create(realm(), "Automation rate cannot be changed"_string);
|
||||
|
||||
m_automation_rate = automation_rate;
|
||||
return {};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue