LibWeb/WebAudio: Add renderQuantumSize
Some checks are pending
CI / macOS, arm64, Sanitizer, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer, Clang (push) Waiting to run
Package the js repl as a binary artifact / Linux, arm64 (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / Linux, x86_64 (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run

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.
This commit is contained in:
Ben Eidson 2025-07-13 16:57:07 -04:00 committed by Jelle Raaijmakers
commit 96b142e10b
Notes: github-actions[bot] 2025-08-20 12:52:14 +00:00
5 changed files with 23 additions and 5 deletions

View file

@ -44,6 +44,8 @@ public:
static constexpr float MIN_SAMPLE_RATE { 8000 }; static constexpr float MIN_SAMPLE_RATE { 8000 };
static constexpr float MAX_SAMPLE_RATE { 192000 }; static constexpr float MAX_SAMPLE_RATE { 192000 };
static WebIDL::UnsignedLong render_quantum_size() { return s_render_quantum_size; }
GC::Ref<AudioDestinationNode> destination() const { return *m_destination; } GC::Ref<AudioDestinationNode> destination() const { return *m_destination; }
float sample_rate() const { return m_sample_rate; } float sample_rate() const { return m_sample_rate; }
double current_time() const { return m_current_time; } double current_time() const { return m_current_time; }
@ -94,6 +96,9 @@ protected:
Vector<GC::Ref<WebIDL::Promise>> m_pending_promises; Vector<GC::Ref<WebIDL::Promise>> m_pending_promises;
private: 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<JS::PromiseCapability>, GC::Root<WebIDL::BufferSource>, GC::Ptr<WebIDL::CallbackType>, GC::Ptr<WebIDL::CallbackType>); void queue_a_decoding_operation(GC::Ref<JS::PromiseCapability>, GC::Root<WebIDL::BufferSource>, GC::Ptr<WebIDL::CallbackType>, GC::Ptr<WebIDL::CallbackType>);
float m_sample_rate { 0 }; float m_sample_rate { 0 };

View file

@ -26,6 +26,7 @@ interface BaseAudioContext : EventTarget {
readonly attribute double currentTime; readonly attribute double currentTime;
readonly attribute AudioListener listener; readonly attribute AudioListener listener;
readonly attribute AudioContextState state; readonly attribute AudioContextState state;
readonly attribute unsigned long renderQuantumSize;
// FIXME: [SameObject, SecureContext] // FIXME: [SameObject, SecureContext]
[FIXME] readonly attribute AudioWorklet audioWorklet; [FIXME] readonly attribute AudioWorklet audioWorklet;
attribute EventHandler onstatechange; attribute EventHandler onstatechange;

View file

@ -0,0 +1 @@
128

View file

@ -2,8 +2,8 @@ Harness status: OK
Found 1147 tests Found 1147 tests
879 Pass 882 Pass
268 Fail 265 Fail
Fail idl_test setup Fail idl_test setup
Pass idl_test validation Pass idl_test validation
Pass Partial interface Element: member names are unique 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 currentTime
Pass BaseAudioContext interface: attribute listener Pass BaseAudioContext interface: attribute listener
Pass BaseAudioContext interface: attribute state Pass BaseAudioContext interface: attribute state
Fail BaseAudioContext interface: attribute renderQuantumSize Pass BaseAudioContext interface: attribute renderQuantumSize
Fail BaseAudioContext interface: attribute audioWorklet Fail BaseAudioContext interface: attribute audioWorklet
Pass BaseAudioContext interface: attribute onstatechange Pass BaseAudioContext interface: attribute onstatechange
Pass BaseAudioContext interface: operation createAnalyser() 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 "currentTime" with the proper type
Pass BaseAudioContext interface: context must inherit property "listener" 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 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 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 "onstatechange" with the proper type
Pass BaseAudioContext interface: context must inherit property "createAnalyser()" 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 "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 "listener" with the proper type
Pass BaseAudioContext interface: new OfflineAudioContext(1, 1, sample_rate) must inherit property "state" 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 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 "onstatechange" with the proper type
Pass BaseAudioContext interface: new OfflineAudioContext(1, 1, sample_rate) must inherit property "createAnalyser()" with the proper type Pass BaseAudioContext interface: new OfflineAudioContext(1, 1, sample_rate) must inherit property "createAnalyser()" with the proper type

View file

@ -0,0 +1,11 @@
<!DOCTYPE html>
<script src="../include.js"></script>
<script>
// Once the ctorofflineaudiocontext WPT test is updated to check
// renderQuantumSize and renderSizeHint, this test is not needed.
test(() => {
const audioContext = new OfflineAudioContext(1, 1, 44100)
println(`${audioContext.renderQuantumSize}`);
});
</script>