From 96b142e10b69b8cc38fdfcf720ddcb08dea39a7f Mon Sep 17 00:00:00 2001 From: Ben Eidson Date: Sun, 13 Jul 2025 16:57:07 -0400 Subject: [PATCH] LibWeb/WebAudio: Add renderQuantumSize Adds this attribute to BaseAudioContext.idl and adds associated test for OfflineAudioContext. This gives a set value that can be used to start implementing OfflineAudioContext::start_rendering(). Updates idlharness test to account for now implemented renderQuantumSize. --- Libraries/LibWeb/WebAudio/BaseAudioContext.h | 5 +++++ Libraries/LibWeb/WebAudio/BaseAudioContext.idl | 1 + .../Text/expected/WebAudio/OfflineAudioContext.txt | 1 + .../wpt-import/webaudio/idlharness.https.window.txt | 10 +++++----- .../Text/input/WebAudio/OfflineAudioContext.html | 11 +++++++++++ 5 files changed, 23 insertions(+), 5 deletions(-) create mode 100644 Tests/LibWeb/Text/expected/WebAudio/OfflineAudioContext.txt create mode 100644 Tests/LibWeb/Text/input/WebAudio/OfflineAudioContext.html diff --git a/Libraries/LibWeb/WebAudio/BaseAudioContext.h b/Libraries/LibWeb/WebAudio/BaseAudioContext.h index cab3e65e671..c5ef912e0a5 100644 --- a/Libraries/LibWeb/WebAudio/BaseAudioContext.h +++ b/Libraries/LibWeb/WebAudio/BaseAudioContext.h @@ -44,6 +44,8 @@ public: static constexpr float MIN_SAMPLE_RATE { 8000 }; static constexpr float MAX_SAMPLE_RATE { 192000 }; + static WebIDL::UnsignedLong render_quantum_size() { return s_render_quantum_size; } + GC::Ref destination() const { return *m_destination; } float sample_rate() const { return m_sample_rate; } double current_time() const { return m_current_time; } @@ -94,6 +96,9 @@ protected: Vector> m_pending_promises; private: + // https://webaudio.github.io/web-audio-api/#render-quantum-size + static constexpr WebIDL::UnsignedLong s_render_quantum_size { 128 }; + void queue_a_decoding_operation(GC::Ref, GC::Root, GC::Ptr, GC::Ptr); float m_sample_rate { 0 }; diff --git a/Libraries/LibWeb/WebAudio/BaseAudioContext.idl b/Libraries/LibWeb/WebAudio/BaseAudioContext.idl index 4677a3c941a..846f68eb295 100644 --- a/Libraries/LibWeb/WebAudio/BaseAudioContext.idl +++ b/Libraries/LibWeb/WebAudio/BaseAudioContext.idl @@ -26,6 +26,7 @@ interface BaseAudioContext : EventTarget { readonly attribute double currentTime; readonly attribute AudioListener listener; readonly attribute AudioContextState state; + readonly attribute unsigned long renderQuantumSize; // FIXME: [SameObject, SecureContext] [FIXME] readonly attribute AudioWorklet audioWorklet; attribute EventHandler onstatechange; diff --git a/Tests/LibWeb/Text/expected/WebAudio/OfflineAudioContext.txt b/Tests/LibWeb/Text/expected/WebAudio/OfflineAudioContext.txt new file mode 100644 index 00000000000..a949a93dfcc --- /dev/null +++ b/Tests/LibWeb/Text/expected/WebAudio/OfflineAudioContext.txt @@ -0,0 +1 @@ +128 diff --git a/Tests/LibWeb/Text/expected/wpt-import/webaudio/idlharness.https.window.txt b/Tests/LibWeb/Text/expected/wpt-import/webaudio/idlharness.https.window.txt index 45c10e27f8c..4d1b1fabea5 100644 --- a/Tests/LibWeb/Text/expected/wpt-import/webaudio/idlharness.https.window.txt +++ b/Tests/LibWeb/Text/expected/wpt-import/webaudio/idlharness.https.window.txt @@ -2,8 +2,8 @@ Harness status: OK Found 1147 tests -879 Pass -268 Fail +882 Pass +265 Fail Fail idl_test setup Pass idl_test validation Pass Partial interface Element: member names are unique @@ -26,7 +26,7 @@ Pass BaseAudioContext interface: attribute sampleRate Pass BaseAudioContext interface: attribute currentTime Pass BaseAudioContext interface: attribute listener Pass BaseAudioContext interface: attribute state -Fail BaseAudioContext interface: attribute renderQuantumSize +Pass BaseAudioContext interface: attribute renderQuantumSize Fail BaseAudioContext interface: attribute audioWorklet Pass BaseAudioContext interface: attribute onstatechange Pass BaseAudioContext interface: operation createAnalyser() @@ -93,7 +93,7 @@ Pass BaseAudioContext interface: context must inherit property "sampleRate" with Pass BaseAudioContext interface: context must inherit property "currentTime" with the proper type Pass BaseAudioContext interface: context must inherit property "listener" with the proper type Pass BaseAudioContext interface: context must inherit property "state" with the proper type -Fail BaseAudioContext interface: context must inherit property "renderQuantumSize" with the proper type +Pass BaseAudioContext interface: context must inherit property "renderQuantumSize" with the proper type Fail BaseAudioContext interface: context must inherit property "audioWorklet" with the proper type Pass BaseAudioContext interface: context must inherit property "onstatechange" with the proper type Pass BaseAudioContext interface: context must inherit property "createAnalyser()" with the proper type @@ -154,7 +154,7 @@ Pass BaseAudioContext interface: new OfflineAudioContext(1, 1, sample_rate) must Pass BaseAudioContext interface: new OfflineAudioContext(1, 1, sample_rate) must inherit property "currentTime" with the proper type Pass BaseAudioContext interface: new OfflineAudioContext(1, 1, sample_rate) must inherit property "listener" with the proper type Pass BaseAudioContext interface: new OfflineAudioContext(1, 1, sample_rate) must inherit property "state" with the proper type -Fail BaseAudioContext interface: new OfflineAudioContext(1, 1, sample_rate) must inherit property "renderQuantumSize" with the proper type +Pass BaseAudioContext interface: new OfflineAudioContext(1, 1, sample_rate) must inherit property "renderQuantumSize" with the proper type Fail BaseAudioContext interface: new OfflineAudioContext(1, 1, sample_rate) must inherit property "audioWorklet" with the proper type Pass BaseAudioContext interface: new OfflineAudioContext(1, 1, sample_rate) must inherit property "onstatechange" with the proper type Pass BaseAudioContext interface: new OfflineAudioContext(1, 1, sample_rate) must inherit property "createAnalyser()" with the proper type diff --git a/Tests/LibWeb/Text/input/WebAudio/OfflineAudioContext.html b/Tests/LibWeb/Text/input/WebAudio/OfflineAudioContext.html new file mode 100644 index 00000000000..1ac5fccd0ac --- /dev/null +++ b/Tests/LibWeb/Text/input/WebAudio/OfflineAudioContext.html @@ -0,0 +1,11 @@ + + +