Skip to content

Truly independent web browser

LibWeb: Remove obsolete WebAudio C++ facades

Shannon Booth07f56972e457
diff --git a/Libraries/LibWeb/Bindings/Rust/src/bindings/event_target.rs b/Libraries/LibWeb/Bindings/Rust/src/bindings/event_target.rs
index 6ac2e3d57a8..bb6f3c96705 100644
--- a/Libraries/LibWeb/Bindings/Rust/src/bindings/event_target.rs
+++ b/Libraries/LibWeb/Bindings/Rust/src/bindings/event_target.rs
@@ -221,12 +221,6 @@ impl CppEventTarget {
pub(crate) struct CppEvent(CppCell);
impl CppEvent {
- /// # Safety
- /// `event` must be a live C++ Event that the returned handle keeps alive.
- pub(crate) unsafe fn from_raw(event: *mut c_void) -> Self {
- Self(unsafe { CppCell::from_raw(event) })
- }
-
pub(crate) fn create(realm: Gc<Realm>, r#type: &str, bubbles: bool, cancelable: bool, composed: bool) -> Self {
// SAFETY: The realm is live, the type is lent for the call, and LibWeb returns a live event.
let event = Self(unsafe {
diff --git a/Libraries/LibWeb/Bindings/Rust/src/web_audio/analyser_node.rs b/Libraries/LibWeb/Bindings/Rust/src/web_audio/analyser_node.rs
index bf975a64298..7e6416fd4a3 100644
--- a/Libraries/LibWeb/Bindings/Rust/src/web_audio/analyser_node.rs
+++ b/Libraries/LibWeb/Bindings/Rust/src/web_audio/analyser_node.rs
@@ -19,7 +19,7 @@ use libjs_rust::api::{
};
use libjs_rust::api::{Gc, Trace};
use libweb_rust::web_audio::control_message::FfiSharedCppObject;
-use libweb_rust::web_audio::rendering::analyser_render_node::web_audio_node_create_analyser;
+use libweb_rust::web_audio::rendering::analyser_render_node::create_analyser_render_node;
use libweb_rust::web_audio::rendering::audio_frame_ring::{AudioFrameRing, AudioFrameRingCallbacks};
use libweb_rust::web_audio::rendering::fft::{FFT, FFTDirection};
use libweb_rust::web_audio::rendering::node_message::SharedCppObject;
@@ -154,12 +154,12 @@ impl AnalyserNode {
callbacks,
});
node.node.queue_render_node_creation(unsafe {
- Box::from_raw(web_audio_node_create_analyser(
+ create_analyser_render_node(
node.node.node_id(),
BaseAudioContext::RENDER_QUANTUM_SIZE as usize,
ring,
callbacks,
- ))
+ )
});
Ok(node)
}
diff --git a/Libraries/LibWeb/Bindings/Rust/src/web_audio/audio_buffer_source_node.rs b/Libraries/LibWeb/Bindings/Rust/src/web_audio/audio_buffer_source_node.rs
index 146bad87892..1f76916fffa 100644
--- a/Libraries/LibWeb/Bindings/Rust/src/web_audio/audio_buffer_source_node.rs
+++ b/Libraries/LibWeb/Bindings/Rust/src/web_audio/audio_buffer_source_node.rs
@@ -15,7 +15,7 @@ use libjs_rust::api::Trace;
use libweb_rust::web_audio::control_message::ControlMessage;
use libweb_rust::web_audio::rendering::audio_data::AudioBufferContents;
use libweb_rust::web_audio::rendering::node_message::{NodeMessage, SetBufferSourceParameters, StartBufferSource};
-use libweb_rust::web_audio::rendering::render_nodes::web_audio_node_create_audio_buffer_source;
+use libweb_rust::web_audio::rendering::render_nodes::create_audio_buffer_source_render_node;
use super::audio_buffer::AudioBuffer;
use super::audio_node::{
@@ -293,14 +293,14 @@ impl AudioBufferSourceNode {
node.node
.parent()
.initialize_audio_node_options(cx, &AudioNodeOptions::default(), &default_options)?;
- node.node.parent().queue_render_node_creation(unsafe {
- Box::from_raw(web_audio_node_create_audio_buffer_source(
+ node.node
+ .parent()
+ .queue_render_node_creation(create_audio_buffer_source_render_node(
node.node.parent().node_id(),
BaseAudioContext::RENDER_QUANTUM_SIZE as usize,
- Arc::as_ptr(node.playback_rate.render_param()),
- Arc::as_ptr(node.detune.render_param()),
- ))
- });
+ Arc::clone(node.playback_rate.render_param()),
+ Arc::clone(node.detune.render_param()),
+ ));
node.queue_parameters_update(None, false);
Ok(node)
}
diff --git a/Libraries/LibWeb/Bindings/Rust/src/web_audio/audio_destination_node.rs b/Libraries/LibWeb/Bindings/Rust/src/web_audio/audio_destination_node.rs
index 1a87337a1bf..e8c032164c2 100644
--- a/Libraries/LibWeb/Bindings/Rust/src/web_audio/audio_destination_node.rs
+++ b/Libraries/LibWeb/Bindings/Rust/src/web_audio/audio_destination_node.rs
@@ -13,7 +13,7 @@ use std::ptr::NonNull;
use ak::Utf16String;
use libjs_rust::api::Trace;
-use libweb_rust::web_audio::rendering::render_nodes::web_audio_node_create_destination;
+use libweb_rust::web_audio::rendering::render_nodes::create_destination_render_node;
use super::audio_node::{
AnyAudioNode, AudioNode, AudioNodeDefaultOptions, AudioNodeOptions, ChannelCountMode, ChannelInterpretation,
@@ -97,13 +97,11 @@ impl AudioDestinationNode {
// FIXME: Set tail-time to no
node.node
.initialize_audio_node_options(cx, &AudioNodeOptions::default(), &default_options)?;
- node.node.queue_render_node_creation(unsafe {
- Box::from_raw(web_audio_node_create_destination(
- node.node.node_id(),
- BaseAudioContext::RENDER_QUANTUM_SIZE as usize,
- channel_count as usize,
- ))
- });
+ node.node.queue_render_node_creation(create_destination_render_node(
+ node.node.node_id(),
+ BaseAudioContext::RENDER_QUANTUM_SIZE as usize,
+ channel_count as usize,
+ ));
Ok(node)
}
diff --git a/Libraries/LibWeb/Bindings/Rust/src/web_audio/audio_worklet_node.rs b/Libraries/LibWeb/Bindings/Rust/src/web_audio/audio_worklet_node.rs
index d69f34ecde6..9f200005b15 100644
--- a/Libraries/LibWeb/Bindings/Rust/src/web_audio/audio_worklet_node.rs
+++ b/Libraries/LibWeb/Bindings/Rust/src/web_audio/audio_worklet_node.rs
@@ -20,7 +20,7 @@ use libjs_rust::api::{
use libjs_rust::api::{Gc, Realm, Trace};
use libweb_rust::web_audio::control_message::FfiSharedCppObject;
use libweb_rust::web_audio::rendering::audio_worklet_pipe::{AudioWorkletPipe, WorkletPipeConfig, WorkletPipeState};
-use libweb_rust::web_audio::rendering::audio_worklet_render_node::web_audio_node_create_audio_worklet;
+use libweb_rust::web_audio::rendering::audio_worklet_render_node::create_audio_worklet_render_node;
use libweb_rust::web_audio::rendering::node_message::SharedCppObject;
use libweb_rust::web_audio::rendering::render_node::RenderAudioParam;
@@ -446,26 +446,24 @@ impl AudioWorkletNode {
release: service.release,
});
unsafe { web_audio_worklet_set_pump(service.pointer, scope.as_ptr(), node.node.node_id()) };
- let render_params: Vec<*const RenderAudioParam> = parameter_map
+ let render_params: Vec<Arc<RenderAudioParam>> = parameter_map
.values(vm)
.values()
.iter()
- .map(|param| Arc::as_ptr(param.render_param()))
+ .map(|param| Arc::clone(param.render_param()))
.collect();
- node.node.queue_render_node_creation(unsafe {
- Box::from_raw(web_audio_node_create_audio_worklet(
- node.node.node_id(),
- options.number_of_inputs as usize,
- options.number_of_outputs as usize,
- BaseAudioContext::RENDER_QUANTUM_SIZE as usize,
- ak::Span::new(&output_channel_capacity),
- node.node.channel_count_value() as usize,
- node.node.channel_count_mode(cx)?,
- node.node.channel_interpretation(cx)?,
- Arc::as_ptr(&pipe),
- ak::Span::new(&render_params),
- ))
- });
+ node.node.queue_render_node_creation(create_audio_worklet_render_node(
+ node.node.node_id(),
+ options.number_of_inputs as usize,
+ options.number_of_outputs as usize,
+ BaseAudioContext::RENDER_QUANTUM_SIZE as usize,
+ &output_channel_capacity,
+ node.node.channel_count_value() as usize,
+ node.node.channel_count_mode(cx)?,
+ node.node.channel_interpretation(cx)?,
+ Arc::clone(&pipe),
+ render_params,
+ ));
// FIXME: Implement the spec's actively-processing keep-alive (drop this when the processor's
// process() return value has been false and inputs are silent). For now a live worklet
diff --git a/Libraries/LibWeb/Bindings/Rust/src/web_audio/biquad_filter_node.rs b/Libraries/LibWeb/Bindings/Rust/src/web_audio/biquad_filter_node.rs
index 3f27ab4909a..cf7bf3ffb94 100644
--- a/Libraries/LibWeb/Bindings/Rust/src/web_audio/biquad_filter_node.rs
+++ b/Libraries/LibWeb/Bindings/Rust/src/web_audio/biquad_filter_node.rs
@@ -16,7 +16,7 @@ use libjs_rust::api::{Gc, Trace};
use libweb_rust::web_audio::control_message::ControlMessage;
use libweb_rust::web_audio::rendering::biquad_coefficients::{biquad_frequency_response, compute_biquad_coefficients};
use libweb_rust::web_audio::rendering::node_message::{NodeMessage, SetBiquadFilterType};
-use libweb_rust::web_audio::rendering::render_nodes::web_audio_node_create_biquad_filter;
+use libweb_rust::web_audio::rendering::render_nodes::create_biquad_filter_render_node;
use super::audio_array::{copy_float32_array, float32_array_length, overwrite_float32_array};
use super::audio_node::{
@@ -154,16 +154,14 @@ impl BiquadFilterNode {
// FIXME: Set tail-time to yes
node.node
.initialize_audio_node_options(cx, &options.parent, &default_options)?;
- node.node.queue_render_node_creation(unsafe {
- Box::from_raw(web_audio_node_create_biquad_filter(
- node.node.node_id(),
- BaseAudioContext::RENDER_QUANTUM_SIZE as usize,
- Arc::as_ptr(node.frequency.render_param()),
- Arc::as_ptr(node.detune.render_param()),
- Arc::as_ptr(node.q.render_param()),
- Arc::as_ptr(node.gain.render_param()),
- ))
- });
+ node.node.queue_render_node_creation(create_biquad_filter_render_node(
+ node.node.node_id(),
+ BaseAudioContext::RENDER_QUANTUM_SIZE as usize,
+ Arc::clone(node.frequency.render_param()),
+ Arc::clone(node.detune.render_param()),
+ Arc::clone(node.q.render_param()),
+ Arc::clone(node.gain.render_param()),
+ ));
if options.r#type != BiquadFilterType::Lowpass {
context.queue_control_message(ControlMessage::NodeMessage(NodeMessage::SetBiquadFilterType(
SetBiquadFilterType {
diff --git a/Libraries/LibWeb/Bindings/Rust/src/web_audio/channel_merger_node.rs b/Libraries/LibWeb/Bindings/Rust/src/web_audio/channel_merger_node.rs
index 6cbffff289a..5d82e52de2e 100644
--- a/Libraries/LibWeb/Bindings/Rust/src/web_audio/channel_merger_node.rs
+++ b/Libraries/LibWeb/Bindings/Rust/src/web_audio/channel_merger_node.rs
@@ -10,7 +10,7 @@ use std::ptr::NonNull;
use ak::Utf16String;
use libjs_rust::api::Trace;
-use libweb_rust::web_audio::rendering::render_nodes::web_audio_node_create_channel_merger;
+use libweb_rust::web_audio::rendering::render_nodes::create_channel_merger_render_node;
use super::audio_node::{
AnyAudioNode, AudioNode, AudioNodeDefaultOptions, AudioNodeOptions, ChannelCountMode, ChannelInterpretation,
@@ -103,13 +103,11 @@ impl ChannelMergerNode {
// FIXME: Set tail-time to no
node.node
.initialize_audio_node_options(cx, &options.parent, &default_options)?;
- node.node.queue_render_node_creation(unsafe {
- Box::from_raw(web_audio_node_create_channel_merger(
- node.node.node_id(),
- BaseAudioContext::RENDER_QUANTUM_SIZE as usize,
- options.number_of_inputs as usize,
- ))
- });
+ node.node.queue_render_node_creation(create_channel_merger_render_node(
+ node.node.node_id(),
+ BaseAudioContext::RENDER_QUANTUM_SIZE as usize,
+ options.number_of_inputs as usize,
+ ));
Ok(node)
}
diff --git a/Libraries/LibWeb/Bindings/Rust/src/web_audio/channel_splitter_node.rs b/Libraries/LibWeb/Bindings/Rust/src/web_audio/channel_splitter_node.rs
index 8f456b61894..f7ce87961aa 100644
--- a/Libraries/LibWeb/Bindings/Rust/src/web_audio/channel_splitter_node.rs
+++ b/Libraries/LibWeb/Bindings/Rust/src/web_audio/channel_splitter_node.rs
@@ -10,7 +10,7 @@ use std::ptr::NonNull;
use ak::Utf16String;
use libjs_rust::api::Trace;
-use libweb_rust::web_audio::rendering::render_nodes::web_audio_node_create_channel_splitter;
+use libweb_rust::web_audio::rendering::render_nodes::create_channel_splitter_render_node;
use super::audio_node::{
AnyAudioNode, AudioNode, AudioNodeDefaultOptions, AudioNodeOptions, ChannelCountMode, ChannelInterpretation,
@@ -102,13 +102,12 @@ impl ChannelSplitterNode {
// FIXME: Set tail-time to no
node.node
.initialize_audio_node_options(cx, &options.parent, &default_options)?;
- node.node.queue_render_node_creation(unsafe {
- Box::from_raw(web_audio_node_create_channel_splitter(
+ node.node
+ .queue_render_node_creation(create_channel_splitter_render_node(
node.node.node_id(),
BaseAudioContext::RENDER_QUANTUM_SIZE as usize,
options.number_of_outputs as usize,
- ))
- });
+ ));
Ok(node)
}
diff --git a/Libraries/LibWeb/Bindings/Rust/src/web_audio/constant_source_node.rs b/Libraries/LibWeb/Bindings/Rust/src/web_audio/constant_source_node.rs
index 0a290f660f5..2f5f99b9c76 100644
--- a/Libraries/LibWeb/Bindings/Rust/src/web_audio/constant_source_node.rs
+++ b/Libraries/LibWeb/Bindings/Rust/src/web_audio/constant_source_node.rs
@@ -10,7 +10,7 @@ use std::ptr::NonNull;
use std::sync::Arc;
use libjs_rust::api::Trace;
-use libweb_rust::web_audio::rendering::render_nodes::web_audio_node_create_constant_source;
+use libweb_rust::web_audio::rendering::render_nodes::create_constant_source_render_node;
use super::audio_node::AnyAudioNode;
use super::audio_param::{AudioParam, AutomationRate, FixedAutomationRate};
@@ -88,13 +88,13 @@ impl ConstantSourceNode {
node.node.parent().set_this(AnyAudioNode::ConstantSourceNode(node));
node.node.parent().event_target().set_owner(node);
node.offset.set_owner(AnyAudioNode::ConstantSourceNode(node));
- node.node.parent().queue_render_node_creation(unsafe {
- Box::from_raw(web_audio_node_create_constant_source(
+ node.node
+ .parent()
+ .queue_render_node_creation(create_constant_source_render_node(
node.node.parent().node_id(),
BaseAudioContext::RENDER_QUANTUM_SIZE as usize,
- Arc::as_ptr(node.offset.render_param()),
- ))
- });
+ Arc::clone(node.offset.render_param()),
+ ));
Ok(node)
}
diff --git a/Libraries/LibWeb/Bindings/Rust/src/web_audio/convolver_node.rs b/Libraries/LibWeb/Bindings/Rust/src/web_audio/convolver_node.rs
index 4d29638db52..bc967eb633b 100644
--- a/Libraries/LibWeb/Bindings/Rust/src/web_audio/convolver_node.rs
+++ b/Libraries/LibWeb/Bindings/Rust/src/web_audio/convolver_node.rs
@@ -17,7 +17,7 @@ use libjs_rust::api::Trace;
use libweb_rust::web_audio::control_message::ControlMessage;
use libweb_rust::web_audio::rendering::convolver_kernel::{AudioBufferContents, ConvolverDelayLine, ConvolverKernel};
use libweb_rust::web_audio::rendering::node_message::{NodeMessage, SetConvolverKernel};
-use libweb_rust::web_audio::rendering::render_nodes::web_audio_node_create_convolver;
+use libweb_rust::web_audio::rendering::render_nodes::create_convolver_render_node;
use super::audio_buffer::AudioBuffer;
use super::audio_node::{
@@ -86,12 +86,11 @@ impl ConvolverNode {
});
node.node.set_this(AnyAudioNode::ConvolverNode(node));
node.node.event_target().set_owner(node);
- node.node.queue_render_node_creation(unsafe {
- Box::from_raw(web_audio_node_create_convolver(
- node.node.node_id(),
- BaseAudioContext::RENDER_QUANTUM_SIZE as usize,
- ))
- });
+ node.node.queue_render_node_creation(create_convolver_render_node(
+ node.node.node_id(),
+ BaseAudioContext::RENDER_QUANTUM_SIZE as usize,
+ ));
+
// 1. Set the attributes normalize to the inverse of the value of disableNormalization.
// NB: Done by the constructor above, so that step 2 already sees the final value.
// 2. If buffer exists, set the buffer attribute to its value.
diff --git a/Libraries/LibWeb/Bindings/Rust/src/web_audio/delay_node.rs b/Libraries/LibWeb/Bindings/Rust/src/web_audio/delay_node.rs
index ce0a26d584a..25fc6f401b5 100644
--- a/Libraries/LibWeb/Bindings/Rust/src/web_audio/delay_node.rs
+++ b/Libraries/LibWeb/Bindings/Rust/src/web_audio/delay_node.rs
@@ -11,7 +11,7 @@ use std::sync::Arc;
use ak::Utf16String;
use libjs_rust::api::Trace;
-use libweb_rust::web_audio::rendering::render_nodes::web_audio_node_create_delay;
+use libweb_rust::web_audio::rendering::render_nodes::create_delay_render_node;
use super::audio_node::{
AnyAudioNode, AudioNode, AudioNodeDefaultOptions, AudioNodeOptions, ChannelCountMode, ChannelInterpretation,
@@ -121,14 +121,12 @@ impl DelayNode {
// FIXME: Set tail-time to yes
node.node
.initialize_audio_node_options(cx, &options.parent, &default_options)?;
- node.node.queue_render_node_creation(unsafe {
- Box::from_raw(web_audio_node_create_delay(
- node.node.node_id(),
- BaseAudioContext::RENDER_QUANTUM_SIZE as usize,
- Arc::as_ptr(node.delay_time.render_param()),
- options.max_delay_time,
- ))
- });
+ node.node.queue_render_node_creation(create_delay_render_node(
+ node.node.node_id(),
+ BaseAudioContext::RENDER_QUANTUM_SIZE as usize,
+ Arc::clone(node.delay_time.render_param()),
+ options.max_delay_time,
+ ));
Ok(node)
}
diff --git a/Libraries/LibWeb/Bindings/Rust/src/web_audio/dynamics_compressor_node.rs b/Libraries/LibWeb/Bindings/Rust/src/web_audio/dynamics_compressor_node.rs
index 7138663702c..af60db44a22 100644
--- a/Libraries/LibWeb/Bindings/Rust/src/web_audio/dynamics_compressor_node.rs
+++ b/Libraries/LibWeb/Bindings/Rust/src/web_audio/dynamics_compressor_node.rs
@@ -10,7 +10,7 @@ use std::ptr::NonNull;
use ak::Utf16String;
use libjs_rust::api::Trace;
-use libweb_rust::web_audio::rendering::render_nodes::web_audio_node_create_passthrough;
+use libweb_rust::web_audio::rendering::render_nodes::create_passthrough_render_node;
use super::audio_node::{
AnyAudioNode, AudioNode, AudioNodeDefaultOptions, AudioNodeOptions, ChannelCountMode, ChannelInterpretation,
@@ -170,12 +170,10 @@ impl DynamicsCompressorNode {
.initialize_audio_node_options(cx, &options.parent, &default_options)?;
// FIXME: Implement actual dynamics compression; for now the signal passes through unchanged.
- node.node.queue_render_node_creation(unsafe {
- Box::from_raw(web_audio_node_create_passthrough(
- node.node.node_id(),
- BaseAudioContext::RENDER_QUANTUM_SIZE as usize,
- ))
- });
+ node.node.queue_render_node_creation(create_passthrough_render_node(
+ node.node.node_id(),
+ BaseAudioContext::RENDER_QUANTUM_SIZE as usize,
+ ));
Ok(node)
}
diff --git a/Libraries/LibWeb/Bindings/Rust/src/web_audio/gain_node.rs b/Libraries/LibWeb/Bindings/Rust/src/web_audio/gain_node.rs
index a0eb520b02f..bc4421a7001 100644
--- a/Libraries/LibWeb/Bindings/Rust/src/web_audio/gain_node.rs
+++ b/Libraries/LibWeb/Bindings/Rust/src/web_audio/gain_node.rs
@@ -10,7 +10,7 @@ use std::ptr::NonNull;
use std::sync::Arc;
use libjs_rust::api::Trace;
-use libweb_rust::web_audio::rendering::render_nodes::web_audio_node_create_gain;
+use libweb_rust::web_audio::rendering::render_nodes::create_gain_render_node;
use super::audio_node::{
AnyAudioNode, AudioNode, AudioNodeDefaultOptions, AudioNodeOptions, ChannelCountMode, ChannelInterpretation,
@@ -104,13 +104,11 @@ impl GainNode {
// FIXME: Set tail-time to no
node.node
.initialize_audio_node_options(cx, &options.parent, &default_options)?;
- node.node.queue_render_node_creation(unsafe {
- Box::from_raw(web_audio_node_create_gain(
- node.node.node_id(),
- BaseAudioContext::RENDER_QUANTUM_SIZE as usize,
- Arc::as_ptr(node.gain.render_param()),
- ))
- });
+ node.node.queue_render_node_creation(create_gain_render_node(
+ node.node.node_id(),
+ BaseAudioContext::RENDER_QUANTUM_SIZE as usize,
+ Arc::clone(node.gain.render_param()),
+ ));
Ok(node)
}
diff --git a/Libraries/LibWeb/Bindings/Rust/src/web_audio/iir_filter_node.rs b/Libraries/LibWeb/Bindings/Rust/src/web_audio/iir_filter_node.rs
index d5c64db1f37..8d2f5305601 100644
--- a/Libraries/LibWeb/Bindings/Rust/src/web_audio/iir_filter_node.rs
+++ b/Libraries/LibWeb/Bindings/Rust/src/web_audio/iir_filter_node.rs
@@ -10,7 +10,7 @@ use std::ptr::NonNull;
use ak::Utf16String;
use libjs_rust::api::TypedArrayBase;
use libjs_rust::api::{Gc, Trace};
-use libweb_rust::web_audio::rendering::render_nodes::web_audio_node_create_iir_filter;
+use libweb_rust::web_audio::rendering::render_nodes::create_iir_filter_render_node;
use super::audio_array::{copy_float32_array, float32_array_length, overwrite_float32_array};
use super::audio_node::{
@@ -139,14 +139,12 @@ impl IIRFilterNode {
// FIXME: Set tail-time to yes
node.node
.initialize_audio_node_options(cx, &options.parent, &default_options)?;
- node.node.queue_render_node_creation(unsafe {
- Box::from_raw(web_audio_node_create_iir_filter(
- node.node.node_id(),
- BaseAudioContext::RENDER_QUANTUM_SIZE as usize,
- ak::Span::new(&normalized_feedforward),
- ak::Span::new(&normalized_feedback),
- ))
- });
+ node.node.queue_render_node_creation(create_iir_filter_render_node(
+ node.node.node_id(),
+ BaseAudioContext::RENDER_QUANTUM_SIZE as usize,
+ &normalized_feedforward,
+ &normalized_feedback,
+ ));
Ok(node)
}
diff --git a/Libraries/LibWeb/Bindings/Rust/src/web_audio/media_stream_audio_source_node.rs b/Libraries/LibWeb/Bindings/Rust/src/web_audio/media_stream_audio_source_node.rs
index b2c80a7d4e0..0f3edde91c3 100644
--- a/Libraries/LibWeb/Bindings/Rust/src/web_audio/media_stream_audio_source_node.rs
+++ b/Libraries/LibWeb/Bindings/Rust/src/web_audio/media_stream_audio_source_node.rs
@@ -16,7 +16,7 @@ use libjs_rust::api::Object;
use libjs_rust::api::{Gc, Trace};
use libweb_rust::web_audio::control_message::{ControlMessage, FfiSharedCppObject};
use libweb_rust::web_audio::rendering::audio_frame_ring::AudioFrameRingCallbacks;
-use libweb_rust::web_audio::rendering::media_stream_source_render_node::web_audio_node_create_media_stream_source;
+use libweb_rust::web_audio::rendering::media_stream_source_render_node::create_media_stream_source_render_node;
use libweb_rust::web_audio::rendering::node_message::{NodeMessage, SetMediaStreamSourceRing, SharedCppObject};
use super::audio_context::AudioContext;
@@ -177,11 +177,11 @@ impl MediaStreamAudioSourceNode {
let mut callbacks = std::mem::MaybeUninit::uninit();
unsafe { web_audio_media_source_ring_callbacks(callbacks.as_mut_ptr()) };
node.node.queue_render_node_creation(unsafe {
- Box::from_raw(web_audio_node_create_media_stream_source(
+ create_media_stream_source_render_node(
node.node.node_id(),
BaseAudioContext::RENDER_QUANTUM_SIZE as usize,
callbacks.assume_init(),
- ))
+ )
});
node.attach_input_track();
context.parent().add_media_stream_source(cx.vm(), node);
diff --git a/Libraries/LibWeb/Bindings/Rust/src/web_audio/oscillator_node.rs b/Libraries/LibWeb/Bindings/Rust/src/web_audio/oscillator_node.rs
index e4d3003755f..80961ccb676 100644
--- a/Libraries/LibWeb/Bindings/Rust/src/web_audio/oscillator_node.rs
+++ b/Libraries/LibWeb/Bindings/Rust/src/web_audio/oscillator_node.rs
@@ -15,7 +15,7 @@ use ak::Utf16String;
use libjs_rust::api::Trace;
use libweb_rust::web_audio::control_message::ControlMessage;
use libweb_rust::web_audio::rendering::node_message::{NodeMessage, SetOscillatorWaveform};
-use libweb_rust::web_audio::rendering::render_nodes::web_audio_node_create_oscillator;
+use libweb_rust::web_audio::rendering::render_nodes::create_oscillator_render_node;
use super::audio_node::{
AnyAudioNode, AudioNodeDefaultOptions, AudioNodeOptions, ChannelCountMode, ChannelInterpretation,
@@ -145,14 +145,14 @@ impl OscillatorNode {
node.node
.parent()
.initialize_audio_node_options(cx, &options.parent, &default_options)?;
- node.node.parent().queue_render_node_creation(unsafe {
- Box::from_raw(web_audio_node_create_oscillator(
+ node.node
+ .parent()
+ .queue_render_node_creation(create_oscillator_render_node(
node.node.parent().node_id(),
BaseAudioContext::RENDER_QUANTUM_SIZE as usize,
- Arc::as_ptr(node.frequency.render_param()),
- Arc::as_ptr(node.detune.render_param()),
- ))
- });
+ Arc::clone(node.frequency.render_param()),
+ Arc::clone(node.detune.render_param()),
+ ));
node.queue_waveform_update();
Ok(node)
}
diff --git a/Libraries/LibWeb/Bindings/Rust/src/web_audio/panner_node.rs b/Libraries/LibWeb/Bindings/Rust/src/web_audio/panner_node.rs
index e9cc6c58882..ec6271af4ed 100644
--- a/Libraries/LibWeb/Bindings/Rust/src/web_audio/panner_node.rs
+++ b/Libraries/LibWeb/Bindings/Rust/src/web_audio/panner_node.rs
@@ -8,13 +8,12 @@
use std::cell::Cell;
use std::ffi::c_void;
use std::ptr::NonNull;
-use std::sync::Arc;
use ak::Utf16String;
use libjs_rust::api::Trace;
use libweb_rust::web_audio::control_message::ControlMessage;
use libweb_rust::web_audio::rendering::node_message::{NodeMessage, SetPannerParameters};
-use libweb_rust::web_audio::rendering::render_nodes::web_audio_node_create_panner;
+use libweb_rust::web_audio::rendering::render_nodes::create_panner_render_node;
use super::audio_node::{
AnyAudioNode, AudioNode, AudioNodeDefaultOptions, AudioNodeOptions, ChannelCountMode, ChannelInterpretation,
@@ -68,8 +67,10 @@ pub(crate) struct PannerNode {
// https://webaudio.github.io/web-audio-api/#dom-pannernode-rollofffactor
rolloff_factor: Cell<f64>,
+ // https://webaudio.github.io/web-audio-api/#dom-pannernode-coneinnerangle
cone_inner_angle: Cell<f64>,
+ // https://webaudio.github.io/web-audio-api/#dom-pannernode-coneouterangle
cone_outer_angle: Cell<f64>,
// https://webaudio.github.io/web-audio-api/#dom-pannernode-coneoutergain
@@ -236,29 +237,27 @@ impl PannerNode {
.initialize_audio_node_options(cx, &options.parent, &default_options)?;
let listener = context.listener_value();
let params = [
- Arc::as_ptr(node.position_x.render_param()),
- Arc::as_ptr(node.position_y.render_param()),
- Arc::as_ptr(node.position_z.render_param()),
- Arc::as_ptr(node.orientation_x.render_param()),
- Arc::as_ptr(node.orientation_y.render_param()),
- Arc::as_ptr(node.orientation_z.render_param()),
- Arc::as_ptr(listener.position_x.render_param()),
- Arc::as_ptr(listener.position_y.render_param()),
- Arc::as_ptr(listener.position_z.render_param()),
- Arc::as_ptr(listener.forward_x.render_param()),
- Arc::as_ptr(listener.forward_y.render_param()),
- Arc::as_ptr(listener.forward_z.render_param()),
- Arc::as_ptr(listener.up_x.render_param()),
- Arc::as_ptr(listener.up_y.render_param()),
- Arc::as_ptr(listener.up_z.render_param()),
+ node.position_x.render_param(),
+ node.position_y.render_param(),
+ node.position_z.render_param(),
+ node.orientation_x.render_param(),
+ node.orientation_y.render_param(),
+ node.orientation_z.render_param(),
+ listener.position_x.render_param(),
+ listener.position_y.render_param(),
+ listener.position_z.render_param(),
+ listener.forward_x.render_param(),
+ listener.forward_y.render_param(),
+ listener.forward_z.render_param(),
+ listener.up_x.render_param(),
+ listener.up_y.render_param(),
+ listener.up_z.render_param(),
];
- node.node.queue_render_node_creation(unsafe {
- Box::from_raw(web_audio_node_create_panner(
- node.node.node_id(),
- BaseAudioContext::RENDER_QUANTUM_SIZE as usize,
- ak::Span::new(&params),
- ))
- });
+ node.node.queue_render_node_creation(create_panner_render_node(
+ node.node.node_id(),
+ BaseAudioContext::RENDER_QUANTUM_SIZE as usize,
+ &params,
+ ));
node.queue_panner_parameters_update();
Ok(node)
}
diff --git a/Libraries/LibWeb/Bindings/Rust/src/web_audio/script_processor_node.rs b/Libraries/LibWeb/Bindings/Rust/src/web_audio/script_processor_node.rs
index 9b8339df7e9..d560b8dc46b 100644
--- a/Libraries/LibWeb/Bindings/Rust/src/web_audio/script_processor_node.rs
+++ b/Libraries/LibWeb/Bindings/Rust/src/web_audio/script_processor_node.rs
@@ -17,7 +17,7 @@ use libjs_rust::api::Vm;
use libweb_rust::web_audio::control_message::FfiSharedCppObject;
use libweb_rust::web_audio::rendering::node_message::SharedCppObject;
use libweb_rust::web_audio::rendering::script_processor_pipe::{ScriptProcessorPipe, ScriptProcessorPipeConfig};
-use libweb_rust::web_audio::rendering::script_processor_render_node::web_audio_node_create_script_processor;
+use libweb_rust::web_audio::rendering::script_processor_render_node::create_script_processor_render_node;
use super::audio_buffer::AudioBuffer;
use super::audio_node::{AnyAudioNode, AudioNode, ChannelCountMode};
@@ -156,13 +156,13 @@ impl ScriptProcessorNode {
});
*script_processor_node.pipe.borrow_mut() = Some(Arc::clone(&pipe));
context.add_script_processor_node(cx.vm(), script_processor_node);
- script_processor_node.node.queue_render_node_creation(unsafe {
- Box::from_raw(web_audio_node_create_script_processor(
+ script_processor_node
+ .node
+ .queue_render_node_creation(create_script_processor_render_node(
script_processor_node.node.node_id(),
BaseAudioContext::RENDER_QUANTUM_SIZE as usize,
- Arc::as_ptr(&pipe),
- ))
- });
+ Arc::clone(&pipe),
+ ));
Ok(script_processor_node)
}
diff --git a/Libraries/LibWeb/Bindings/Rust/src/web_audio/stereo_panner_node.rs b/Libraries/LibWeb/Bindings/Rust/src/web_audio/stereo_panner_node.rs
index 174695037a5..df92d927a6f 100644
--- a/Libraries/LibWeb/Bindings/Rust/src/web_audio/stereo_panner_node.rs
+++ b/Libraries/LibWeb/Bindings/Rust/src/web_audio/stereo_panner_node.rs
@@ -11,7 +11,7 @@ use std::sync::Arc;
use ak::Utf16String;
use libjs_rust::api::Trace;
-use libweb_rust::web_audio::rendering::render_nodes::web_audio_node_create_stereo_panner;
+use libweb_rust::web_audio::rendering::render_nodes::create_stereo_panner_render_node;
use super::audio_node::{
AnyAudioNode, AudioNode, AudioNodeDefaultOptions, AudioNodeOptions, ChannelCountMode, ChannelInterpretation,
@@ -105,13 +105,11 @@ impl StereoPannerNode {
// FIXME: Set tail-time to no
node.node
.initialize_audio_node_options(cx, &options.parent, &default_options)?;
- node.node.queue_render_node_creation(unsafe {
- Box::from_raw(web_audio_node_create_stereo_panner(
- node.node.node_id(),
- BaseAudioContext::RENDER_QUANTUM_SIZE as usize,
- Arc::as_ptr(node.pan.render_param()),
- ))
- });
+ node.node.queue_render_node_creation(create_stereo_panner_render_node(
+ node.node.node_id(),
+ BaseAudioContext::RENDER_QUANTUM_SIZE as usize,
+ Arc::clone(node.pan.render_param()),
+ ));
Ok(node)
}
diff --git a/Libraries/LibWeb/Bindings/Rust/src/web_audio/wave_shaper_node.rs b/Libraries/LibWeb/Bindings/Rust/src/web_audio/wave_shaper_node.rs
index 7029a245575..4559df4a3e7 100644
--- a/Libraries/LibWeb/Bindings/Rust/src/web_audio/wave_shaper_node.rs
+++ b/Libraries/LibWeb/Bindings/Rust/src/web_audio/wave_shaper_node.rs
@@ -16,7 +16,7 @@ use libjs_rust::api::{TypedArrayBase, TypedArrayKind, create_typed_array};
use libweb_rust::web_audio::control_message::ControlMessage;
use libweb_rust::web_audio::rendering::audio_data::WaveShaperCurve;
use libweb_rust::web_audio::rendering::node_message::{NodeMessage, SetWaveShaperParameters};
-use libweb_rust::web_audio::rendering::render_nodes::web_audio_node_create_wave_shaper;
+use libweb_rust::web_audio::rendering::render_nodes::create_wave_shaper_render_node;
use super::audio_array::{copy_float32_array, float32_array_length, overwrite_float32_array};
use super::audio_node::{
@@ -108,12 +108,10 @@ impl WaveShaperNode {
// FIXME: Set tail-time to yes when the oversample attribute is "2x" or "4x".
node.node
.initialize_audio_node_options(cx, &options.parent, &default_options)?;
- node.node.queue_render_node_creation(unsafe {
- Box::from_raw(web_audio_node_create_wave_shaper(
- node.node.node_id(),
- BaseAudioContext::RENDER_QUANTUM_SIZE as usize,
- ))
- });
+ node.node.queue_render_node_creation(create_wave_shaper_render_node(
+ node.node.node_id(),
+ BaseAudioContext::RENDER_QUANTUM_SIZE as usize,
+ ));
node.oversample.set(options.oversample);
// Also, let [[curve set]] be an internal slot of this WaveShaperNode. Initialize this slot to false. If options is
diff --git a/Libraries/LibWeb/CMakeLists.txt b/Libraries/LibWeb/CMakeLists.txt
index dba124b7191..ade6794afb1 100644
--- a/Libraries/LibWeb/CMakeLists.txt
+++ b/Libraries/LibWeb/CMakeLists.txt
@@ -930,30 +930,15 @@ set(SOURCES
WebAudio/AudioWorkletNode.cpp
WebAudio/AudioWorkletProcessor.cpp
WebAudio/AudioContext.cpp
- WebAudio/AudioParamTimeline.cpp
WebAudio/BaseAudioContext.cpp
- WebAudio/ControlMessageQueue.cpp
WebAudio/MediaElementAudioSourceNode.cpp
WebAudio/MediaStreamAudioDestinationNode.cpp
WebAudio/MediaStreamAudioSourceNode.cpp
WebAudio/OfflineAudioContext.cpp
- WebAudio/Rendering/AnalyserRenderNode.cpp
- WebAudio/Rendering/AudioData.cpp
- WebAudio/Rendering/AudioBus.cpp
WebAudio/Rendering/AudioWorkletPipe.cpp
- WebAudio/Rendering/AudioWorkletRenderNode.cpp
- WebAudio/Rendering/BiquadCoefficients.cpp
- WebAudio/Rendering/ConvolverKernel.cpp
- WebAudio/Rendering/FFT.cpp
- WebAudio/Rendering/MediaStreamDestinationRenderNode.cpp
- WebAudio/Rendering/MediaStreamSourceRenderNode.cpp
WebAudio/Rendering/OfflineAudioRenderer.cpp
WebAudio/Rendering/RealtimeAudioRenderer.cpp
- WebAudio/Rendering/RenderGraph.cpp
- WebAudio/Rendering/RenderNode.cpp
- WebAudio/Rendering/RenderNodes.cpp
WebAudio/Rendering/ScriptProcessorPipe.cpp
- WebAudio/Rendering/ScriptProcessorRenderNode.cpp
WebAudio/ScriptProcessorNode.cpp
WebDriver/Actions.cpp
WebDriver/BiDi/BiDi.cpp
diff --git a/Libraries/LibWeb/Rust/build.rs b/Libraries/LibWeb/Rust/build.rs
index 764a27217cf..8e269c6e793 100644
--- a/Libraries/LibWeb/Rust/build.rs
+++ b/Libraries/LibWeb/Rust/build.rs
@@ -2470,20 +2470,8 @@ fn main() -> Result<(), Box<dyn Error>> {
let mut web_audio_config = base_config.clone();
web_audio_config.namespaces = Some(vec!["Web".into(), "WebAudio".into(), "RustFFI".into()]);
for name in [
- "FFT",
- "AudioBus",
- "ConvolverKernel",
- "ConvolverDelayLine",
- "AudioParamTimeline",
- "RenderAudioParam",
- "RenderGraph",
"NodeHandle",
- "AudioBufferContents",
- "PeriodicWaveData",
- "WaveShaperCurve",
- "ControlMessage",
"ControlMessageQueue",
- "ControlMessages",
"AudioWorkletPipe",
"ScriptProcessorPipe",
"OfflineAudioRenderer",
@@ -2492,6 +2480,7 @@ fn main() -> Result<(), Box<dyn Error>> {
web_audio_config.export.rename.insert(name.into(), "void".into());
web_audio_config.export.exclude.push(name.into());
}
+ web_audio_config.export.include.push("AutomationRate".into());
web_audio_config.export.item_types = vec![
cbindgen::ItemType::Enums,
cbindgen::ItemType::Structs,
@@ -2502,21 +2491,8 @@ fn main() -> Result<(), Box<dyn Error>> {
generate_ffi_header(
web_audio_config,
&[
- manifest_dir.join("src/web_audio/audio_param_timeline.rs"),
- manifest_dir.join("src/web_audio/rendering/fft.rs"),
- manifest_dir.join("src/web_audio/rendering/biquad_coefficients.rs"),
- manifest_dir.join("src/web_audio/rendering/audio_bus.rs"),
- manifest_dir.join("src/web_audio/rendering/convolver_kernel.rs"),
manifest_dir.join("src/web_audio/rendering/render_node.rs"),
- manifest_dir.join("src/web_audio/rendering/render_graph.rs"),
- manifest_dir.join("src/web_audio/rendering/render_nodes.rs"),
- manifest_dir.join("src/web_audio/rendering/node_message.rs"),
- manifest_dir.join("src/web_audio/rendering/audio_data.rs"),
manifest_dir.join("src/web_audio/rendering/audio_frame_ring.rs"),
- manifest_dir.join("src/web_audio/rendering/analyser_render_node.rs"),
- manifest_dir.join("src/web_audio/rendering/audio_worklet_render_node.rs"),
- manifest_dir.join("src/web_audio/rendering/script_processor_render_node.rs"),
- manifest_dir.join("src/web_audio/rendering/media_stream_source_render_node.rs"),
manifest_dir.join("src/web_audio/rendering/media_stream_destination_render_node.rs"),
manifest_dir.join("src/web_audio/rendering/pipe_callbacks.rs"),
manifest_dir.join("src/web_audio/rendering/audio_worklet_pipe.rs"),
@@ -2525,7 +2501,6 @@ fn main() -> Result<(), Box<dyn Error>> {
manifest_dir.join("src/web_audio/rendering/offline_audio_renderer.rs"),
manifest_dir.join("src/web_audio/rendering/realtime_audio_renderer.rs"),
manifest_dir.join("src/web_audio/control_message.rs"),
- manifest_dir.join("src/web_audio/control_message_queue.rs"),
],
&out_dir,
Path::new("WebAudio/RustFFI.h"),
diff --git a/Libraries/LibWeb/Rust/src/web_audio/audio_param_timeline.rs b/Libraries/LibWeb/Rust/src/web_audio/audio_param_timeline.rs
index 39c55f8f8b3..7fa5da24a26 100644
--- a/Libraries/LibWeb/Rust/src/web_audio/audio_param_timeline.rs
+++ b/Libraries/LibWeb/Rust/src/web_audio/audio_param_timeline.rs
@@ -6,9 +6,9 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
-use std::sync::{Arc, Mutex};
+use std::sync::Mutex;
-use ak::{Span, SpanMut, math};
+use ak::math;
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[repr(u8)]
@@ -561,108 +561,3 @@ impl TimelineState {
InsertResult::Success
}
}
-
-#[unsafe(no_mangle)]
-pub(crate) extern "C" fn web_audio_param_timeline_create(default_value: f32) -> *const AudioParamTimeline {
- Arc::into_raw(Arc::new(AudioParamTimeline::new(default_value)))
-}
-
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_param_timeline_destroy(timeline: *const AudioParamTimeline) {
- drop(unsafe { Arc::from_raw(timeline) });
-}
-
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_param_timeline_set_value_at_time(
- timeline: *const AudioParamTimeline,
- value: f32,
- start_time: f64,
-) -> InsertResult {
- unsafe { &*timeline }.set_value_at_time(value, start_time)
-}
-
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_param_timeline_linear_ramp_to_value_at_time(
- timeline: *const AudioParamTimeline,
- value: f32,
- end_time: f64,
- current_time: f64,
- current_value: f32,
-) -> InsertResult {
- unsafe { &*timeline }.linear_ramp_to_value_at_time(value, end_time, current_time, current_value)
-}
-
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_param_timeline_exponential_ramp_to_value_at_time(
- timeline: *const AudioParamTimeline,
- value: f32,
- end_time: f64,
- current_time: f64,
- current_value: f32,
-) -> InsertResult {
- unsafe { &*timeline }.exponential_ramp_to_value_at_time(value, end_time, current_time, current_value)
-}
-
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_param_timeline_set_target_at_time(
- timeline: *const AudioParamTimeline,
- target: f32,
- start_time: f64,
- time_constant: f32,
-) -> InsertResult {
- unsafe { &*timeline }.set_target_at_time(target, start_time, time_constant)
-}
-
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_param_timeline_set_value_curve_at_time(
- timeline: *const AudioParamTimeline,
- values: Span<'_, f32>,
- start_time: f64,
- duration: f64,
-) -> InsertResult {
- unsafe { &*timeline }.set_value_curve_at_time(values.as_slice().to_vec(), start_time, duration)
-}
-
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_param_timeline_cancel_scheduled_values(
- timeline: *const AudioParamTimeline,
- cancel_time: f64,
-) {
- unsafe { &*timeline }.cancel_scheduled_values(cancel_time);
-}
-
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_param_timeline_cancel_and_hold_at_time(
- timeline: *const AudioParamTimeline,
- cancel_time: f64,
-) {
- unsafe { &*timeline }.cancel_and_hold_at_time(cancel_time);
-}
-
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_param_timeline_value_at_time(
- timeline: *const AudioParamTimeline,
- time: f64,
-) -> f32 {
- unsafe { &*timeline }.value_at_time(time)
-}
-
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_param_timeline_sample(
- timeline: *const AudioParamTimeline,
- start_time: f64,
- sample_period: f64,
- output: SpanMut<'_, f32>,
-) {
- unsafe { &*timeline }.sample(start_time, sample_period, output.into_slice());
-}
-
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_param_timeline_has_events(timeline: *const AudioParamTimeline) -> bool {
- unsafe { &*timeline }.has_events()
-}
-
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_param_timeline_default_value(timeline: *const AudioParamTimeline) -> f32 {
- unsafe { &*timeline }.default_value()
-}
diff --git a/Libraries/LibWeb/Rust/src/web_audio/control_message.rs b/Libraries/LibWeb/Rust/src/web_audio/control_message.rs
index 9877342f0f8..ef23e793c2e 100644
--- a/Libraries/LibWeb/Rust/src/web_audio/control_message.rs
+++ b/Libraries/LibWeb/Rust/src/web_audio/control_message.rs
@@ -6,7 +6,10 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
-use super::rendering::node_message::NodeMessage;
+use std::ffi::c_void;
+use std::sync::Arc;
+
+use super::rendering::node_message::{NodeMessage, SharedCppObject};
use super::rendering::render_node::{
ChannelCountMode, ChannelInterpretation, NodeHandle, OutgoingNodeConnection, OutgoingParamConnection,
};
@@ -47,20 +50,6 @@ pub enum ControlMessage {
NodeMessage(NodeMessage),
}
-use super::rendering::audio_data::{AudioBufferContents, PeriodicWaveData, WaveShaperCurve};
-use super::rendering::biquad_coefficients::BiquadFilterType;
-use super::rendering::convolver_kernel::{ConvolverDelayLine, ConvolverKernel};
-use super::rendering::node_message::*;
-use super::rendering::render_node::RenderAudioParam;
-use ak::Span;
-
-pub struct ControlMessages {
- pub messages: Vec<ControlMessage>,
-}
-
-use std::ffi::c_void;
-use std::sync::Arc;
-
pub(crate) unsafe fn clone_arc<T>(pointer: *const T) -> Arc<T> {
unsafe {
Arc::increment_strong_count(pointer);
@@ -68,20 +57,6 @@ pub(crate) unsafe fn clone_arc<T>(pointer: *const T) -> Arc<T> {
}
}
-unsafe fn clone_optional_arc<T>(pointer: *const T) -> Option<Arc<T>> {
- if pointer.is_null() {
- None
- } else {
- Some(unsafe { clone_arc(pointer) })
- }
-}
-
-#[repr(C)]
-pub struct FfiOutgoingParamConnection {
- pub destination: *const RenderAudioParam,
- pub output_index: usize,
-}
-
#[repr(C)]
#[derive(Clone, Copy)]
pub struct FfiSharedCppObject {
@@ -105,202 +80,3 @@ impl FfiSharedCppObject {
})
}
}
-
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_message_add_node(node: *mut NodeHandle) -> *mut ControlMessage {
- Box::into_raw(Box::new(ControlMessage::AddNode(AddNode {
- node: unsafe { Box::from_raw(node) },
- })))
-}
-
-#[unsafe(no_mangle)]
-pub(crate) extern "C" fn web_audio_message_remove_node(node_id: u64) -> *mut ControlMessage {
- Box::into_raw(Box::new(ControlMessage::RemoveNode(RemoveNode { node_id })))
-}
-
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_message_replace_connections(
- source: u64,
- node_connections: Span<'_, OutgoingNodeConnection>,
- param_connections: Span<'_, FfiOutgoingParamConnection>,
-) -> *mut ControlMessage {
- Box::into_raw(Box::new(ControlMessage::ReplaceConnections(ReplaceConnections {
- source,
- node_connections: node_connections.as_slice().to_vec(),
- param_connections: param_connections
- .as_slice()
- .iter()
- .map(|connection| OutgoingParamConnection {
- destination: unsafe { clone_arc(connection.destination) },
- output_index: connection.output_index,
- })
- .collect(),
- })))
-}
-
-#[unsafe(no_mangle)]
-pub(crate) extern "C" fn web_audio_message_set_channel_config(
- node_id: u64,
- channel_count: usize,
- channel_count_mode: ChannelCountMode,
- channel_interpretation: ChannelInterpretation,
-) -> *mut ControlMessage {
- Box::into_raw(Box::new(ControlMessage::SetChannelConfig(SetChannelConfig {
- node_id,
- channel_count,
- channel_count_mode,
- channel_interpretation,
- })))
-}
-
-#[unsafe(no_mangle)]
-pub(crate) extern "C" fn web_audio_message_start_source(node_id: u64, when: f64) -> *mut ControlMessage {
- Box::into_raw(Box::new(ControlMessage::NodeMessage(NodeMessage::StartSource(
- StartSource { node_id, when },
- ))))
-}
-
-#[unsafe(no_mangle)]
-pub(crate) extern "C" fn web_audio_message_stop_source(node_id: u64, when: f64) -> *mut ControlMessage {
- Box::into_raw(Box::new(ControlMessage::NodeMessage(NodeMessage::StopSource(
- StopSource { node_id, when },
- ))))
-}
-
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_message_start_buffer_source(
- node_id: u64,
- when: f64,
- offset: f64,
- has_duration: bool,
- duration: f64,
- buffer: *const AudioBufferContents,
-) -> *mut ControlMessage {
- Box::into_raw(Box::new(ControlMessage::NodeMessage(NodeMessage::StartBufferSource(
- StartBufferSource {
- node_id,
- when,
- offset,
- duration: has_duration.then_some(duration),
- buffer: unsafe { clone_optional_arc(buffer) },
- },
- ))))
-}
-
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_message_set_buffer_source_parameters(
- node_id: u64,
- r#loop: bool,
- loop_start: f64,
- loop_end: f64,
- buffer: *const AudioBufferContents,
- update_buffer: bool,
-) -> *mut ControlMessage {
- Box::into_raw(Box::new(ControlMessage::NodeMessage(
- NodeMessage::SetBufferSourceParameters(SetBufferSourceParameters {
- node_id,
- r#loop,
- loop_start,
- loop_end,
- buffer: unsafe { clone_optional_arc(buffer) },
- update_buffer,
- }),
- )))
-}
-
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_message_set_oscillator_waveform(
- node_id: u64,
- r#type: OscillatorType,
- periodic_wave: *const PeriodicWaveData,
-) -> *mut ControlMessage {
- Box::into_raw(Box::new(ControlMessage::NodeMessage(
- NodeMessage::SetOscillatorWaveform(SetOscillatorWaveform {
- node_id,
- r#type,
- periodic_wave: unsafe { clone_optional_arc(periodic_wave) },
- }),
- )))
-}
-
-#[unsafe(no_mangle)]
-pub(crate) extern "C" fn web_audio_message_set_biquad_filter_type(
- node_id: u64,
- r#type: BiquadFilterType,
-) -> *mut ControlMessage {
- Box::into_raw(Box::new(ControlMessage::NodeMessage(NodeMessage::SetBiquadFilterType(
- SetBiquadFilterType { node_id, r#type },
- ))))
-}
-
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_message_set_convolver_kernel(
- node_id: u64,
- kernel: *const ConvolverKernel,
- delay_line: *const ConvolverDelayLine,
-) -> *mut ControlMessage {
- Box::into_raw(Box::new(ControlMessage::NodeMessage(NodeMessage::SetConvolverKernel(
- SetConvolverKernel {
- node_id,
- kernel: unsafe { clone_optional_arc(kernel) },
- delay_line: unsafe { clone_optional_arc(delay_line) },
- },
- ))))
-}
-
-#[unsafe(no_mangle)]
-pub(crate) extern "C" fn web_audio_message_set_panner_parameters(
- node_id: u64,
- panning_model: PanningModelType,
- distance_model: DistanceModelType,
- ref_distance: f64,
- max_distance: f64,
- rolloff_factor: f64,
- cone_inner_angle: f64,
- cone_outer_angle: f64,
- cone_outer_gain: f64,
-) -> *mut ControlMessage {
- Box::into_raw(Box::new(ControlMessage::NodeMessage(NodeMessage::SetPannerParameters(
- SetPannerParameters {
- node_id,
- panning_model,
- distance_model,
- ref_distance,
- max_distance,
- rolloff_factor,
- cone_inner_angle,
- cone_outer_angle,
- cone_outer_gain,
- },
- ))))
-}
-
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_message_set_wave_shaper_parameters(
- node_id: u64,
- curve: *const WaveShaperCurve,
- oversample: OverSampleType,
-) -> *mut ControlMessage {
- Box::into_raw(Box::new(ControlMessage::NodeMessage(
- NodeMessage::SetWaveShaperParameters(SetWaveShaperParameters {
- node_id,
- curve: unsafe { clone_optional_arc(curve) },
- oversample,
- }),
- )))
-}
-
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_message_set_media_stream_source_ring(
- node_id: u64,
- ring: FfiSharedCppObject,
- channel_count: u32,
-) -> *mut ControlMessage {
- Box::into_raw(Box::new(ControlMessage::NodeMessage(
- NodeMessage::SetMediaStreamSourceRing(SetMediaStreamSourceRing {
- node_id,
- ring: unsafe { ring.acquire() },
- channel_count,
- }),
- )))
-}
diff --git a/Libraries/LibWeb/Rust/src/web_audio/control_message_queue.rs b/Libraries/LibWeb/Rust/src/web_audio/control_message_queue.rs
index 7cb141ab2ee..606de91d413 100644
--- a/Libraries/LibWeb/Rust/src/web_audio/control_message_queue.rs
+++ b/Libraries/LibWeb/Rust/src/web_audio/control_message_queue.rs
@@ -5,9 +5,9 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
-use std::sync::{Arc, Mutex};
+use std::sync::Mutex;
-use super::control_message::{ControlMessage, ControlMessages};
+use super::control_message::ControlMessage;
// https://webaudio.github.io/web-audio-api/#control-message-queue
#[derive(Default)]
@@ -28,30 +28,3 @@ impl ControlMessageQueue {
std::mem::take(&mut *messages)
}
}
-
-#[unsafe(no_mangle)]
-pub(crate) extern "C" fn web_audio_control_queue_create() -> *const ControlMessageQueue {
- Arc::into_raw(Arc::new(ControlMessageQueue::default()))
-}
-
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_control_queue_destroy(queue: *const ControlMessageQueue) {
- drop(unsafe { Arc::from_raw(queue) });
-}
-
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_control_queue_enqueue(
- queue: *const ControlMessageQueue,
- message: *mut ControlMessage,
-) {
- unsafe { &*queue }.enqueue(*unsafe { Box::from_raw(message) });
-}
-
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_control_queue_drain(
- queue: *const ControlMessageQueue,
-) -> *mut ControlMessages {
- Box::into_raw(Box::new(ControlMessages {
- messages: unsafe { &*queue }.drain(),
- }))
-}
diff --git a/Libraries/LibWeb/Rust/src/web_audio/rendering/analyser_render_node.rs b/Libraries/LibWeb/Rust/src/web_audio/rendering/analyser_render_node.rs
index e5e8af0539b..7a5a8a735e6 100644
--- a/Libraries/LibWeb/Rust/src/web_audio/rendering/analyser_render_node.rs
+++ b/Libraries/LibWeb/Rust/src/web_audio/rendering/analyser_render_node.rs
@@ -61,13 +61,12 @@ impl NodeProcessor for AnalyserRenderNode {
/// # Safety
/// The ring handle and callbacks must refer to the same live LibAudio ring.
-#[unsafe(no_mangle)]
-pub unsafe extern "C" fn web_audio_node_create_analyser(
+pub unsafe fn create_analyser_render_node(
node_id: u64,
quantum_size: usize,
ring: FfiSharedCppObject,
callbacks: AudioFrameRingCallbacks,
-) -> *mut NodeHandle {
+) -> Box<NodeHandle> {
let time_domain_ring = AudioFrameRing {
owner: unsafe { ring.acquire() }.unwrap(),
callbacks,
diff --git a/Libraries/LibWeb/Rust/src/web_audio/rendering/audio_bus.rs b/Libraries/LibWeb/Rust/src/web_audio/rendering/audio_bus.rs
index 98f23ed5865..c9db211eb6d 100644
--- a/Libraries/LibWeb/Rust/src/web_audio/rendering/audio_bus.rs
+++ b/Libraries/LibWeb/Rust/src/web_audio/rendering/audio_bus.rs
@@ -5,8 +5,8 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
-use ak::{Span, SpanMut};
-
+// https://webaudio.github.io/web-audio-api/#ChannelLayouts
+// Speakers channel layouts exist for mono, stereo, quad and 5.1; all other channel counts use discrete mixing.
const LEFT: usize = 0;
const RIGHT: usize = 1;
const CENTER: usize = 2;
@@ -224,90 +224,3 @@ impl AudioBus {
}
}
}
-
-#[unsafe(no_mangle)]
-pub(crate) extern "C" fn web_audio_bus_create(channel_count: usize, frame_count: usize) -> *mut AudioBus {
- Box::into_raw(Box::new(AudioBus::new(channel_count, frame_count)))
-}
-
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_bus_destroy(bus: *mut AudioBus) {
- if !bus.is_null() {
- drop(unsafe { Box::from_raw(bus) });
- }
-}
-
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_bus_clone(bus: *const AudioBus) -> *mut AudioBus {
- let source = unsafe { &*bus };
- let mut copy = AudioBus::new(0, source.frame_count());
- copy.copy_from(source);
- Box::into_raw(Box::new(copy))
-}
-
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_bus_channel_count(bus: *const AudioBus) -> usize {
- unsafe { &*bus }.channel_count()
-}
-
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_bus_frame_count(bus: *const AudioBus) -> usize {
- unsafe { &*bus }.frame_count()
-}
-
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_bus_channel(
- bus: *const AudioBus,
- index: usize,
- output: *mut Span<'static, f32>,
-) {
- unsafe {
- *output = Span::new((&*bus).channel(index));
- }
-}
-
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_bus_channel_mut(
- bus: *mut AudioBus,
- index: usize,
- output: *mut SpanMut<'static, f32>,
-) {
- unsafe {
- *output = SpanMut::new((&mut *bus).channel_mut(index));
- }
-}
-
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_bus_zero(bus: *mut AudioBus) {
- unsafe { &mut *bus }.zero();
-}
-
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_bus_is_silent(bus: *const AudioBus) -> bool {
- unsafe { &*bus }.is_silent()
-}
-
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_bus_set_channel_count(bus: *mut AudioBus, channel_count: usize) {
- unsafe { &mut *bus }.set_channel_count(channel_count);
-}
-
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_bus_copy_from(bus: *mut AudioBus, source: *const AudioBus) {
- if !std::ptr::eq(bus, source) {
- unsafe { &mut *bus }.copy_from(unsafe { &*source });
- }
-}
-
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_bus_sum_from(bus: *mut AudioBus, source: *const AudioBus, speakers: bool) {
- if std::ptr::eq(bus, source) {
- for channel in &mut unsafe { &mut *bus }.channels {
- for sample in channel {
- *sample += *sample;
- }
- }
- } else {
- unsafe { &mut *bus }.sum_from(unsafe { &*source }, speakers);
- }
-}
diff --git a/Libraries/LibWeb/Rust/src/web_audio/rendering/audio_data.rs b/Libraries/LibWeb/Rust/src/web_audio/rendering/audio_data.rs
index 9fc837c1c52..b6de0bc0064 100644
--- a/Libraries/LibWeb/Rust/src/web_audio/rendering/audio_data.rs
+++ b/Libraries/LibWeb/Rust/src/web_audio/rendering/audio_data.rs
@@ -5,10 +5,9 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
-use std::sync::Arc;
-
-use ak::Span;
-
+// An immutable snapshot of an AudioBuffer's sample data, created on the control thread when the buffer's content is
+// acquired and shared with the rendering thread.
+// https://webaudio.github.io/web-audio-api/#acquire-the-content
pub struct AudioBufferContents {
pub channels: Vec<Vec<f32>>,
pub sample_rate: f32,
@@ -37,94 +36,3 @@ pub struct PeriodicWaveData {
pub struct WaveShaperCurve {
pub values: Vec<f32>,
}
-
-#[unsafe(no_mangle)]
-pub(crate) extern "C" fn web_audio_buffer_contents_create(
- channels: Span<'_, Span<'_, f32>>,
- sample_rate: f32,
-) -> *const AudioBufferContents {
- Arc::into_raw(Arc::new(AudioBufferContents {
- channels: channels
- .as_slice()
- .iter()
- .map(|channel| channel.as_slice().to_vec())
- .collect(),
- sample_rate,
- }))
-}
-
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_buffer_contents_destroy(contents: *const AudioBufferContents) {
- drop(unsafe { Arc::from_raw(contents) });
-}
-
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_buffer_contents_channel(
- contents: *const AudioBufferContents,
- channel: usize,
- output: *mut Span<'static, f32>,
-) {
- unsafe {
- *output = Span::new(&(&*contents).channels[channel]);
- }
-}
-
-#[unsafe(no_mangle)]
-pub(crate) extern "C" fn web_audio_periodic_wave_data_create(
- real: Span<'_, f32>,
- imag: Span<'_, f32>,
- normalize: bool,
-) -> *const PeriodicWaveData {
- Arc::into_raw(Arc::new(PeriodicWaveData {
- real: real.as_slice().to_vec(),
- imag: imag.as_slice().to_vec(),
- normalize,
- }))
-}
-
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_periodic_wave_data_destroy(data: *const PeriodicWaveData) {
- drop(unsafe { Arc::from_raw(data) });
-}
-
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_periodic_wave_data_real(
- data: *const PeriodicWaveData,
- output: *mut Span<'static, f32>,
-) {
- unsafe {
- *output = Span::new(&(&*data).real);
- }
-}
-
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_periodic_wave_data_imag(
- data: *const PeriodicWaveData,
- output: *mut Span<'static, f32>,
-) {
- unsafe {
- *output = Span::new(&(&*data).imag);
- }
-}
-
-#[unsafe(no_mangle)]
-pub(crate) extern "C" fn web_audio_wave_shaper_curve_create(values: Span<'_, f32>) -> *const WaveShaperCurve {
- Arc::into_raw(Arc::new(WaveShaperCurve {
- values: values.as_slice().to_vec(),
- }))
-}
-
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_wave_shaper_curve_destroy(curve: *const WaveShaperCurve) {
- drop(unsafe { Arc::from_raw(curve) });
-}
-
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_wave_shaper_curve_values(
- curve: *const WaveShaperCurve,
- output: *mut Span<'static, f32>,
-) {
- unsafe {
- *output = Span::new(&(&*curve).values);
- }
-}
diff --git a/Libraries/LibWeb/Rust/src/web_audio/rendering/audio_worklet_render_node.rs b/Libraries/LibWeb/Rust/src/web_audio/rendering/audio_worklet_render_node.rs
index 0d3cb6439c6..38fbcc26e14 100644
--- a/Libraries/LibWeb/Rust/src/web_audio/rendering/audio_worklet_render_node.rs
+++ b/Libraries/LibWeb/Rust/src/web_audio/rendering/audio_worklet_render_node.rs
@@ -11,7 +11,6 @@ use super::audio_worklet_pipe::{AudioWorkletPipe, WorkletPipeState};
use super::render_graph::RenderGraph;
use super::render_node::*;
use super::render_nodes::{BusRef, NodeProcessor, node_handle};
-use crate::web_audio::control_message::clone_arc;
// Script runs on the main-thread pump, `prime_level` quanta behind this render node; this side
// only exchanges preallocated pipe slots and renders silence on underrun.
@@ -105,21 +104,19 @@ impl NodeProcessor for AudioWorkletRenderNode {
}
}
-/// # Safety
-/// The pipe and parameter pointers must name live `Arc` allocations for the call.
-#[unsafe(no_mangle)]
-pub unsafe extern "C" fn web_audio_node_create_audio_worklet(
+#[allow(clippy::too_many_arguments, reason = "mirror the C++ render node constructor")]
+pub fn create_audio_worklet_render_node(
node_id: u64,
input_count: usize,
output_count: usize,
quantum_size: usize,
- output_channel_capacities: ak::Span<'_, u32>,
+ output_channel_capacities: &[u32],
channel_count: usize,
channel_count_mode: ChannelCountMode,
channel_interpretation: ChannelInterpretation,
- pipe: *const AudioWorkletPipe,
- params: ak::Span<'_, *const RenderAudioParam>,
-) -> *mut NodeHandle {
+ pipe: Arc<AudioWorkletPipe>,
+ params: Vec<Arc<RenderAudioParam>>,
+) -> Box<NodeHandle> {
let data = RenderNodeData::new(node_id, input_count, output_count, quantum_size, 1);
// Channel configuration must be set here: the SetChannelConfig messages queued during node
@@ -130,14 +127,10 @@ pub unsafe extern "C" fn web_audio_node_create_audio_worklet(
node_handle(
data,
AudioWorkletRenderNode {
- pipe: unsafe { clone_arc(pipe) },
- params: params
- .as_slice()
- .iter()
- .map(|param| unsafe { clone_arc(*param) })
- .collect(),
+ pipe,
+ params,
param_scratch: vec![0.; quantum_size],
- output_channel_capacities: output_channel_capacities.as_slice().to_vec(),
+ output_channel_capacities: output_channel_capacities.to_vec(),
},
)
}
diff --git a/Libraries/LibWeb/Rust/src/web_audio/rendering/biquad_coefficients.rs b/Libraries/LibWeb/Rust/src/web_audio/rendering/biquad_coefficients.rs
index e361f4cbb90..6179d19936a 100644
--- a/Libraries/LibWeb/Rust/src/web_audio/rendering/biquad_coefficients.rs
+++ b/Libraries/LibWeb/Rust/src/web_audio/rendering/biquad_coefficients.rs
@@ -167,27 +167,3 @@ pub fn biquad_frequency_response(coefficients: &BiquadCoefficients, normalized_f
let phase = math::atan2(response_imaginary, response_real) as f32;
(magnitude, phase)
}
-
-#[unsafe(no_mangle)]
-pub(crate) extern "C" fn web_audio_compute_biquad_coefficients(
- filter_type: BiquadFilterType,
- normalized_frequency: f64,
- q: f64,
- gain_db: f64,
-) -> BiquadCoefficients {
- compute_biquad_coefficients(filter_type, normalized_frequency, q, gain_db)
-}
-
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_biquad_frequency_response(
- coefficients: *const BiquadCoefficients,
- normalized_frequency: f64,
- magnitude: *mut f32,
- phase: *mut f32,
-) {
- let response = biquad_frequency_response(unsafe { &*coefficients }, normalized_frequency);
- unsafe {
- *magnitude = response.0;
- *phase = response.1;
- }
-}
diff --git a/Libraries/LibWeb/Rust/src/web_audio/rendering/convolver_kernel.rs b/Libraries/LibWeb/Rust/src/web_audio/rendering/convolver_kernel.rs
index 6a96ddd42c2..9e5659d7c92 100644
--- a/Libraries/LibWeb/Rust/src/web_audio/rendering/convolver_kernel.rs
+++ b/Libraries/LibWeb/Rust/src/web_audio/rendering/convolver_kernel.rs
@@ -10,7 +10,7 @@
use std::cell::UnsafeCell;
use std::sync::Arc;
-use ak::{Span, SpanMut};
+use ak::Span;
use super::fft::{FFT, FFTDirection};
@@ -227,111 +227,3 @@ impl ConvolverDelayLine {
self.imag[channel].get_mut()
}
}
-
-#[unsafe(no_mangle)]
-pub(crate) extern "C" fn web_audio_convolver_kernel_create(
- channels: Span<'_, Span<'_, f32>>,
- sample_rate: f32,
- partition_size: usize,
- normalize: bool,
-) -> *const ConvolverKernel {
- let contents = AudioBufferContents {
- channels: channels.as_slice(),
- sample_rate,
- };
- ConvolverKernel::create(&contents, partition_size, normalize).map_or(std::ptr::null(), Arc::into_raw)
-}
-
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_convolver_kernel_destroy(kernel: *const ConvolverKernel) {
- drop(unsafe { Arc::from_raw(kernel) });
-}
-
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_convolver_kernel_channel_count(kernel: *const ConvolverKernel) -> usize {
- unsafe { &*kernel }.channel_count()
-}
-
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_convolver_kernel_partition_count(kernel: *const ConvolverKernel) -> usize {
- unsafe { &*kernel }.partition_count()
-}
-
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_convolver_kernel_bin_count(kernel: *const ConvolverKernel) -> usize {
- unsafe { &*kernel }.bin_count()
-}
-
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_convolver_kernel_head(
- kernel: *const ConvolverKernel,
- channel: usize,
- output: *mut Span<'static, f32>,
-) {
- unsafe {
- *output = Span::new((&*kernel).head(channel));
- }
-}
-
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_convolver_kernel_partition_real(
- kernel: *const ConvolverKernel,
- channel: usize,
- partition: usize,
- output: *mut Span<'static, f32>,
-) {
- unsafe {
- *output = Span::new((&*kernel).partition_real(channel, partition));
- }
-}
-
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_convolver_kernel_partition_imag(
- kernel: *const ConvolverKernel,
- channel: usize,
- partition: usize,
- output: *mut Span<'static, f32>,
-) {
- unsafe {
- *output = Span::new((&*kernel).partition_imag(channel, partition));
- }
-}
-
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_convolver_delay_line_create(
- kernel: *const ConvolverKernel,
-) -> *const ConvolverDelayLine {
- Arc::into_raw(Arc::new(ConvolverDelayLine::create(unsafe { &*kernel })))
-}
-
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_convolver_delay_line_destroy(delay_line: *const ConvolverDelayLine) {
- drop(unsafe { Arc::from_raw(delay_line) });
-}
-
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_convolver_delay_line_length(delay_line: *const ConvolverDelayLine) -> usize {
- unsafe { &*delay_line }.length()
-}
-
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_convolver_delay_line_real(
- delay_line: *const ConvolverDelayLine,
- channel: usize,
- output: *mut SpanMut<'static, f32>,
-) {
- unsafe {
- *output = SpanMut::new((&*delay_line).real_shared(channel));
- }
-}
-
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_convolver_delay_line_imag(
- delay_line: *const ConvolverDelayLine,
- channel: usize,
- output: *mut SpanMut<'static, f32>,
-) {
- unsafe {
- *output = SpanMut::new((&*delay_line).imag_shared(channel));
- }
-}
diff --git a/Libraries/LibWeb/Rust/src/web_audio/rendering/fft.rs b/Libraries/LibWeb/Rust/src/web_audio/rendering/fft.rs
index 1b446df8724..6572d49d1f2 100644
--- a/Libraries/LibWeb/Rust/src/web_audio/rendering/fft.rs
+++ b/Libraries/LibWeb/Rust/src/web_audio/rendering/fft.rs
@@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
-use ak::{SpanMut, math};
+use ak::math;
#[derive(Clone, Copy, PartialEq, Eq)]
#[repr(u8)]
@@ -92,23 +92,3 @@ impl FFT {
}
}
}
-
-#[unsafe(no_mangle)]
-pub(crate) extern "C" fn web_audio_fft_create(size: usize) -> *mut FFT {
- Box::into_raw(Box::new(FFT::new(size)))
-}
-
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_fft_destroy(fft: *mut FFT) {
- drop(unsafe { Box::from_raw(fft) });
-}
-
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_fft_transform(
- fft: *const FFT,
- re: SpanMut<'_, f32>,
- im: SpanMut<'_, f32>,
- direction: FFTDirection,
-) {
- unsafe { &*fft }.transform(re.into_slice(), im.into_slice(), direction);
-}
diff --git a/Libraries/LibWeb/Rust/src/web_audio/rendering/media_stream_destination_render_node.rs b/Libraries/LibWeb/Rust/src/web_audio/rendering/media_stream_destination_render_node.rs
index 7700eed1085..9bcac11e708 100644
--- a/Libraries/LibWeb/Rust/src/web_audio/rendering/media_stream_destination_render_node.rs
+++ b/Libraries/LibWeb/Rust/src/web_audio/rendering/media_stream_destination_render_node.rs
@@ -100,7 +100,7 @@ pub(crate) unsafe extern "C" fn web_audio_node_create_media_stream_destination(
data.channel_count.set(channel_count);
data.channel_count_mode.set(ChannelCountMode::Explicit);
data.channel_interpretation.set(ChannelInterpretation::Speakers);
- node_handle(
+ Box::into_raw(node_handle(
data,
MediaStreamDestinationRenderNode {
shared_state: Arc::new(SharedState {
@@ -114,5 +114,5 @@ pub(crate) unsafe extern "C" fn web_audio_node_create_media_stream_destination(
mix_bus: AudioBus::new(channel_count, quantum_size),
interleaved_scratch: vec![0.; quantum_size * channel_count],
},
- )
+ ))
}
diff --git a/Libraries/LibWeb/Rust/src/web_audio/rendering/media_stream_source_render_node.rs b/Libraries/LibWeb/Rust/src/web_audio/rendering/media_stream_source_render_node.rs
index 057d0653c73..da84edf4e0f 100644
--- a/Libraries/LibWeb/Rust/src/web_audio/rendering/media_stream_source_render_node.rs
+++ b/Libraries/LibWeb/Rust/src/web_audio/rendering/media_stream_source_render_node.rs
@@ -74,12 +74,11 @@ impl NodeProcessor for MediaStreamSourceRenderNode {
/// # Safety
/// The callbacks must accept the ring handles supplied in later node messages.
-#[unsafe(no_mangle)]
-pub unsafe extern "C" fn web_audio_node_create_media_stream_source(
+pub unsafe fn create_media_stream_source_render_node(
node_id: u64,
quantum_size: usize,
callbacks: AudioFrameRingCallbacks,
-) -> *mut NodeHandle {
+) -> Box<NodeHandle> {
let data = RenderNodeData::new(node_id, 0, 1, quantum_size, 2);
// NB: The control thread queues SetChannelConfig before AddNode and messages addressed to
diff --git a/Libraries/LibWeb/Rust/src/web_audio/rendering/offline_audio_renderer.rs b/Libraries/LibWeb/Rust/src/web_audio/rendering/offline_audio_renderer.rs
index 2491a4a56ff..a71fb133494 100644
--- a/Libraries/LibWeb/Rust/src/web_audio/rendering/offline_audio_renderer.rs
+++ b/Libraries/LibWeb/Rust/src/web_audio/rendering/offline_audio_renderer.rs
@@ -264,11 +264,6 @@ pub(crate) unsafe extern "C" fn web_audio_offline_renderer_request_suspend(
unsafe { &*renderer }.request_suspend(frame)
}
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_offline_renderer_started(renderer: *const OfflineAudioRenderer) -> bool {
- unsafe { &*(*renderer).thread.get() }.is_some()
-}
-
#[unsafe(no_mangle)]
pub(crate) unsafe extern "C" fn web_audio_offline_renderer_frames_rendered(
renderer: *const OfflineAudioRenderer,
diff --git a/Libraries/LibWeb/Rust/src/web_audio/rendering/render_graph.rs b/Libraries/LibWeb/Rust/src/web_audio/rendering/render_graph.rs
index 3cda4712a8c..9c28dd8a758 100644
--- a/Libraries/LibWeb/Rust/src/web_audio/rendering/render_graph.rs
+++ b/Libraries/LibWeb/Rust/src/web_audio/rendering/render_graph.rs
@@ -12,7 +12,7 @@ use std::cell::Cell;
use super::audio_bus::AudioBus;
use super::node_message::node_message_target;
use super::render_node::{NodeHandle, RenderContext};
-use crate::web_audio::control_message::{ControlMessage, ControlMessages};
+use crate::web_audio::control_message::ControlMessage;
// The rendering thread's mirror of the audio graph. Nodes and connections are added and updated exclusively through
// control messages, which are applied at the start of each render quantum.
@@ -306,66 +306,6 @@ impl NodeMap {
}
}
-#[unsafe(no_mangle)]
-pub(crate) extern "C" fn web_audio_graph_create() -> *mut RenderGraph {
- Box::into_raw(Box::new(RenderGraph::default()))
-}
-
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_graph_destroy(graph: *mut RenderGraph) {
- drop(unsafe { Box::from_raw(graph) });
-}
-
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_graph_set_destination(graph: *mut RenderGraph, node_id: u64) {
- unsafe { &mut *graph }.set_destination(node_id);
-}
-
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_graph_apply_control_messages(
- graph: *mut RenderGraph,
- messages: *mut ControlMessages,
-) {
- unsafe { &mut *graph }.apply_control_messages(unsafe { Box::from_raw(messages) }.messages);
-}
-
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_graph_render_quantum(
- graph: *const RenderGraph,
- context: *const RenderContext,
-) {
- unsafe { &*graph }.render_quantum(unsafe { &*context });
-}
-
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_graph_pull_output(
- graph: *const RenderGraph,
- source: u64,
- output_index: usize,
- context: *const RenderContext,
-) -> *mut AudioBus {
- unsafe { &*graph }.pull_output(source, output_index, unsafe { &*context })
-}
-
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_graph_destination_output(graph: *const RenderGraph) -> *mut AudioBus {
- unsafe { &*graph }
- .destination()
- .map_or(std::ptr::null_mut(), |node| unsafe { node.data().output(0) })
-}
-
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_graph_take_ended_nodes(
- graph: *mut RenderGraph,
- context: *mut std::ffi::c_void,
- callback: unsafe extern "C" fn(*mut std::ffi::c_void, ak::Span<'_, u64>),
-) {
- let ended_nodes = unsafe { &mut *graph }.take_ended_nodes();
- unsafe {
- callback(context, ak::Span::new(&ended_nodes));
- }
-}
-
#[cfg(test)]
mod tests {
use super::*;
@@ -377,7 +317,7 @@ mod tests {
AutomationRate, ChannelCountMode, ChannelInterpretation, OutgoingNodeConnection, RenderAudioParam,
};
use crate::web_audio::rendering::render_nodes::{
- web_audio_node_create_constant_source, web_audio_node_create_destination,
+ create_constant_source_render_node, create_destination_render_node,
};
use std::sync::Arc;
@@ -393,7 +333,7 @@ mod tests {
channel_interpretation: ChannelInterpretation::Discrete,
}));
for id in [1, 3] {
- let node = unsafe { Box::from_raw(web_audio_node_create_constant_source(id, 4, Arc::as_ptr(&param))) };
+ let node = create_constant_source_render_node(id, 4, Arc::clone(&param));
queue.enqueue(ControlMessage::AddNode(AddNode { node }));
queue.enqueue(ControlMessage::NodeMessage(NodeMessage::StartSource(StartSource {
node_id: id,
@@ -404,7 +344,7 @@ mod tests {
when: 3. / 48000.,
})));
}
- let destination = unsafe { Box::from_raw(web_audio_node_create_destination(2, 4, 2)) };
+ let destination = create_destination_render_node(2, 4, 2);
queue.enqueue(ControlMessage::AddNode(AddNode { node: destination }));
queue.enqueue(ControlMessage::ReplaceConnections(ReplaceConnections {
source: 1,
diff --git a/Libraries/LibWeb/Rust/src/web_audio/rendering/render_node.rs b/Libraries/LibWeb/Rust/src/web_audio/rendering/render_node.rs
index af5f6fe3d19..650b5708f4e 100644
--- a/Libraries/LibWeb/Rust/src/web_audio/rendering/render_node.rs
+++ b/Libraries/LibWeb/Rust/src/web_audio/rendering/render_node.rs
@@ -6,12 +6,9 @@
*/
use std::cell::UnsafeCell;
-use std::ffi::c_void;
use std::sync::Arc;
use std::sync::atomic::{AtomicU8, Ordering};
-use ak::SpanMut;
-
use super::audio_bus::AudioBus;
use crate::web_audio::audio_param_timeline::AudioParamTimeline;
@@ -70,13 +67,6 @@ pub struct RenderAudioParam {
unsafe impl Send for RenderAudioParam {}
unsafe impl Sync for RenderAudioParam {}
-pub type PullOutput = unsafe extern "C" fn(*mut c_void, u64, usize, *const RenderContext) -> *const AudioBus;
-
-struct ForeignRenderGraph {
- graph: *mut c_void,
- pull_output: PullOutput,
-}
-
impl RenderAudioParam {
pub fn new(
timeline: Arc<AudioParamTimeline>,
@@ -100,7 +90,7 @@ impl RenderAudioParam {
self.automation_rate.store(automation_rate as u8, Ordering::SeqCst);
}
- fn automation_rate(&self) -> AutomationRate {
+ pub(super) fn automation_rate(&self) -> AutomationRate {
if self.automation_rate.load(Ordering::SeqCst) == AutomationRate::ARate as u8 {
AutomationRate::ARate
} else {
@@ -189,75 +179,6 @@ impl RenderAudioParam {
}
}
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_render_param_create(
- timeline: *const AudioParamTimeline,
- min_value: f32,
- max_value: f32,
- automation_rate: AutomationRate,
-) -> *const RenderAudioParam {
- unsafe {
- Arc::increment_strong_count(timeline);
- }
- let timeline = unsafe { Arc::from_raw(timeline) };
- Arc::into_raw(Arc::new(RenderAudioParam::new(
- timeline,
- min_value,
- max_value,
- automation_rate,
- )))
-}
-
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_render_param_destroy(param: *const RenderAudioParam) {
- drop(unsafe { Arc::from_raw(param) });
-}
-
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_render_param_set_automation_rate(
- param: *const RenderAudioParam,
- rate: AutomationRate,
-) {
- unsafe { &*param }.set_automation_rate(rate);
-}
-
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_render_param_automation_rate(
- param: *const RenderAudioParam,
-) -> AutomationRate {
- unsafe { &*param }.automation_rate()
-}
-
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_render_param_clear_inputs(param: *const RenderAudioParam) {
- unsafe { &mut *(*param).state.get() }.inputs.clear();
-}
-
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_render_param_add_input(
- param: *const RenderAudioParam,
- source: u64,
- output_index: usize,
-) {
- unsafe { &mut *(*param).state.get() }
- .inputs
- .push(Input { source, output_index });
-}
-
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_render_param_compute(
- param: *const RenderAudioParam,
- graph: *mut c_void,
- pull_output: PullOutput,
- context: *const RenderContext,
- output: SpanMut<'_, f32>,
-) {
- let graph = ForeignRenderGraph { graph, pull_output };
- unsafe {
- (&*param).compute(&graph, &*context, output.into_slice());
- }
-}
-
#[derive(Clone, Copy, PartialEq, Eq)]
#[repr(u8)]
pub enum ChannelCountMode {
@@ -459,16 +380,10 @@ impl NodeHandle {
}
}
-pub trait OutputGraph {
+pub(crate) trait OutputGraph {
fn pull_output(&self, source: u64, output_index: usize, context: &RenderContext) -> *const AudioBus;
}
-impl OutputGraph for ForeignRenderGraph {
- fn pull_output(&self, source: u64, output_index: usize, context: &RenderContext) -> *const AudioBus {
- unsafe { (self.pull_output)(self.graph, source, output_index, context) }
- }
-}
-
impl OutputGraph for super::render_graph::RenderGraph {
fn pull_output(&self, source: u64, output_index: usize, context: &RenderContext) -> *const AudioBus {
self.pull_output(source, output_index, context)
@@ -484,91 +399,3 @@ impl RenderAudioParam {
unsafe { &mut (*self.state.get()).inputs }.push(Input { source, output_index });
}
}
-
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_node_destroy(node: *mut NodeHandle) {
- drop(unsafe { Box::from_raw(node) });
-}
-
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_node_id(node: *const NodeHandle) -> u64 {
- unsafe { &*node }.data().node_id
-}
-
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_node_input_count(node: *const NodeHandle) -> usize {
- unsafe { &*node }.data().input_count()
-}
-
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_node_output_count(node: *const NodeHandle) -> usize {
- unsafe { &*node }.data().output_count()
-}
-
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_node_output(node: *const NodeHandle, index: usize) -> *mut AudioBus {
- unsafe { (&*node).data().output(index) }
-}
-
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_node_pull_input(
- node: *const NodeHandle,
- graph: *const super::render_graph::RenderGraph,
- context: *const RenderContext,
- input_index: usize,
-) -> *const AudioBus {
- unsafe { (&*node).data().pull_input(&*graph, &*context, input_index) }
-}
-
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_node_channel_count(node: *const NodeHandle) -> usize {
- unsafe { &*node }.data().channel_count.get()
-}
-
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_node_channel_count_mode(node: *const NodeHandle) -> ChannelCountMode {
- unsafe { &*node }.data().channel_count_mode.get()
-}
-
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_node_channel_interpretation(
- node: *const NodeHandle,
-) -> ChannelInterpretation {
- unsafe { &*node }.data().channel_interpretation.get()
-}
-
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_node_set_channel_count(node: *const NodeHandle, value: usize) {
- unsafe { &*node }.data().channel_count.set(value);
-}
-
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_node_set_channel_count_mode(
- node: *const NodeHandle,
- value: ChannelCountMode,
-) {
- unsafe { &*node }.data().channel_count_mode.set(value);
-}
-
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_node_set_channel_interpretation(
- node: *const NodeHandle,
- value: ChannelInterpretation,
-) {
- unsafe { &*node }.data().channel_interpretation.set(value);
-}
-
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_node_has_input_connections(node: *const NodeHandle, input: usize) -> bool {
- !(unsafe { &*(&*node).data().input_connections.get() })[input].is_empty()
-}
-
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_node_outgoing_node_connection_count(node: *const NodeHandle) -> usize {
- unsafe { &*(&*node).data().outgoing_node_connections.get() }.len()
-}
-
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_node_outgoing_param_connection_count(node: *const NodeHandle) -> usize {
- unsafe { &*(&*node).data().outgoing_param_connections.get() }.len()
-}
diff --git a/Libraries/LibWeb/Rust/src/web_audio/rendering/render_nodes.rs b/Libraries/LibWeb/Rust/src/web_audio/rendering/render_nodes.rs
index 20cc61f36f7..d113b506d04 100644
--- a/Libraries/LibWeb/Rust/src/web_audio/rendering/render_nodes.rs
+++ b/Libraries/LibWeb/Rust/src/web_audio/rendering/render_nodes.rs
@@ -128,13 +128,13 @@ impl<T: NodeProcessor> RenderNode for NativeRenderNode<T> {
}
}
-pub(super) fn node_handle<T: NodeProcessor + 'static>(data: RenderNodeData, processor: T) -> *mut NodeHandle {
- Box::into_raw(Box::new(NodeHandle {
+pub(super) fn node_handle<T: NodeProcessor + 'static>(data: RenderNodeData, processor: T) -> Box<NodeHandle> {
+ Box::new(NodeHandle {
node: Box::new(NativeRenderNode {
data,
processor: UnsafeCell::new(processor),
}),
- }))
+ })
}
struct PanGains {
@@ -1820,74 +1820,53 @@ impl NodeProcessor for PassthroughRenderNode {
}
}
-use crate::web_audio::control_message::clone_arc;
-use ak::Span;
-
-#[unsafe(no_mangle)]
-pub extern "C" fn web_audio_node_create_destination(
- node_id: u64,
- quantum_size: usize,
- channel_count: usize,
-) -> *mut NodeHandle {
+pub fn create_destination_render_node(node_id: u64, quantum_size: usize, channel_count: usize) -> Box<NodeHandle> {
let data = RenderNodeData::new(node_id, 1, 1, quantum_size, channel_count);
data.channel_count.set(channel_count);
data.channel_count_mode.set(ChannelCountMode::Explicit);
node_handle(data, DestinationRenderNode)
}
-/// # Safety
-/// Parameter pointers must name live `Arc` allocations for the duration of the call.
-#[unsafe(no_mangle)]
-pub unsafe extern "C" fn web_audio_node_create_gain(
- node_id: u64,
- quantum_size: usize,
- gain: *const RenderAudioParam,
-) -> *mut NodeHandle {
+pub fn create_gain_render_node(node_id: u64, quantum_size: usize, gain: Arc<RenderAudioParam>) -> Box<NodeHandle> {
let data = RenderNodeData::new(node_id, 1, 1, quantum_size, 1);
node_handle(
data,
GainRenderNode {
- gain: unsafe { clone_arc(gain) },
+ gain,
gain_values: vec![0.; quantum_size],
},
)
}
-/// # Safety
-/// Parameter pointers must name live `Arc` allocations for the duration of the call.
-#[unsafe(no_mangle)]
-pub unsafe extern "C" fn web_audio_node_create_constant_source(
+pub fn create_constant_source_render_node(
node_id: u64,
quantum_size: usize,
- offset: *const RenderAudioParam,
-) -> *mut NodeHandle {
+ offset: Arc<RenderAudioParam>,
+) -> Box<NodeHandle> {
let data = RenderNodeData::new(node_id, 0, 1, quantum_size, 1);
node_handle(
data,
ConstantSourceRenderNode {
source: ScheduledSourceRenderNode::default(),
- offset: unsafe { clone_arc(offset) },
+ offset,
offset_values: vec![0.; quantum_size],
},
)
}
-/// # Safety
-/// Parameter pointers must name live `Arc` allocations for the duration of the call.
-#[unsafe(no_mangle)]
-pub unsafe extern "C" fn web_audio_node_create_oscillator(
+pub fn create_oscillator_render_node(
node_id: u64,
quantum_size: usize,
- frequency: *const RenderAudioParam,
- detune: *const RenderAudioParam,
-) -> *mut NodeHandle {
+ frequency: Arc<RenderAudioParam>,
+ detune: Arc<RenderAudioParam>,
+) -> Box<NodeHandle> {
let data = RenderNodeData::new(node_id, 0, 1, quantum_size, 1);
node_handle(
data,
OscillatorRenderNode {
source: ScheduledSourceRenderNode::default(),
- frequency: unsafe { clone_arc(frequency) },
- detune: unsafe { clone_arc(detune) },
+ frequency,
+ detune,
frequency_values: vec![0.; quantum_size],
detune_values: vec![0.; quantum_size],
r#type: OscillatorType::Sine,
@@ -1898,22 +1877,19 @@ pub unsafe extern "C" fn web_audio_node_create_oscillator(
)
}
-/// # Safety
-/// Parameter pointers must name live `Arc` allocations for the duration of the call.
-#[unsafe(no_mangle)]
-pub unsafe extern "C" fn web_audio_node_create_audio_buffer_source(
+pub fn create_audio_buffer_source_render_node(
node_id: u64,
quantum_size: usize,
- playback_rate: *const RenderAudioParam,
- detune: *const RenderAudioParam,
-) -> *mut NodeHandle {
+ playback_rate: Arc<RenderAudioParam>,
+ detune: Arc<RenderAudioParam>,
+) -> Box<NodeHandle> {
let data = RenderNodeData::new(node_id, 0, 1, quantum_size, 1);
node_handle(
data,
AudioBufferSourceRenderNode {
source: ScheduledSourceRenderNode::default(),
- playback_rate: unsafe { clone_arc(playback_rate) },
- detune: unsafe { clone_arc(detune) },
+ playback_rate,
+ detune,
playback_rate_values: vec![0.; quantum_size],
detune_values: vec![0.; quantum_size],
buffer: None,
@@ -1929,20 +1905,17 @@ pub unsafe extern "C" fn web_audio_node_create_audio_buffer_source(
)
}
-/// # Safety
-/// Parameter pointers must name live `Arc` allocations for the duration of the call.
-#[unsafe(no_mangle)]
-pub unsafe extern "C" fn web_audio_node_create_delay(
+pub fn create_delay_render_node(
node_id: u64,
quantum_size: usize,
- delay_time: *const RenderAudioParam,
+ delay_time: Arc<RenderAudioParam>,
max_delay_time: f64,
-) -> *mut NodeHandle {
+) -> Box<NodeHandle> {
let data = RenderNodeData::new(node_id, 1, 1, quantum_size, 1);
node_handle(
data,
DelayRenderNode {
- delay_time: unsafe { clone_arc(delay_time) },
+ delay_time,
delay_values: vec![0.; quantum_size],
max_delay_time,
history: Vec::new(),
@@ -1951,31 +1924,27 @@ pub unsafe extern "C" fn web_audio_node_create_delay(
)
}
-/// # Safety
-/// Parameter pointers must name live `Arc` allocations for the duration of the call.
-#[unsafe(no_mangle)]
-pub unsafe extern "C" fn web_audio_node_create_stereo_panner(
+pub fn create_stereo_panner_render_node(
node_id: u64,
quantum_size: usize,
- pan: *const RenderAudioParam,
-) -> *mut NodeHandle {
+ pan: Arc<RenderAudioParam>,
+) -> Box<NodeHandle> {
let data = RenderNodeData::new(node_id, 1, 1, quantum_size, 2);
data.channel_count_mode.set(ChannelCountMode::ClampedMax);
node_handle(
data,
StereoPannerRenderNode {
- pan: unsafe { clone_arc(pan) },
+ pan,
pan_values: vec![0.; quantum_size],
},
)
}
-#[unsafe(no_mangle)]
-pub extern "C" fn web_audio_node_create_channel_splitter(
+pub fn create_channel_splitter_render_node(
node_id: u64,
quantum_size: usize,
number_of_outputs: usize,
-) -> *mut NodeHandle {
+) -> Box<NodeHandle> {
let data = RenderNodeData::new(node_id, 1, number_of_outputs, quantum_size, 1);
data.channel_count.set(number_of_outputs);
data.channel_count_mode.set(ChannelCountMode::Explicit);
@@ -1983,37 +1952,33 @@ pub extern "C" fn web_audio_node_create_channel_splitter(
node_handle(data, ChannelSplitterRenderNode)
}
-#[unsafe(no_mangle)]
-pub extern "C" fn web_audio_node_create_channel_merger(
+pub fn create_channel_merger_render_node(
node_id: u64,
quantum_size: usize,
number_of_inputs: usize,
-) -> *mut NodeHandle {
+) -> Box<NodeHandle> {
let data = RenderNodeData::new(node_id, number_of_inputs, 1, quantum_size, number_of_inputs);
data.channel_count.set(1);
data.channel_count_mode.set(ChannelCountMode::Explicit);
node_handle(data, ChannelMergerRenderNode)
}
-/// # Safety
-/// Parameter pointers must name live `Arc` allocations for the duration of the call.
-#[unsafe(no_mangle)]
-pub unsafe extern "C" fn web_audio_node_create_biquad_filter(
+pub fn create_biquad_filter_render_node(
node_id: u64,
quantum_size: usize,
- frequency: *const RenderAudioParam,
- detune: *const RenderAudioParam,
- q: *const RenderAudioParam,
- gain: *const RenderAudioParam,
-) -> *mut NodeHandle {
+ frequency: Arc<RenderAudioParam>,
+ detune: Arc<RenderAudioParam>,
+ q: Arc<RenderAudioParam>,
+ gain: Arc<RenderAudioParam>,
+) -> Box<NodeHandle> {
let data = RenderNodeData::new(node_id, 1, 1, quantum_size, 1);
node_handle(
data,
BiquadFilterRenderNode {
- frequency: unsafe { clone_arc(frequency) },
- detune: unsafe { clone_arc(detune) },
- q: unsafe { clone_arc(q) },
- gain: unsafe { clone_arc(gain) },
+ frequency,
+ detune,
+ q,
+ gain,
frequency_values: vec![0.; quantum_size],
detune_values: vec![0.; quantum_size],
q_values: vec![0.; quantum_size],
@@ -2024,29 +1989,27 @@ pub unsafe extern "C" fn web_audio_node_create_biquad_filter(
)
}
-#[unsafe(no_mangle)]
-pub extern "C" fn web_audio_node_create_iir_filter(
+pub fn create_iir_filter_render_node(
node_id: u64,
quantum_size: usize,
- feedforward: Span<'_, f64>,
- feedback: Span<'_, f64>,
-) -> *mut NodeHandle {
+ feedforward: &[f64],
+ feedback: &[f64],
+) -> Box<NodeHandle> {
let data = RenderNodeData::new(node_id, 1, 1, quantum_size, 1);
- assert!(feedforward.as_slice().len() < 32);
- assert!(feedback.as_slice().len() < 32);
+ assert!(feedforward.len() < 32);
+ assert!(feedback.len() < 32);
node_handle(
data,
IIRFilterRenderNode {
- feedforward: feedforward.as_slice().to_vec(),
- feedback: feedback.as_slice().to_vec(),
+ feedforward: feedforward.to_vec(),
+ feedback: feedback.to_vec(),
filter_states: Vec::new(),
position: 0,
},
)
}
-#[unsafe(no_mangle)]
-pub extern "C" fn web_audio_node_create_wave_shaper(node_id: u64, quantum_size: usize) -> *mut NodeHandle {
+pub fn create_wave_shaper_render_node(node_id: u64, quantum_size: usize) -> Box<NodeHandle> {
let data = RenderNodeData::new(node_id, 1, 1, quantum_size, 1);
node_handle(
data,
@@ -2060,8 +2023,7 @@ pub extern "C" fn web_audio_node_create_wave_shaper(node_id: u64, quantum_size:
)
}
-#[unsafe(no_mangle)]
-pub extern "C" fn web_audio_node_create_convolver(node_id: u64, quantum_size: usize) -> *mut NodeHandle {
+pub fn create_convolver_render_node(node_id: u64, quantum_size: usize) -> Box<NodeHandle> {
let data = RenderNodeData::new(node_id, 1, 1, quantum_size, 1);
data.channel_count_mode.set(ChannelCountMode::ClampedMax);
node_handle(
@@ -2081,39 +2043,34 @@ pub extern "C" fn web_audio_node_create_convolver(node_id: u64, quantum_size: us
)
}
-/// # Safety
-/// Parameter pointers must name live `Arc` allocations for the duration of the call.
-#[unsafe(no_mangle)]
-pub unsafe extern "C" fn web_audio_node_create_panner(
+pub fn create_panner_render_node(
node_id: u64,
quantum_size: usize,
- params: Span<'_, *const RenderAudioParam>,
-) -> *mut NodeHandle {
+ params: &[&Arc<RenderAudioParam>; 15],
+) -> Box<NodeHandle> {
let data = RenderNodeData::new(node_id, 1, 1, quantum_size, 2);
data.channel_count_mode.set(ChannelCountMode::ClampedMax);
- let params = params.as_slice();
- assert_eq!(params.len(), 15);
node_handle(
data,
PannerRenderNode {
params: PannerParams {
- position_x: unsafe { clone_arc(params[0]) },
- position_y: unsafe { clone_arc(params[1]) },
- position_z: unsafe { clone_arc(params[2]) },
- orientation_x: unsafe { clone_arc(params[3]) },
- orientation_y: unsafe { clone_arc(params[4]) },
- orientation_z: unsafe { clone_arc(params[5]) },
+ position_x: Arc::clone(params[0]),
+ position_y: Arc::clone(params[1]),
+ position_z: Arc::clone(params[2]),
+ orientation_x: Arc::clone(params[3]),
+ orientation_y: Arc::clone(params[4]),
+ orientation_z: Arc::clone(params[5]),
},
listener_params: ListenerParams {
- position_x: unsafe { clone_arc(params[6]) },
- position_y: unsafe { clone_arc(params[7]) },
- position_z: unsafe { clone_arc(params[8]) },
- forward_x: unsafe { clone_arc(params[9]) },
- forward_y: unsafe { clone_arc(params[10]) },
- forward_z: unsafe { clone_arc(params[11]) },
- up_x: unsafe { clone_arc(params[12]) },
- up_y: unsafe { clone_arc(params[13]) },
- up_z: unsafe { clone_arc(params[14]) },
+ position_x: Arc::clone(params[6]),
+ position_y: Arc::clone(params[7]),
+ position_z: Arc::clone(params[8]),
+ forward_x: Arc::clone(params[9]),
+ forward_y: Arc::clone(params[10]),
+ forward_z: Arc::clone(params[11]),
+ up_x: Arc::clone(params[12]),
+ up_y: Arc::clone(params[13]),
+ up_z: Arc::clone(params[14]),
},
config: SetPannerParameters::default(),
param_values: (0..15).map(|_| vec![0.; quantum_size]).collect(),
@@ -2121,8 +2078,7 @@ pub unsafe extern "C" fn web_audio_node_create_panner(
)
}
-#[unsafe(no_mangle)]
-pub extern "C" fn web_audio_node_create_passthrough(node_id: u64, quantum_size: usize) -> *mut NodeHandle {
+pub fn create_passthrough_render_node(node_id: u64, quantum_size: usize) -> Box<NodeHandle> {
let data = RenderNodeData::new(node_id, 1, 1, quantum_size, 1);
node_handle(data, PassthroughRenderNode)
}
diff --git a/Libraries/LibWeb/Rust/src/web_audio/rendering/script_processor_pipe.rs b/Libraries/LibWeb/Rust/src/web_audio/rendering/script_processor_pipe.rs
index d68a1bcba7b..f99b59f60fb 100644
--- a/Libraries/LibWeb/Rust/src/web_audio/rendering/script_processor_pipe.rs
+++ b/Libraries/LibWeb/Rust/src/web_audio/rendering/script_processor_pipe.rs
@@ -11,7 +11,6 @@ use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::{Arc, Condvar, Mutex};
use super::pipe_callbacks::{CallbackService, PipeCallbacks};
-use crate::web_audio::control_message::clone_arc;
#[derive(Clone, Copy)]
#[repr(C)]
@@ -171,67 +170,3 @@ pub(crate) unsafe extern "C" fn web_audio_script_pipe_create(
pub(crate) unsafe extern "C" fn web_audio_script_pipe_destroy(pipe: *const ScriptProcessorPipe) {
drop(unsafe { Arc::from_raw(pipe) });
}
-
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_script_pipe_channel(
- pipe: *const ScriptProcessorPipe,
- output: bool,
- block: usize,
- channel: usize,
- result: *mut ak::SpanMut<'static, f32>,
-) {
- let (pointer, length) = if output {
- unsafe { (&*pipe).output_channel(block, channel) }
- } else {
- unsafe { (&*pipe).input_channel(block, channel) }
- };
- unsafe {
- *result = ak::SpanMut::new(ak::slice_from_raw_parts_mut(pointer, length));
- }
-}
-
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_script_pipe_has_output(
- pipe: *const ScriptProcessorPipe,
- block: usize,
-) -> bool {
- unsafe { (&*pipe).has_output(block) }
-}
-
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_script_pipe_is_rendering_owner(
- pipe: *const ScriptProcessorPipe,
- block: usize,
-) -> bool {
- unsafe { &*pipe }.is_block_owned_by_rendering_thread(block)
-}
-
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_script_pipe_to_control(
- pipe: *const ScriptProcessorPipe,
- block: usize,
- frame: u64,
-) {
- unsafe { clone_arc(pipe) }.hand_block_to_control_thread(block, frame);
-}
-
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_script_pipe_to_rendering(
- pipe: *const ScriptProcessorPipe,
- block: usize,
- has_output: bool,
-) {
- unsafe {
- (&*pipe).hand_block_back_to_rendering_thread(block, has_output);
- }
-}
-
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_script_pipe_shutdown(pipe: *const ScriptProcessorPipe) {
- unsafe { &*pipe }.shut_down();
-}
-
-#[unsafe(no_mangle)]
-pub(crate) unsafe extern "C" fn web_audio_script_pipe_is_shutdown(pipe: *const ScriptProcessorPipe) -> bool {
- unsafe { &*pipe }.is_shut_down()
-}
diff --git a/Libraries/LibWeb/Rust/src/web_audio/rendering/script_processor_render_node.rs b/Libraries/LibWeb/Rust/src/web_audio/rendering/script_processor_render_node.rs
index 75c38ba16dc..8cbce204527 100644
--- a/Libraries/LibWeb/Rust/src/web_audio/rendering/script_processor_render_node.rs
+++ b/Libraries/LibWeb/Rust/src/web_audio/rendering/script_processor_render_node.rs
@@ -12,7 +12,6 @@ use super::render_graph::RenderGraph;
use super::render_node::*;
use super::render_nodes::{BusRef, NodeProcessor, node_handle};
use super::script_processor_pipe::ScriptProcessorPipe;
-use crate::web_audio::control_message::clone_arc;
struct ScriptProcessorRenderNode {
pipe: Arc<ScriptProcessorPipe>,
@@ -83,15 +82,11 @@ impl NodeProcessor for ScriptProcessorRenderNode {
}
}
-/// # Safety
-/// The pipe pointer must name a live `Arc` allocation for the call.
-#[unsafe(no_mangle)]
-pub unsafe extern "C" fn web_audio_node_create_script_processor(
+pub fn create_script_processor_render_node(
node_id: u64,
quantum_size: usize,
- pipe: *const ScriptProcessorPipe,
-) -> *mut NodeHandle {
- let pipe = unsafe { clone_arc(pipe) };
+ pipe: Arc<ScriptProcessorPipe>,
+) -> Box<NodeHandle> {
let data = RenderNodeData::new(node_id, 1, 1, quantum_size, pipe.config.output_channel_count.max(1));
assert!(pipe.config.buffer_size.is_multiple_of(quantum_size));
node_handle(
diff --git a/Libraries/LibWeb/WebAudio/AudioParamTimeline.cpp b/Libraries/LibWeb/WebAudio/AudioParamTimeline.cpp
deleted file mode 100644
index e545dd187a6..00000000000
--- a/Libraries/LibWeb/WebAudio/AudioParamTimeline.cpp
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright (c) 2024, Shannon Booth <[email protected]>
- * Copyright (c) 2026, Jelle Raaijmakers <[email protected]>
- * Copyright (c) 2026-present, the Ladybird developers.
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#include <LibWeb/WebAudio/AudioParamTimeline.h>
-#include <LibWeb/WebAudio/RustFFI.h>
-
-namespace Web::WebAudio {
-
-AudioParamTimeline::AudioParamTimeline(float default_value)
- : m_timeline(RustFFI::web_audio_param_timeline_create(default_value))
-{
- static_assert(to_underlying(InsertResult::Success) == to_underlying(RustFFI::InsertResult::Success));
- static_assert(to_underlying(InsertResult::EventContainedInValueCurve) == to_underlying(RustFFI::InsertResult::EventContainedInValueCurve));
- static_assert(to_underlying(InsertResult::ValueCurveOverlapsEvent) == to_underlying(RustFFI::InsertResult::ValueCurveOverlapsEvent));
-}
-
-AudioParamTimeline::~AudioParamTimeline()
-{
- RustFFI::web_audio_param_timeline_destroy(m_timeline);
-}
-
-float AudioParamTimeline::value_at_time(double time) const
-{
- return RustFFI::web_audio_param_timeline_value_at_time(m_timeline, time);
-}
-
-void AudioParamTimeline::sample(double start_time, double sample_period, Span<float> output) const
-{
- RustFFI::web_audio_param_timeline_sample(m_timeline, start_time, sample_period, output);
-}
-
-bool AudioParamTimeline::has_events() const
-{
- return RustFFI::web_audio_param_timeline_has_events(m_timeline);
-}
-
-float AudioParamTimeline::default_value() const
-{
- return RustFFI::web_audio_param_timeline_default_value(m_timeline);
-}
-
-AudioParamTimeline::InsertResult AudioParamTimeline::set_value_at_time(float value, double start_time)
-{
- return static_cast<InsertResult>(RustFFI::web_audio_param_timeline_set_value_at_time(m_timeline, value, start_time));
-}
-
-AudioParamTimeline::InsertResult AudioParamTimeline::linear_ramp_to_value_at_time(float value, double end_time, double current_time, float current_value)
-{
- return static_cast<InsertResult>(RustFFI::web_audio_param_timeline_linear_ramp_to_value_at_time(m_timeline, value, end_time, current_time, current_value));
-}
-
-AudioParamTimeline::InsertResult AudioParamTimeline::exponential_ramp_to_value_at_time(float value, double end_time, double current_time, float current_value)
-{
- return static_cast<InsertResult>(RustFFI::web_audio_param_timeline_exponential_ramp_to_value_at_time(m_timeline, value, end_time, current_time, current_value));
-}
-
-AudioParamTimeline::InsertResult AudioParamTimeline::set_target_at_time(float target, double start_time, float time_constant)
-{
- return static_cast<InsertResult>(RustFFI::web_audio_param_timeline_set_target_at_time(m_timeline, target, start_time, time_constant));
-}
-
-AudioParamTimeline::InsertResult AudioParamTimeline::set_value_curve_at_time(Vector<float> values, double start_time, double duration)
-{
- return static_cast<InsertResult>(RustFFI::web_audio_param_timeline_set_value_curve_at_time(m_timeline, values.span(), start_time, duration));
-}
-
-void AudioParamTimeline::cancel_scheduled_values(double cancel_time)
-{
- RustFFI::web_audio_param_timeline_cancel_scheduled_values(m_timeline, cancel_time);
-}
-
-void AudioParamTimeline::cancel_and_hold_at_time(double cancel_time)
-{
- RustFFI::web_audio_param_timeline_cancel_and_hold_at_time(m_timeline, cancel_time);
-}
-
-}
diff --git a/Libraries/LibWeb/WebAudio/AudioParamTimeline.h b/Libraries/LibWeb/WebAudio/AudioParamTimeline.h
deleted file mode 100644
index dee1ffd199a..00000000000
--- a/Libraries/LibWeb/WebAudio/AudioParamTimeline.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (c) 2024, Shannon Booth <[email protected]>
- * Copyright (c) 2026, Jelle Raaijmakers <[email protected]>
- * Copyright (c) 2026-present, the Ladybird developers.
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#pragma once
-
-#include <AK/AtomicRefCounted.h>
-#include <AK/Span.h>
-#include <AK/Vector.h>
-#include <LibWeb/Export.h>
-
-namespace Web::WebAudio {
-
-// Holds the automation events for a single AudioParam and evaluates the parameter's intrinsic value over time.
-// This timeline is shared between the control thread, which inserts events through the AudioParam interface, and
-// the rendering thread, which evaluates the parameter while rendering the audio graph. All public methods lock an
-// internal mutex, so both threads observe a consistent series of automation events.
-// https://webaudio.github.io/web-audio-api/#dfn-automation-event
-class WEB_API AudioParamTimeline final : public AtomicRefCounted<AudioParamTimeline> {
-public:
- enum class [[nodiscard]] InsertResult : u8 {
- Success,
- EventContainedInValueCurve,
- ValueCurveOverlapsEvent,
- };
-
- explicit AudioParamTimeline(float default_value);
- ~AudioParamTimeline();
-
- // All event times passed into these methods must already be clamped to the context's current time by the caller.
- InsertResult set_value_at_time(float value, double start_time);
- InsertResult linear_ramp_to_value_at_time(float value, double end_time, double current_time, float current_value);
- InsertResult exponential_ramp_to_value_at_time(float value, double end_time, double current_time, float current_value);
- InsertResult set_target_at_time(float target, double start_time, float time_constant);
- InsertResult set_value_curve_at_time(Vector<float> values, double start_time, double duration);
- void cancel_scheduled_values(double cancel_time);
- void cancel_and_hold_at_time(double cancel_time);
-
- float value_at_time(double time) const;
-
- // Evaluates the intrinsic value for each sample frame of a render quantum starting at start_time.
- void sample(double start_time, double sample_period, Span<float> output) const;
-
- bool has_events() const;
- float default_value() const;
- void const* rust_timeline() const { return m_timeline; }
-
-private:
- void const* m_timeline { nullptr };
-};
-
-}
diff --git a/Libraries/LibWeb/WebAudio/BindingsGlue.h b/Libraries/LibWeb/WebAudio/BindingsGlue.h
deleted file mode 100644
index e6e2054f428..00000000000
--- a/Libraries/LibWeb/WebAudio/BindingsGlue.h
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright (c) 2026-present, the Ladybird developers.
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#pragma once
-
-#include <AK/Optional.h>
-#include <AK/Utf16View.h>
-#include <LibGC/Forward.h>
-#include <LibJS/Forward.h>
-#include <LibJS/Runtime/Value.h>
-#include <LibWeb/Export.h>
-#include <LibWeb/Forward.h>
-
-namespace Web::Bindings {
-
-// Maplike glue for AudioParamMap (see Meta/Generators/libweb_bindings/glue_headers.py).
-WEB_API GC::Ref<JS::Map> map_entries(JS::Realm&, WebAudio::AudioParamMap&);
-WEB_API Optional<JS::Value> map_get(JS::Realm&, WebAudio::AudioParamMap&, Utf16View key);
-WEB_API bool map_has(WebAudio::AudioParamMap&, Utf16View key);
-
-}
diff --git a/Libraries/LibWeb/WebAudio/ControlMessage.h b/Libraries/LibWeb/WebAudio/ControlMessage.h
deleted file mode 100644
index 8f70ca5631a..00000000000
--- a/Libraries/LibWeb/WebAudio/ControlMessage.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (c) 2025-2026, Ben Eidson <[email protected]>
- * Copyright (c) 2026, Jelle Raaijmakers <[email protected]>
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#pragma once
-
-#include <AK/NonnullOwnPtr.h>
-#include <AK/Variant.h>
-#include <AK/Vector.h>
-#include <LibWeb/WebAudio/Rendering/NodeMessage.h>
-#include <LibWeb/WebAudio/Rendering/RenderNode.h>
-#include <LibWeb/WebAudio/Types.h>
-
-namespace Web::WebAudio {
-
-// Transfers a freshly constructed render node to the rendering thread.
-struct AddNode {
- NonnullOwnPtr<Rendering::RenderNode> node;
-};
-
-// Retires the render node of an AudioNode that is no longer alive on the control thread. The rendering loop only
-// considers "the set of all nodes created by this BaseAudioContext, and still alive", so a node that was garbage
-// collected must leave the render graph as well.
-// https://webaudio.github.io/web-audio-api/#rendering-loop
-struct RemoveNode {
- NodeID node_id { 0 };
-};
-
-// Replaces the source node's outgoing connections with a full snapshot taken after a connect() or disconnect() call.
-struct ReplaceConnections {
- NodeID source { 0 };
- Vector<Rendering::RenderNode::OutgoingNodeConnection> node_connections;
- Vector<Rendering::RenderNode::OutgoingParamConnection> param_connections;
-};
-
-struct SetChannelConfig {
- NodeID node_id { 0 };
- size_t channel_count { 0 };
- Bindings::ChannelCountMode channel_count_mode { Bindings::ChannelCountMode::Max };
- Bindings::ChannelInterpretation channel_interpretation { Bindings::ChannelInterpretation::Speakers };
-};
-
-// https://webaudio.github.io/web-audio-api/#control-message
-using ControlMessage = Variant<AddNode, RemoveNode, ReplaceConnections, SetChannelConfig, NodeMessage>;
-
-}
diff --git a/Libraries/LibWeb/WebAudio/ControlMessageQueue.cpp b/Libraries/LibWeb/WebAudio/ControlMessageQueue.cpp
deleted file mode 100644
index 4e0b9eaa12e..00000000000
--- a/Libraries/LibWeb/WebAudio/ControlMessageQueue.cpp
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (c) 2025, Ben Eidson <[email protected]>
- * Copyright (c) 2026-present, the Ladybird developers.
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#include <LibWeb/WebAudio/ControlMessageQueue.h>
-#include <LibWeb/WebAudio/RustFFI.h>
-namespace Web::WebAudio {
-
-static_assert(to_underlying(Bindings::ChannelCountMode::Max) == to_underlying(RustFFI::ChannelCountMode::Max));
-static_assert(to_underlying(Bindings::ChannelCountMode::ClampedMax) == to_underlying(RustFFI::ChannelCountMode::ClampedMax));
-static_assert(to_underlying(Bindings::ChannelCountMode::Explicit) == to_underlying(RustFFI::ChannelCountMode::Explicit));
-static_assert(to_underlying(Bindings::ChannelInterpretation::Speakers) == to_underlying(RustFFI::ChannelInterpretation::Speakers));
-static_assert(to_underlying(Bindings::ChannelInterpretation::Discrete) == to_underlying(RustFFI::ChannelInterpretation::Discrete));
-static_assert(to_underlying(Bindings::OscillatorType::Sine) == to_underlying(RustFFI::OscillatorType::Sine));
-static_assert(to_underlying(Bindings::OscillatorType::Square) == to_underlying(RustFFI::OscillatorType::Square));
-static_assert(to_underlying(Bindings::OscillatorType::Sawtooth) == to_underlying(RustFFI::OscillatorType::Sawtooth));
-static_assert(to_underlying(Bindings::OscillatorType::Triangle) == to_underlying(RustFFI::OscillatorType::Triangle));
-static_assert(to_underlying(Bindings::OscillatorType::Custom) == to_underlying(RustFFI::OscillatorType::Custom));
-static_assert(to_underlying(Bindings::PanningModelType::Equalpower) == to_underlying(RustFFI::PanningModelType::Equalpower));
-static_assert(to_underlying(Bindings::PanningModelType::HRTF) == to_underlying(RustFFI::PanningModelType::HRTF));
-static_assert(to_underlying(Bindings::DistanceModelType::Linear) == to_underlying(RustFFI::DistanceModelType::Linear));
-static_assert(to_underlying(Bindings::DistanceModelType::Inverse) == to_underlying(RustFFI::DistanceModelType::Inverse));
-static_assert(to_underlying(Bindings::DistanceModelType::Exponential) == to_underlying(RustFFI::DistanceModelType::Exponential));
-static_assert(to_underlying(Bindings::OverSampleType::None) == to_underlying(RustFFI::OverSampleType::None));
-static_assert(to_underlying(Bindings::OverSampleType::_2x) == to_underlying(RustFFI::OverSampleType::_2x));
-static_assert(to_underlying(Bindings::OverSampleType::_4x) == to_underlying(RustFFI::OverSampleType::_4x));
-
-ControlMessageQueue::ControlMessageQueue()
- : m_queue(RustFFI::web_audio_control_queue_create())
-{
-}
-ControlMessageQueue::~ControlMessageQueue() { RustFFI::web_audio_control_queue_destroy(m_queue); }
-void* ControlMessageQueue::drain() { return RustFFI::web_audio_control_queue_drain(m_queue); }
-
-void ControlMessageQueue::enqueue(ControlMessage message)
-{
- auto shared_object = []<typename T>(T* pointer) {
- return RustFFI::FfiSharedCppObject { pointer,
- [](void* pointer) { static_cast<T*>(pointer)->ref(); },
- [](void* pointer) { static_cast<T*>(pointer)->unref(); } };
- };
- void* rust_message = message.visit(
- [](AddNode& add_node) -> void* {
- auto* node = add_node.node.leak_ptr();
- auto* rust_node = node->release_rust_node();
- delete node;
- return RustFFI::web_audio_message_add_node(rust_node);
- },
- [](RemoveNode const& value) -> void* { return RustFFI::web_audio_message_remove_node(value.node_id.value()); },
- [](ReplaceConnections const& value) -> void* {
- Vector<RustFFI::OutgoingNodeConnection> nodes;
- for (auto const& connection : value.node_connections)
- nodes.append({ connection.destination.value(), connection.output_index, connection.input_index });
- Vector<RustFFI::FfiOutgoingParamConnection> params;
- for (auto const& connection : value.param_connections)
- params.append({ connection.destination->rust_param(), connection.output_index });
- return RustFFI::web_audio_message_replace_connections(value.source.value(), nodes.span(), params.span());
- },
- [](SetChannelConfig const& value) -> void* { return RustFFI::web_audio_message_set_channel_config(value.node_id.value(), value.channel_count, static_cast<RustFFI::ChannelCountMode>(value.channel_count_mode), static_cast<RustFFI::ChannelInterpretation>(value.channel_interpretation)); },
- [&](NodeMessage const& node_message) -> void* {
- return node_message.visit(
- [](StartSource const& value) -> void* { return RustFFI::web_audio_message_start_source(value.node_id.value(), value.when); },
- [](StopSource const& value) -> void* { return RustFFI::web_audio_message_stop_source(value.node_id.value(), value.when); },
- [](StartBufferSource const& value) -> void* { return RustFFI::web_audio_message_start_buffer_source(value.node_id.value(), value.when, value.offset, value.duration.has_value(), value.duration.value_or(0.), value.buffer ? value.buffer->rust_data() : nullptr); },
- [](SetBufferSourceParameters const& value) -> void* { return RustFFI::web_audio_message_set_buffer_source_parameters(value.node_id.value(), value.loop, value.loop_start, value.loop_end, value.buffer ? value.buffer->rust_data() : nullptr, value.update_buffer); },
- [](SetOscillatorWaveform const& value) -> void* { return RustFFI::web_audio_message_set_oscillator_waveform(value.node_id.value(), static_cast<RustFFI::OscillatorType>(value.type), value.periodic_wave ? value.periodic_wave->rust_data() : nullptr); },
- [](SetBiquadFilterType const& value) -> void* { return RustFFI::web_audio_message_set_biquad_filter_type(value.node_id.value(), static_cast<RustFFI::BiquadFilterType>(value.type)); },
- [&](SetConvolverKernel const& value) -> void* { return RustFFI::web_audio_message_set_convolver_kernel(value.node_id.value(), value.kernel ? value.kernel->rust_kernel() : nullptr, value.delay_line ? value.delay_line->rust_delay_line() : nullptr); },
- [](SetPannerParameters const& value) -> void* { return RustFFI::web_audio_message_set_panner_parameters(value.node_id.value(), static_cast<RustFFI::PanningModelType>(value.panning_model), static_cast<RustFFI::DistanceModelType>(value.distance_model), value.ref_distance, value.max_distance, value.rolloff_factor, value.cone_inner_angle, value.cone_outer_angle, value.cone_outer_gain); },
- [](SetWaveShaperParameters const& value) -> void* { return RustFFI::web_audio_message_set_wave_shaper_parameters(value.node_id.value(), value.curve ? value.curve->rust_data() : nullptr, static_cast<RustFFI::OverSampleType>(value.oversample)); },
- [&](SetMediaStreamSourceRing const& value) -> void* { return RustFFI::web_audio_message_set_media_stream_source_ring(value.node_id.value(), shared_object(value.ring.ptr()), value.channel_count); });
- });
- RustFFI::web_audio_control_queue_enqueue(m_queue, rust_message);
-}
-
-}
diff --git a/Libraries/LibWeb/WebAudio/ControlMessageQueue.h b/Libraries/LibWeb/WebAudio/ControlMessageQueue.h
deleted file mode 100644
index e292d68e124..00000000000
--- a/Libraries/LibWeb/WebAudio/ControlMessageQueue.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (c) 2025, Ben Eidson <[email protected]>
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#pragma once
-
-#include <AK/AtomicRefCounted.h>
-#include <AK/Mutex.h>
-#include <AK/Vector.h>
-#include <LibWeb/Export.h>
-#include <LibWeb/WebAudio/ControlMessage.h>
-
-namespace Web::WebAudio {
-
-// https://webaudio.github.io/web-audio-api/#control-message-queue
-class WEB_API ControlMessageQueue : public AtomicRefCounted<ControlMessageQueue> {
-public:
- ControlMessageQueue();
- ~ControlMessageQueue();
- void enqueue(ControlMessage); // Called by the control thread.
- void const* rust_queue() const { return m_queue; }
- void* drain(); // Called by the rendering thread.
-
-private:
- void const* m_queue { nullptr };
-};
-
-}
diff --git a/Libraries/LibWeb/WebAudio/MediaStreamAudioDestinationNode.cpp b/Libraries/LibWeb/WebAudio/MediaStreamAudioDestinationNode.cpp
index a0bde0e8c03..a4a393d0fc9 100644
--- a/Libraries/LibWeb/WebAudio/MediaStreamAudioDestinationNode.cpp
+++ b/Libraries/LibWeb/WebAudio/MediaStreamAudioDestinationNode.cpp
@@ -4,18 +4,69 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
+#include <AK/AtomicRefCounted.h>
+#include <LibAudio/SpscAudioFrameRing.h>
#include <LibCore/EventLoop.h>
#include <LibWeb/Bindings/Wrappable.h>
#include <LibWeb/Bindings/WrapperWorld.h>
#include <LibWeb/MediaCapture/MediaStream.h>
#include <LibWeb/MediaCapture/MediaStreamTrack.h>
-#include <LibWeb/WebAudio/Rendering/MediaStreamDestinationRenderNode.h>
#include <LibWeb/WebAudio/RustFFI.h>
+
namespace Web::WebAudio {
+struct MediaStreamDestinationSharedState final : public AtomicRefCounted<MediaStreamDestinationSharedState> {
+ explicit MediaStreamDestinationSharedState(NonnullRefPtr<Audio::SpscAudioFrameRing> ring)
+ : ring(move(ring))
+ {
+ }
+
+ NonnullRefPtr<Audio::SpscAudioFrameRing> ring;
+
+ // Only the control thread invokes or clears this callback.
+ Function<void()> drain;
+};
+
+struct DestinationCallbackService : AtomicRefCounted<DestinationCallbackService> {
+ DestinationCallbackService(NonnullRefPtr<MediaStreamDestinationSharedState> state, Core::EventLoop& loop)
+ : shared_state(move(state))
+ , event_loop(loop)
+ {
+ }
+ NonnullRefPtr<MediaStreamDestinationSharedState> shared_state;
+ Core::EventLoop& event_loop;
+};
+
+static void* create_render_node(u64 node_id, size_t quantum_size, size_t channel_count, NonnullRefPtr<MediaStreamDestinationSharedState> shared_state, Core::EventLoop& event_loop)
+{
+ auto service = adopt_ref(*new DestinationCallbackService(shared_state, event_loop));
+ RustFFI::PipeCallbacks callbacks {
+ { service.ptr(), [](void* service) { static_cast<DestinationCallbackService*>(service)->ref(); }, [](void* service) { static_cast<DestinationCallbackService*>(service)->unref(); } },
+ [](void* service, void* task, void (*invoke)(void*)) {
+ static_cast<DestinationCallbackService*>(service)->event_loop.deferred_invoke([task, invoke] { invoke(task); });
+ },
+ [](void* service) {
+ auto& shared_state = *static_cast<DestinationCallbackService*>(service)->shared_state;
+ if (shared_state.drain)
+ shared_state.drain();
+ },
+ [](void*, size_t, u64) { return false; },
+ };
+ return RustFFI::web_audio_node_create_media_stream_destination(node_id, quantum_size, channel_count,
+ { shared_state->ring.ptr(), [](void* ring) { static_cast<Audio::SpscAudioFrameRing*>(ring)->ref(); }, [](void* ring) { static_cast<Audio::SpscAudioFrameRing*>(ring)->unref(); } },
+ {
+ [](void* ring) { return static_cast<Audio::SpscAudioFrameRing*>(ring)->channel_count(); },
+ [](void* ring) { return static_cast<Audio::SpscAudioFrameRing*>(ring)->frames_available(); },
+ [](void* ring) { return static_cast<Audio::SpscAudioFrameRing*>(ring)->frames_free(); },
+ [](void* ring, Span<float> samples) { return static_cast<Audio::SpscAudioFrameRing*>(ring)->try_pop(samples); },
+ [](void* ring, ReadonlySpan<float> samples) { return static_cast<Audio::SpscAudioFrameRing*>(ring)->try_push(samples); },
+ },
+ callbacks);
+}
+
extern "C" void web_audio_media_destination_create_stream(MediaCapture::MediaStream**, MediaCapture::MediaStreamTrack**);
extern "C" RustFFI::FfiSharedCppObject web_audio_media_destination_create_state(MediaCapture::MediaStreamTrack*, u64, u32, u32, void**);
-extern "C" void web_audio_media_destination_clear_drain(Rendering::MediaStreamDestinationSharedState*);
+extern "C" void web_audio_media_destination_clear_drain(MediaStreamDestinationSharedState*);
extern "C" JS::Object* web_audio_media_destination_wrap_stream(JS::Realm*, MediaCapture::MediaStream*);
void web_audio_media_destination_create_stream(MediaCapture::MediaStream** out_stream, MediaCapture::MediaStreamTrack** out_track)
{
@@ -41,7 +92,7 @@ RustFFI::FfiSharedCppObject web_audio_media_destination_create_state(MediaCaptur
// (~170 ms at 48 kHz) absorb a full burst plus scheduling jitter.
static constexpr size_t ring_capacity_in_frames = 8192;
auto ring = adopt_ref(*new Audio::SpscAudioFrameRing(ring_capacity_in_frames, channel_count));
- auto shared_state = adopt_ref(*new Rendering::MediaStreamDestinationSharedState(move(ring)));
+ auto shared_state = adopt_ref(*new MediaStreamDestinationSharedState(move(ring)));
// The drain callback runs (and is later cleared) exclusively on the control thread; it is
// the only place a GC root crosses into the shared state, so the render thread never
@@ -59,11 +110,10 @@ RustFFI::FfiSharedCppObject web_audio_media_destination_create_state(MediaCaptur
}
};
- Rendering::MediaStreamDestinationRenderNode node(NodeID(node_id), 128, channel_count, shared_state, Core::EventLoop::current());
- *render_node = node.release_rust_node();
- return { &shared_state.leak_ref(), [](void* state) { static_cast<Rendering::MediaStreamDestinationSharedState*>(state)->ref(); }, [](void* state) { static_cast<Rendering::MediaStreamDestinationSharedState*>(state)->unref(); } };
+ *render_node = create_render_node(node_id, 128, channel_count, shared_state, Core::EventLoop::current());
+ return { &shared_state.leak_ref(), [](void* state) { static_cast<MediaStreamDestinationSharedState*>(state)->ref(); }, [](void* state) { static_cast<MediaStreamDestinationSharedState*>(state)->unref(); } };
}
-void web_audio_media_destination_clear_drain(Rendering::MediaStreamDestinationSharedState* state) { state->drain = nullptr; }
+void web_audio_media_destination_clear_drain(MediaStreamDestinationSharedState* state) { state->drain = nullptr; }
JS::Object* web_audio_media_destination_wrap_stream(JS::Realm* realm, MediaCapture::MediaStream* stream) { return Bindings::wrap(Bindings::host_defined_wrapper_world(*realm), *realm, GC::Ref { *stream }).ptr(); }
}
diff --git a/Libraries/LibWeb/WebAudio/Rendering/AnalyserRenderNode.cpp b/Libraries/LibWeb/WebAudio/Rendering/AnalyserRenderNode.cpp
deleted file mode 100644
index a2302aabc0e..00000000000
--- a/Libraries/LibWeb/WebAudio/Rendering/AnalyserRenderNode.cpp
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright (c) 2026-present, the Ladybird developers.
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#include <LibWeb/WebAudio/Rendering/AnalyserRenderNode.h>
-#include <LibWeb/WebAudio/RustFFI.h>
-
-namespace Web::WebAudio::Rendering {
-
-AnalyserRenderNode::AnalyserRenderNode(NodeID node_id, size_t quantum_size, NonnullRefPtr<Audio::SpscAudioFrameRing> time_domain_ring)
- : RenderNode(RustFFI::web_audio_node_create_analyser(node_id.value(), quantum_size,
- { time_domain_ring.ptr(), [](void* ring) { static_cast<Audio::SpscAudioFrameRing*>(ring)->ref(); }, [](void* ring) { static_cast<Audio::SpscAudioFrameRing*>(ring)->unref(); } },
- {
- [](void* ring) { return static_cast<Audio::SpscAudioFrameRing*>(ring)->channel_count(); },
- [](void* ring) { return static_cast<Audio::SpscAudioFrameRing*>(ring)->frames_available(); },
- [](void* ring) { return static_cast<Audio::SpscAudioFrameRing*>(ring)->frames_free(); },
- [](void* ring, Span<float> samples) { return static_cast<Audio::SpscAudioFrameRing*>(ring)->try_pop(samples); },
- [](void* ring, ReadonlySpan<float> samples) { return static_cast<Audio::SpscAudioFrameRing*>(ring)->try_push(samples); },
- }))
-{
-}
-
-}
diff --git a/Libraries/LibWeb/WebAudio/Rendering/AnalyserRenderNode.h b/Libraries/LibWeb/WebAudio/Rendering/AnalyserRenderNode.h
deleted file mode 100644
index 79fb8ae290b..00000000000
--- a/Libraries/LibWeb/WebAudio/Rendering/AnalyserRenderNode.h
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright (c) 2026-present, the Ladybird developers.
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#pragma once
-
-#include <AK/NonnullRefPtr.h>
-#include <AK/Vector.h>
-#include <LibAudio/SpscAudioFrameRing.h>
-#include <LibWeb/WebAudio/Rendering/RenderNode.h>
-
-namespace Web::WebAudio::Rendering {
-
-// https://webaudio.github.io/web-audio-api/#AnalyserNode
-class AnalyserRenderNode final : public RenderNode {
-public:
- AnalyserRenderNode(NodeID, size_t quantum_size, NonnullRefPtr<Audio::SpscAudioFrameRing> time_domain_ring);
-};
-
-}
diff --git a/Libraries/LibWeb/WebAudio/Rendering/AudioBus.cpp b/Libraries/LibWeb/WebAudio/Rendering/AudioBus.cpp
deleted file mode 100644
index 862856da91f..00000000000
--- a/Libraries/LibWeb/WebAudio/Rendering/AudioBus.cpp
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Copyright (c) 2026, Jelle Raaijmakers <[email protected]>
- * Copyright (c) 2026-present, the Ladybird developers.
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#include <AK/StdLibExtras.h>
-#include <LibWeb/WebAudio/Rendering/AudioBus.h>
-#include <LibWeb/WebAudio/RustFFI.h>
-
-namespace Web::WebAudio::Rendering {
-
-AudioBus::AudioBus(size_t channel_count, size_t frame_count)
- : m_bus(RustFFI::web_audio_bus_create(channel_count, frame_count))
-{
-}
-
-AudioBus::AudioBus(AudioBus const& other)
- : m_bus(RustFFI::web_audio_bus_clone(other.m_bus))
-{
-}
-
-AudioBus::AudioBus(AudioBus&& other)
- : m_bus(exchange(other.m_bus, nullptr))
- , m_owned(other.m_owned)
-{
-}
-
-AudioBus& AudioBus::operator=(AudioBus const& other)
-{
- if (this != &other) {
- auto* copy = RustFFI::web_audio_bus_clone(other.m_bus);
- if (m_owned)
- RustFFI::web_audio_bus_destroy(m_bus);
- m_bus = copy;
- m_owned = true;
- }
- return *this;
-}
-
-AudioBus& AudioBus::operator=(AudioBus&& other)
-{
- if (this != &other) {
- if (m_owned)
- RustFFI::web_audio_bus_destroy(m_bus);
- m_bus = exchange(other.m_bus, nullptr);
- m_owned = other.m_owned;
- }
- return *this;
-}
-
-AudioBus::~AudioBus()
-{
- if (m_owned)
- RustFFI::web_audio_bus_destroy(m_bus);
-}
-
-AudioBus AudioBus::borrow(void* bus)
-{
- return AudioBus(bus);
-}
-
-size_t AudioBus::channel_count() const
-{
- return RustFFI::web_audio_bus_channel_count(m_bus);
-}
-
-size_t AudioBus::frame_count() const
-{
- return RustFFI::web_audio_bus_frame_count(m_bus);
-}
-
-Span<float> AudioBus::channel(size_t index)
-{
- Span<float> samples;
- RustFFI::web_audio_bus_channel_mut(m_bus, index, &samples);
- return samples;
-}
-
-ReadonlySpan<float> AudioBus::channel(size_t index) const
-{
- ReadonlySpan<float> samples;
- RustFFI::web_audio_bus_channel(m_bus, index, &samples);
- return samples;
-}
-
-void AudioBus::zero()
-{
- RustFFI::web_audio_bus_zero(m_bus);
-}
-
-bool AudioBus::is_silent() const
-{
- return RustFFI::web_audio_bus_is_silent(m_bus);
-}
-
-void AudioBus::set_channel_count(size_t channel_count)
-{
- RustFFI::web_audio_bus_set_channel_count(m_bus, channel_count);
-}
-
-void AudioBus::copy_from(AudioBus const& source)
-{
- RustFFI::web_audio_bus_copy_from(m_bus, source.m_bus);
-}
-
-void AudioBus::sum_from(AudioBus const& source, Bindings::ChannelInterpretation interpretation)
-{
- RustFFI::web_audio_bus_sum_from(m_bus, source.m_bus, interpretation == Bindings::ChannelInterpretation::Speakers);
-}
-
-}
diff --git a/Libraries/LibWeb/WebAudio/Rendering/AudioBus.h b/Libraries/LibWeb/WebAudio/Rendering/AudioBus.h
deleted file mode 100644
index 36414f966e5..00000000000
--- a/Libraries/LibWeb/WebAudio/Rendering/AudioBus.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (c) 2026, Jelle Raaijmakers <[email protected]>
- * Copyright (c) 2026-present, the Ladybird developers.
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#pragma once
-
-#include <AK/Span.h>
-#include <LibWeb/Bindings/AudioNode.h>
-#include <LibWeb/Export.h>
-
-namespace Web::WebAudio::Rendering {
-
-// A block of audio samples for a single render quantum, holding one buffer of frames per channel.
-class WEB_API AudioBus {
-public:
- AK_ALLOC_WITH_KMALLOC;
-
- AudioBus(size_t channel_count, size_t frame_count);
- AudioBus(AudioBus const&);
- AudioBus(AudioBus&&);
- AudioBus& operator=(AudioBus const&);
- AudioBus& operator=(AudioBus&&);
- ~AudioBus();
-
- size_t channel_count() const;
- size_t frame_count() const;
-
- Span<float> channel(size_t index);
- ReadonlySpan<float> channel(size_t index) const;
-
- void const* rust_bus() const { return m_bus; }
-
- static AudioBus borrow(void*);
-
- void zero();
- bool is_silent() const;
- void set_channel_count(size_t);
- void copy_from(AudioBus const&);
-
- void sum_from(AudioBus const& source, Bindings::ChannelInterpretation);
-
-private:
- explicit AudioBus(void* bus)
- : m_bus(bus)
- , m_owned(false)
- {
- }
- void* m_bus { nullptr };
- bool m_owned { true };
-};
-
-}
diff --git a/Libraries/LibWeb/WebAudio/Rendering/AudioData.cpp b/Libraries/LibWeb/WebAudio/Rendering/AudioData.cpp
deleted file mode 100644
index 633014dcf3a..00000000000
--- a/Libraries/LibWeb/WebAudio/Rendering/AudioData.cpp
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 2026, Jelle Raaijmakers <[email protected]>
- * Copyright (c) 2026-present, the Ladybird developers.
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#include <LibWeb/WebAudio/Rendering/AudioData.h>
-#include <LibWeb/WebAudio/RustFFI.h>
-namespace Web::WebAudio::Rendering {
-
-AudioBufferContents::AudioBufferContents(Vector<Vector<float>> samples, float rate)
- : sample_rate(rate)
-{
- Vector<ReadonlySpan<float>> views;
- for (auto const& channel : samples)
- views.append(channel.span());
- m_data = RustFFI::web_audio_buffer_contents_create(views.span(), rate);
- channels.resize(samples.size());
- for (size_t i = 0; i < samples.size(); ++i)
- RustFFI::web_audio_buffer_contents_channel(m_data, i, &channels[i]);
-}
-AudioBufferContents::AudioBufferContents(void const* data, size_t channel_count, float rate)
- : sample_rate(rate)
- , m_data(data)
-{
- channels.resize(channel_count);
- for (size_t i = 0; i < channel_count; ++i)
- RustFFI::web_audio_buffer_contents_channel(m_data, i, &channels[i]);
-}
-AudioBufferContents::~AudioBufferContents() { RustFFI::web_audio_buffer_contents_destroy(m_data); }
-WaveShaperCurve::WaveShaperCurve(Vector<float> samples)
-{
- m_data = RustFFI::web_audio_wave_shaper_curve_create(samples.span());
- RustFFI::web_audio_wave_shaper_curve_values(m_data, &values);
-}
-WaveShaperCurve::~WaveShaperCurve() { RustFFI::web_audio_wave_shaper_curve_destroy(m_data); }
-PeriodicWaveData::PeriodicWaveData(Vector<float> real_values, Vector<float> imag_values, bool should_normalize)
- : normalize(should_normalize)
-{
- m_data = RustFFI::web_audio_periodic_wave_data_create(real_values.span(), imag_values.span(), should_normalize);
- RustFFI::web_audio_periodic_wave_data_real(m_data, &real);
- RustFFI::web_audio_periodic_wave_data_imag(m_data, &imag);
-}
-PeriodicWaveData::PeriodicWaveData(void const* data, bool should_normalize)
- : normalize(should_normalize)
- , m_data(data)
-{
- RustFFI::web_audio_periodic_wave_data_real(m_data, &real);
- RustFFI::web_audio_periodic_wave_data_imag(m_data, &imag);
-}
-PeriodicWaveData::~PeriodicWaveData() { RustFFI::web_audio_periodic_wave_data_destroy(m_data); }
-
-}
diff --git a/Libraries/LibWeb/WebAudio/Rendering/AudioData.h b/Libraries/LibWeb/WebAudio/Rendering/AudioData.h
deleted file mode 100644
index 6924bfcef04..00000000000
--- a/Libraries/LibWeb/WebAudio/Rendering/AudioData.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (c) 2026, Jelle Raaijmakers <[email protected]>
- * Copyright (c) 2026-present, the Ladybird developers.
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#pragma once
-#include <AK/AtomicRefCounted.h>
-#include <AK/Span.h>
-#include <AK/Vector.h>
-namespace Web::WebAudio::Rendering {
-
-struct AudioBufferContents : public AtomicRefCounted<AudioBufferContents> {
- AudioBufferContents(Vector<Vector<float>> channels, float sample_rate);
- AudioBufferContents(void const* data, size_t channel_count, float sample_rate);
- ~AudioBufferContents();
- size_t length() const { return channels.is_empty() ? 0 : channels.first().size(); }
- double duration() const { return length() / static_cast<double>(sample_rate); }
- void const* rust_data() const { return m_data; }
- Vector<ReadonlySpan<float>> channels;
- float sample_rate { 0 };
-
-private:
- void const* m_data { nullptr };
-};
-struct WaveShaperCurve : public AtomicRefCounted<WaveShaperCurve> {
- explicit WaveShaperCurve(Vector<float> values);
- ~WaveShaperCurve();
- void const* rust_data() const { return m_data; }
- ReadonlySpan<float> values;
-
-private:
- void const* m_data { nullptr };
-};
-struct PeriodicWaveData : public AtomicRefCounted<PeriodicWaveData> {
- PeriodicWaveData(Vector<float> real, Vector<float> imag, bool normalize);
- PeriodicWaveData(void const* data, bool normalize);
- ~PeriodicWaveData();
- void const* rust_data() const { return m_data; }
- ReadonlySpan<float> real;
- ReadonlySpan<float> imag;
- bool normalize { true };
-
-private:
- void const* m_data { nullptr };
-};
-
-}
diff --git a/Libraries/LibWeb/WebAudio/Rendering/AudioWorkletRenderNode.cpp b/Libraries/LibWeb/WebAudio/Rendering/AudioWorkletRenderNode.cpp
deleted file mode 100644
index 2035b8f678c..00000000000
--- a/Libraries/LibWeb/WebAudio/Rendering/AudioWorkletRenderNode.cpp
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (c) 2026-present, the Ladybird developers.
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#include <LibWeb/WebAudio/Rendering/AudioWorkletRenderNode.h>
-#include <LibWeb/WebAudio/RustFFI.h>
-
-namespace Web::WebAudio::Rendering {
-
-static void* create_render_node(NodeID node_id, size_t input_count, size_t output_count, size_t quantum_size, Vector<u32> const& output_channel_capacities, size_t channel_count, Bindings::ChannelCountMode channel_count_mode, Bindings::ChannelInterpretation channel_interpretation, AudioWorkletPipe& pipe, Vector<NonnullRefPtr<RenderAudioParam>> const& params)
-{
- Vector<void const*> native_params;
- for (auto const& param : params)
- native_params.append(param->rust_param());
- return RustFFI::web_audio_node_create_audio_worklet(node_id.value(), input_count, output_count, quantum_size, output_channel_capacities.span(), channel_count, static_cast<RustFFI::ChannelCountMode>(channel_count_mode), static_cast<RustFFI::ChannelInterpretation>(channel_interpretation), pipe.rust_pipe(), native_params.span());
-}
-
-AudioWorkletRenderNode::AudioWorkletRenderNode(NodeID node_id, size_t input_count, size_t output_count, size_t quantum_size,
- Vector<u32> output_channel_capacities,
- size_t channel_count, Bindings::ChannelCountMode channel_count_mode, Bindings::ChannelInterpretation channel_interpretation,
- NonnullRefPtr<AudioWorkletPipe> pipe,
- Vector<NonnullRefPtr<RenderAudioParam>> params)
- : RenderNode(create_render_node(node_id, input_count, output_count, quantum_size, output_channel_capacities, channel_count, channel_count_mode, channel_interpretation, pipe, params))
-{
-}
-
-}
diff --git a/Libraries/LibWeb/WebAudio/Rendering/AudioWorkletRenderNode.h b/Libraries/LibWeb/WebAudio/Rendering/AudioWorkletRenderNode.h
deleted file mode 100644
index b04cfc72638..00000000000
--- a/Libraries/LibWeb/WebAudio/Rendering/AudioWorkletRenderNode.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright (c) 2026-present, the Ladybird developers.
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#pragma once
-
-#include <AK/NonnullRefPtr.h>
-#include <AK/Vector.h>
-#include <LibWeb/WebAudio/Rendering/AudioWorkletPipe.h>
-#include <LibWeb/WebAudio/Rendering/RenderNode.h>
-
-namespace Web::WebAudio::Rendering {
-
-// Script runs on the main-thread pump, `prime_level` quanta behind this render node; this side
-// only exchanges preallocated pipe slots and renders silence on underrun.
-class AudioWorkletRenderNode final : public RenderNode {
-public:
- AudioWorkletRenderNode(NodeID, size_t input_count, size_t output_count, size_t quantum_size,
- Vector<u32> output_channel_capacities,
- size_t channel_count, Bindings::ChannelCountMode, Bindings::ChannelInterpretation,
- NonnullRefPtr<AudioWorkletPipe>,
- Vector<NonnullRefPtr<RenderAudioParam>> params);
-};
-
-}
diff --git a/Libraries/LibWeb/WebAudio/Rendering/BiquadCoefficients.cpp b/Libraries/LibWeb/WebAudio/Rendering/BiquadCoefficients.cpp
deleted file mode 100644
index 1d281b952d6..00000000000
--- a/Libraries/LibWeb/WebAudio/Rendering/BiquadCoefficients.cpp
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (c) 2026, Jelle Raaijmakers <[email protected]>
- * Copyright (c) 2026-present, the Ladybird developers.
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#include <LibWeb/WebAudio/Rendering/BiquadCoefficients.h>
-#include <LibWeb/WebAudio/RustFFI.h>
-
-namespace Web::WebAudio::Rendering {
-
-BiquadCoefficients compute_biquad_coefficients(Bindings::BiquadFilterType type, double normalized_frequency, double q, double gain_db)
-{
- static_assert(to_underlying(Bindings::BiquadFilterType::Lowpass) == to_underlying(RustFFI::BiquadFilterType::Lowpass));
- static_assert(to_underlying(Bindings::BiquadFilterType::Highpass) == to_underlying(RustFFI::BiquadFilterType::Highpass));
- static_assert(to_underlying(Bindings::BiquadFilterType::Bandpass) == to_underlying(RustFFI::BiquadFilterType::Bandpass));
- static_assert(to_underlying(Bindings::BiquadFilterType::Lowshelf) == to_underlying(RustFFI::BiquadFilterType::Lowshelf));
- static_assert(to_underlying(Bindings::BiquadFilterType::Highshelf) == to_underlying(RustFFI::BiquadFilterType::Highshelf));
- static_assert(to_underlying(Bindings::BiquadFilterType::Peaking) == to_underlying(RustFFI::BiquadFilterType::Peaking));
- static_assert(to_underlying(Bindings::BiquadFilterType::Notch) == to_underlying(RustFFI::BiquadFilterType::Notch));
- static_assert(to_underlying(Bindings::BiquadFilterType::Allpass) == to_underlying(RustFFI::BiquadFilterType::Allpass));
- auto coefficients = RustFFI::web_audio_compute_biquad_coefficients(static_cast<RustFFI::BiquadFilterType>(type), normalized_frequency, q, gain_db);
- return { coefficients.b0, coefficients.b1, coefficients.b2, coefficients.a1, coefficients.a2 };
-}
-
-void biquad_frequency_response(BiquadCoefficients const& coefficients, double normalized_frequency, float& magnitude, float& phase)
-{
- RustFFI::BiquadCoefficients rust_coefficients { coefficients.b0, coefficients.b1, coefficients.b2, coefficients.a1, coefficients.a2 };
- RustFFI::web_audio_biquad_frequency_response(&rust_coefficients, normalized_frequency, &magnitude, &phase);
-}
-
-}
diff --git a/Libraries/LibWeb/WebAudio/Rendering/BiquadCoefficients.h b/Libraries/LibWeb/WebAudio/Rendering/BiquadCoefficients.h
deleted file mode 100644
index 01580aa5ef9..00000000000
--- a/Libraries/LibWeb/WebAudio/Rendering/BiquadCoefficients.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (c) 2026, Jelle Raaijmakers <[email protected]>
- * Copyright (c) 2026-present, the Ladybird developers.
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#pragma once
-
-#include <LibWeb/Bindings/BiquadFilterNode.h>
-#include <LibWeb/Export.h>
-
-namespace Web::WebAudio::Rendering {
-
-// Normalized biquad transfer function coefficients, with a0 divided out.
-// https://webaudio.github.io/web-audio-api/#filters-characteristics
-struct BiquadCoefficients {
- double b0 { 0 };
- double b1 { 0 };
- double b2 { 0 };
- double a1 { 0 };
- double a2 { 0 };
-};
-
-// Computes filter coefficients from the BiquadFilterNode's computed parameter values. frequency is expected to already
-// include the detune factor and be given as a fraction of the Nyquist frequency, in the range [0, 1].
-WEB_API BiquadCoefficients compute_biquad_coefficients(Bindings::BiquadFilterType, double normalized_frequency, double q, double gain_db);
-
-// Evaluates the transfer function's magnitude and phase at the given frequency, given as a fraction of the Nyquist
-// frequency in the range [0, 1].
-WEB_API void biquad_frequency_response(BiquadCoefficients const&, double normalized_frequency, float& magnitude, float& phase);
-
-}
diff --git a/Libraries/LibWeb/WebAudio/Rendering/ConvolverKernel.cpp b/Libraries/LibWeb/WebAudio/Rendering/ConvolverKernel.cpp
deleted file mode 100644
index 1b5272cb3a0..00000000000
--- a/Libraries/LibWeb/WebAudio/Rendering/ConvolverKernel.cpp
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright (c) 2026, Jelle Raaijmakers <[email protected]>
- * Copyright (c) 2026-present, the Ladybird developers.
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#include <LibWeb/WebAudio/Rendering/ConvolverKernel.h>
-#include <LibWeb/WebAudio/RustFFI.h>
-
-namespace Web::WebAudio::Rendering {
-
-RefPtr<ConvolverKernel> ConvolverKernel::create(AudioBufferContents const& contents, size_t partition_size, bool normalize)
-{
- Vector<ReadonlySpan<float>> channels;
- channels.ensure_capacity(contents.channels.size());
- for (auto const& channel : contents.channels)
- channels.unchecked_append(channel);
- auto const* kernel = RustFFI::web_audio_convolver_kernel_create(channels.span(), contents.sample_rate, partition_size, normalize);
- if (!kernel)
- return nullptr;
- return adopt_ref(*new ConvolverKernel(kernel));
-}
-
-ConvolverKernel::~ConvolverKernel()
-{
- RustFFI::web_audio_convolver_kernel_destroy(m_kernel);
-}
-
-size_t ConvolverKernel::channel_count() const
-{
- return RustFFI::web_audio_convolver_kernel_channel_count(m_kernel);
-}
-
-size_t ConvolverKernel::partition_count() const
-{
- return RustFFI::web_audio_convolver_kernel_partition_count(m_kernel);
-}
-
-size_t ConvolverKernel::bin_count() const
-{
- return RustFFI::web_audio_convolver_kernel_bin_count(m_kernel);
-}
-
-ReadonlySpan<float> ConvolverKernel::head(size_t channel) const
-{
- ReadonlySpan<float> samples;
- RustFFI::web_audio_convolver_kernel_head(m_kernel, channel, &samples);
- return samples;
-}
-
-ReadonlySpan<float> ConvolverKernel::partition_real(size_t channel, size_t partition) const
-{
- ReadonlySpan<float> samples;
- RustFFI::web_audio_convolver_kernel_partition_real(m_kernel, channel, partition, &samples);
- return samples;
-}
-
-ReadonlySpan<float> ConvolverKernel::partition_imag(size_t channel, size_t partition) const
-{
- ReadonlySpan<float> samples;
- RustFFI::web_audio_convolver_kernel_partition_imag(m_kernel, channel, partition, &samples);
- return samples;
-}
-
-NonnullRefPtr<ConvolverDelayLine> ConvolverDelayLine::create(ConvolverKernel const& kernel)
-{
- return adopt_ref(*new ConvolverDelayLine(RustFFI::web_audio_convolver_delay_line_create(kernel.m_kernel)));
-}
-
-ConvolverDelayLine::~ConvolverDelayLine()
-{
- RustFFI::web_audio_convolver_delay_line_destroy(m_delay_line);
-}
-
-size_t ConvolverDelayLine::length() const
-{
- return RustFFI::web_audio_convolver_delay_line_length(m_delay_line);
-}
-
-Span<float> ConvolverDelayLine::real(size_t channel)
-{
- Span<float> samples;
- RustFFI::web_audio_convolver_delay_line_real(m_delay_line, channel, &samples);
- return samples;
-}
-
-Span<float> ConvolverDelayLine::imag(size_t channel)
-{
- Span<float> samples;
- RustFFI::web_audio_convolver_delay_line_imag(m_delay_line, channel, &samples);
- return samples;
-}
-
-}
diff --git a/Libraries/LibWeb/WebAudio/Rendering/ConvolverKernel.h b/Libraries/LibWeb/WebAudio/Rendering/ConvolverKernel.h
deleted file mode 100644
index 4cbd27d4b18..00000000000
--- a/Libraries/LibWeb/WebAudio/Rendering/ConvolverKernel.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (c) 2026, Jelle Raaijmakers <[email protected]>
- * Copyright (c) 2026-present, the Ladybird developers.
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#pragma once
-
-#include <AK/AtomicRefCounted.h>
-#include <AK/NonnullRefPtr.h>
-#include <AK/RefPtr.h>
-#include <AK/Span.h>
-#include <LibWeb/WebAudio/Rendering/AudioData.h>
-
-namespace Web::WebAudio::Rendering {
-
-class ConvolverKernel : public AtomicRefCounted<ConvolverKernel> {
-public:
- static RefPtr<ConvolverKernel> create(AudioBufferContents const&, size_t partition_size, bool normalize);
- ~ConvolverKernel();
-
- void const* rust_kernel() const { return m_kernel; }
- size_t channel_count() const;
- size_t partition_count() const;
- size_t bin_count() const;
- ReadonlySpan<float> head(size_t channel) const;
- ReadonlySpan<float> partition_real(size_t channel, size_t partition) const;
- ReadonlySpan<float> partition_imag(size_t channel, size_t partition) const;
-
-private:
- friend class ConvolverDelayLine;
-
- explicit ConvolverKernel(void const* kernel)
- : m_kernel(kernel)
- {
- }
-
- void const* m_kernel { nullptr };
-};
-
-class ConvolverDelayLine : public AtomicRefCounted<ConvolverDelayLine> {
-public:
- static constexpr size_t MAX_CHANNEL_COUNT = 2;
-
- static NonnullRefPtr<ConvolverDelayLine> create(ConvolverKernel const&);
- ~ConvolverDelayLine();
-
- void const* rust_delay_line() const { return m_delay_line; }
- size_t length() const;
- Span<float> real(size_t channel);
- Span<float> imag(size_t channel);
-
-private:
- explicit ConvolverDelayLine(void const* delay_line)
- : m_delay_line(delay_line)
- {
- }
-
- void const* m_delay_line { nullptr };
-};
-
-}
diff --git a/Libraries/LibWeb/WebAudio/Rendering/FFT.cpp b/Libraries/LibWeb/WebAudio/Rendering/FFT.cpp
deleted file mode 100644
index 03354dd0939..00000000000
--- a/Libraries/LibWeb/WebAudio/Rendering/FFT.cpp
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (c) 2026-present, the Ladybird developers.
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#include <LibWeb/WebAudio/Rendering/FFT.h>
-#include <LibWeb/WebAudio/RustFFI.h>
-
-namespace Web::WebAudio::Rendering {
-
-FFT::FFT(size_t size)
- : m_size(size)
- , m_fft(RustFFI::web_audio_fft_create(size))
-{
-}
-
-FFT::~FFT()
-{
- RustFFI::web_audio_fft_destroy(m_fft);
-}
-
-void FFT::transform(Span<float> re, Span<float> im, FFTDirection direction) const
-{
- static_assert(to_underlying(FFTDirection::Forward) == to_underlying(RustFFI::FFTDirection::Forward));
- static_assert(to_underlying(FFTDirection::Inverse) == to_underlying(RustFFI::FFTDirection::Inverse));
- RustFFI::web_audio_fft_transform(m_fft, re, im, static_cast<RustFFI::FFTDirection>(direction));
-}
-
-}
diff --git a/Libraries/LibWeb/WebAudio/Rendering/FFT.h b/Libraries/LibWeb/WebAudio/Rendering/FFT.h
deleted file mode 100644
index e73336c415a..00000000000
--- a/Libraries/LibWeb/WebAudio/Rendering/FFT.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (c) 2026-present, the Ladybird developers.
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#pragma once
-
-#include <AK/Noncopyable.h>
-#include <AK/Span.h>
-
-namespace Web::WebAudio::Rendering {
-
-enum class FFTDirection {
- Forward,
- Inverse,
-};
-
-class FFT {
-public:
- AK_MAKE_NONCOPYABLE(FFT);
- AK_ALLOC_WITH_KMALLOC;
-
- explicit FFT(size_t size);
- ~FFT();
-
- size_t size() const { return m_size; }
-
- void transform(Span<float> re, Span<float> im, FFTDirection = FFTDirection::Forward) const;
-
-private:
- size_t m_size { 0 };
- void* m_fft { nullptr };
-};
-
-}
diff --git a/Libraries/LibWeb/WebAudio/Rendering/MediaStreamDestinationRenderNode.cpp b/Libraries/LibWeb/WebAudio/Rendering/MediaStreamDestinationRenderNode.cpp
deleted file mode 100644
index 778cffb25b1..00000000000
--- a/Libraries/LibWeb/WebAudio/Rendering/MediaStreamDestinationRenderNode.cpp
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (c) 2026-present, the Ladybird developers.
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#include <LibCore/EventLoop.h>
-#include <LibWeb/WebAudio/Rendering/MediaStreamDestinationRenderNode.h>
-#include <LibWeb/WebAudio/RustFFI.h>
-
-namespace Web::WebAudio::Rendering {
-
-struct DestinationCallbackService : AtomicRefCounted<DestinationCallbackService> {
- DestinationCallbackService(NonnullRefPtr<MediaStreamDestinationSharedState> state, Core::EventLoop& loop)
- : shared_state(move(state))
- , event_loop(loop)
- {
- }
- NonnullRefPtr<MediaStreamDestinationSharedState> shared_state;
- Core::EventLoop& event_loop;
-};
-
-static void* create_render_node(NodeID node_id, size_t quantum_size, size_t channel_count, NonnullRefPtr<MediaStreamDestinationSharedState> shared_state, Core::EventLoop& event_loop)
-{
- auto service = adopt_ref(*new DestinationCallbackService(shared_state, event_loop));
- RustFFI::PipeCallbacks callbacks {
- { service.ptr(), [](void* service) { static_cast<DestinationCallbackService*>(service)->ref(); }, [](void* service) { static_cast<DestinationCallbackService*>(service)->unref(); } },
- [](void* service, void* task, void (*invoke)(void*)) {
- static_cast<DestinationCallbackService*>(service)->event_loop.deferred_invoke([task, invoke] { invoke(task); });
- },
- [](void* service) {
- auto& shared_state = *static_cast<DestinationCallbackService*>(service)->shared_state;
- if (shared_state.drain)
- shared_state.drain();
- },
- [](void*, size_t, u64) { return false; },
- };
- return RustFFI::web_audio_node_create_media_stream_destination(node_id.value(), quantum_size, channel_count,
- { shared_state->ring.ptr(), [](void* ring) { static_cast<Audio::SpscAudioFrameRing*>(ring)->ref(); }, [](void* ring) { static_cast<Audio::SpscAudioFrameRing*>(ring)->unref(); } },
- {
- [](void* ring) { return static_cast<Audio::SpscAudioFrameRing*>(ring)->channel_count(); },
- [](void* ring) { return static_cast<Audio::SpscAudioFrameRing*>(ring)->frames_available(); },
- [](void* ring) { return static_cast<Audio::SpscAudioFrameRing*>(ring)->frames_free(); },
- [](void* ring, Span<float> samples) { return static_cast<Audio::SpscAudioFrameRing*>(ring)->try_pop(samples); },
- [](void* ring, ReadonlySpan<float> samples) { return static_cast<Audio::SpscAudioFrameRing*>(ring)->try_push(samples); },
- },
- callbacks);
-}
-
-MediaStreamDestinationRenderNode::MediaStreamDestinationRenderNode(NodeID node_id, size_t quantum_size, size_t channel_count, NonnullRefPtr<MediaStreamDestinationSharedState> shared_state, Core::EventLoop& control_thread_event_loop)
- : RenderNode(create_render_node(node_id, quantum_size, channel_count, move(shared_state), control_thread_event_loop))
-{
-}
-
-}
diff --git a/Libraries/LibWeb/WebAudio/Rendering/MediaStreamDestinationRenderNode.h b/Libraries/LibWeb/WebAudio/Rendering/MediaStreamDestinationRenderNode.h
deleted file mode 100644
index ea1dba0e453..00000000000
--- a/Libraries/LibWeb/WebAudio/Rendering/MediaStreamDestinationRenderNode.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (c) 2026-present, the Ladybird developers.
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#pragma once
-
-#include <AK/Atomic.h>
-#include <AK/AtomicRefCounted.h>
-#include <AK/Function.h>
-#include <AK/NonnullRefPtr.h>
-#include <AK/Vector.h>
-#include <LibAudio/SpscAudioFrameRing.h>
-#include <LibCore/Forward.h>
-#include <LibWeb/WebAudio/Rendering/RenderNode.h>
-
-namespace Web::WebAudio::Rendering {
-
-struct MediaStreamDestinationSharedState final : public AtomicRefCounted<MediaStreamDestinationSharedState> {
- explicit MediaStreamDestinationSharedState(NonnullRefPtr<Audio::SpscAudioFrameRing> ring)
- : ring(move(ring))
- {
- }
-
- NonnullRefPtr<Audio::SpscAudioFrameRing> ring;
-
- // Only the control thread invokes or clears this callback.
- Function<void()> drain;
-};
-
-// https://webaudio.github.io/web-audio-api/#MediaStreamAudioDestinationNode
-class MediaStreamDestinationRenderNode final : public RenderNode {
-public:
- MediaStreamDestinationRenderNode(NodeID, size_t quantum_size, size_t channel_count, NonnullRefPtr<MediaStreamDestinationSharedState>, Core::EventLoop& control_thread_event_loop);
-};
-
-}
diff --git a/Libraries/LibWeb/WebAudio/Rendering/MediaStreamSourceRenderNode.cpp b/Libraries/LibWeb/WebAudio/Rendering/MediaStreamSourceRenderNode.cpp
deleted file mode 100644
index 817ad316575..00000000000
--- a/Libraries/LibWeb/WebAudio/Rendering/MediaStreamSourceRenderNode.cpp
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright (c) 2026-present, the Ladybird developers.
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#include <LibWeb/WebAudio/Rendering/MediaStreamSourceRenderNode.h>
-#include <LibWeb/WebAudio/RustFFI.h>
-
-namespace Web::WebAudio::Rendering {
-
-MediaStreamSourceRenderNode::MediaStreamSourceRenderNode(NodeID node_id, size_t quantum_size)
- : RenderNode(RustFFI::web_audio_node_create_media_stream_source(node_id.value(), quantum_size, {
- [](void* ring) { return static_cast<Audio::SpscAudioFrameRing*>(ring)->channel_count(); },
- [](void* ring) { return static_cast<Audio::SpscAudioFrameRing*>(ring)->frames_available(); },
- [](void* ring) { return static_cast<Audio::SpscAudioFrameRing*>(ring)->frames_free(); },
- [](void* ring, Span<float> samples) { return static_cast<Audio::SpscAudioFrameRing*>(ring)->try_pop(samples); },
- [](void* ring, ReadonlySpan<float> samples) { return static_cast<Audio::SpscAudioFrameRing*>(ring)->try_push(samples); },
- }))
-{
-}
-
-}
diff --git a/Libraries/LibWeb/WebAudio/Rendering/MediaStreamSourceRenderNode.h b/Libraries/LibWeb/WebAudio/Rendering/MediaStreamSourceRenderNode.h
deleted file mode 100644
index 6c9541fb64a..00000000000
--- a/Libraries/LibWeb/WebAudio/Rendering/MediaStreamSourceRenderNode.h
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright (c) 2026-present, the Ladybird developers.
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#pragma once
-
-#include <AK/RefPtr.h>
-#include <AK/Vector.h>
-#include <LibAudio/SpscAudioFrameRing.h>
-#include <LibWeb/WebAudio/Rendering/RenderNode.h>
-
-namespace Web::WebAudio::Rendering {
-
-// https://webaudio.github.io/web-audio-api/#MediaStreamAudioSourceNode
-class MediaStreamSourceRenderNode final : public RenderNode {
-public:
- MediaStreamSourceRenderNode(NodeID, size_t quantum_size);
-};
-
-}
diff --git a/Libraries/LibWeb/WebAudio/Rendering/NodeMessage.h b/Libraries/LibWeb/WebAudio/Rendering/NodeMessage.h
deleted file mode 100644
index a872da69fc0..00000000000
--- a/Libraries/LibWeb/WebAudio/Rendering/NodeMessage.h
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Copyright (c) 2025-2026, Ben Eidson <[email protected]>
- * Copyright (c) 2026, Jelle Raaijmakers <[email protected]>
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#pragma once
-
-#include <AK/Optional.h>
-#include <AK/RefPtr.h>
-#include <AK/Variant.h>
-#include <LibAudio/SpscAudioFrameRing.h>
-#include <LibWeb/Bindings/BiquadFilterNode.h>
-#include <LibWeb/Bindings/OscillatorNode.h>
-#include <LibWeb/Bindings/PannerNode.h>
-#include <LibWeb/Bindings/WaveShaperNode.h>
-#include <LibWeb/WebAudio/Rendering/AudioData.h>
-#include <LibWeb/WebAudio/Rendering/ConvolverKernel.h>
-#include <LibWeb/WebAudio/Types.h>
-
-namespace Web::WebAudio {
-
-struct StartSource {
- NodeID node_id { 0 };
- double when { 0.0 };
-};
-
-struct StopSource {
- NodeID node_id { 0 };
- double when { 0.0 };
-};
-
-// Starts an AudioBufferSourceNode, transferring the acquired buffer contents along with the playback range.
-struct StartBufferSource {
- NodeID node_id { 0 };
- double when { 0.0 };
- double offset { 0.0 };
- Optional<double> duration;
- RefPtr<Rendering::AudioBufferContents> buffer;
-};
-
-// Updates an AudioBufferSourceNode's loop parameters, and its buffer if it was assigned after the node started.
-struct SetBufferSourceParameters {
- NodeID node_id { 0 };
- bool loop { false };
- double loop_start { 0.0 };
- double loop_end { 0.0 };
- RefPtr<Rendering::AudioBufferContents> buffer;
- bool update_buffer { false };
-};
-
-struct SetOscillatorWaveform {
- NodeID node_id { 0 };
- Bindings::OscillatorType type { Bindings::OscillatorType::Sine };
- RefPtr<Rendering::PeriodicWaveData> periodic_wave;
-};
-
-struct SetBiquadFilterType {
- NodeID node_id { 0 };
- Bindings::BiquadFilterType type { Bindings::BiquadFilterType::Lowpass };
-};
-
-struct SetConvolverKernel {
- NodeID node_id { 0 };
- RefPtr<Rendering::ConvolverKernel> kernel;
- RefPtr<Rendering::ConvolverDelayLine> delay_line;
-};
-
-struct SetPannerParameters {
- NodeID node_id { 0 };
- Bindings::PanningModelType panning_model { Bindings::PanningModelType::Equalpower };
- Bindings::DistanceModelType distance_model { Bindings::DistanceModelType::Inverse };
- double ref_distance { 1 };
- double max_distance { 10000 };
- double rolloff_factor { 1 };
- double cone_inner_angle { 360 };
- double cone_outer_angle { 360 };
- double cone_outer_gain { 0 };
-};
-
-struct SetWaveShaperParameters {
- NodeID node_id { 0 };
- RefPtr<Rendering::WaveShaperCurve> curve;
- Bindings::OverSampleType oversample { Bindings::OverSampleType::None };
-};
-
-// Attaches the ring buffer that carries a MediaStreamTrack's audio into a
-// MediaStreamAudioSourceNode's render node. Shipped as a message rather than a constructor
-// argument so the ring can be replaced without rebuilding the render node.
-struct SetMediaStreamSourceRing {
- NodeID node_id { 0 };
- RefPtr<Audio::SpscAudioFrameRing> ring;
- u32 channel_count { 0 };
-};
-
-// A control message that updates the state of a single render node.
-using NodeMessage = Variant<
- SetBiquadFilterType,
- SetBufferSourceParameters,
- SetConvolverKernel,
- SetMediaStreamSourceRing,
- SetOscillatorWaveform,
- SetPannerParameters,
- SetWaveShaperParameters,
- StartBufferSource,
- StartSource,
- StopSource>;
-
-inline NodeID node_message_target(NodeMessage const& message)
-{
- return message.visit([](auto const& node_message) { return node_message.node_id; });
-}
-
-}
diff --git a/Libraries/LibWeb/WebAudio/Rendering/OfflineAudioRenderer.cpp b/Libraries/LibWeb/WebAudio/Rendering/OfflineAudioRenderer.cpp
index 117f7a152b4..7f67fef1148 100644
--- a/Libraries/LibWeb/WebAudio/Rendering/OfflineAudioRenderer.cpp
+++ b/Libraries/LibWeb/WebAudio/Rendering/OfflineAudioRenderer.cpp
@@ -71,7 +71,6 @@ void OfflineAudioRenderer::start_rendering() { RustFFI::web_audio_offline_render
void OfflineAudioRenderer::stop() { RustFFI::web_audio_offline_renderer_stop(m_renderer); }
bool OfflineAudioRenderer::request_suspend(u64 frame) { return RustFFI::web_audio_offline_renderer_request_suspend(m_renderer, frame); }
void OfflineAudioRenderer::resume() { RustFFI::web_audio_offline_renderer_resume(m_renderer); }
-bool OfflineAudioRenderer::is_rendering_started() const { return RustFFI::web_audio_offline_renderer_started(m_renderer); }
u64 OfflineAudioRenderer::frames_rendered() const { return RustFFI::web_audio_offline_renderer_frames_rendered(m_renderer); }
}
diff --git a/Libraries/LibWeb/WebAudio/Rendering/OfflineAudioRenderer.h b/Libraries/LibWeb/WebAudio/Rendering/OfflineAudioRenderer.h
index a5d9e6911ac..ca8234e9d53 100644
--- a/Libraries/LibWeb/WebAudio/Rendering/OfflineAudioRenderer.h
+++ b/Libraries/LibWeb/WebAudio/Rendering/OfflineAudioRenderer.h
@@ -18,8 +18,6 @@
#include <AK/Vector.h>
#include <LibThreading/Thread.h>
#include <LibWeb/Export.h>
-#include <LibWeb/WebAudio/ControlMessageQueue.h>
-#include <LibWeb/WebAudio/Rendering/RenderGraph.h>
#include <LibWeb/WebAudio/Types.h>
namespace Core {
@@ -59,7 +57,6 @@ public:
bool request_suspend(u64 frame);
void resume();
- bool is_rendering_started() const;
u64 frames_rendered() const;
// Only safe to access on the control thread after the completion callback was invoked.
diff --git a/Libraries/LibWeb/WebAudio/Rendering/RealtimeAudioRenderer.h b/Libraries/LibWeb/WebAudio/Rendering/RealtimeAudioRenderer.h
index 66064d853c7..8c2cbbcb53a 100644
--- a/Libraries/LibWeb/WebAudio/Rendering/RealtimeAudioRenderer.h
+++ b/Libraries/LibWeb/WebAudio/Rendering/RealtimeAudioRenderer.h
@@ -20,8 +20,6 @@
#include <LibCore/Forward.h>
#include <LibMedia/Forward.h>
#include <LibWeb/Export.h>
-#include <LibWeb/WebAudio/ControlMessageQueue.h>
-#include <LibWeb/WebAudio/Rendering/RenderGraph.h>
#include <LibWeb/WebAudio/Types.h>
namespace Web::WebAudio::Rendering {
diff --git a/Libraries/LibWeb/WebAudio/Rendering/RenderGraph.cpp b/Libraries/LibWeb/WebAudio/Rendering/RenderGraph.cpp
deleted file mode 100644
index f97e3af4695..00000000000
--- a/Libraries/LibWeb/WebAudio/Rendering/RenderGraph.cpp
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 2026, Jelle Raaijmakers <[email protected]>
- * Copyright (c) 2026-present, the Ladybird developers.
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#include <LibWeb/WebAudio/Rendering/RenderGraph.h>
-#include <LibWeb/WebAudio/RustFFI.h>
-namespace Web::WebAudio::Rendering {
-
-RenderGraph::RenderGraph()
- : m_graph(RustFFI::web_audio_graph_create())
-{
-}
-RenderGraph::~RenderGraph()
-{
- if (m_owned)
- RustFFI::web_audio_graph_destroy(m_graph);
-}
-void RenderGraph::apply_control_messages(void* messages) { RustFFI::web_audio_graph_apply_control_messages(m_graph, messages); }
-void RenderGraph::set_destination(NodeID node) { RustFFI::web_audio_graph_set_destination(m_graph, node.value()); }
-void RenderGraph::render_quantum(RenderContext const& context)
-{
- RustFFI::RenderContext rust_context { context.sample_rate, context.quantum_size, context.quantum_start_frame };
- RustFFI::web_audio_graph_render_quantum(m_graph, &rust_context);
-}
-Optional<AudioBus> RenderGraph::pull_output(NodeID source, size_t output_index, RenderContext const& context)
-{
- RustFFI::RenderContext rust_context { context.sample_rate, context.quantum_size, context.quantum_start_frame };
- auto* bus = RustFFI::web_audio_graph_pull_output(m_graph, source.value(), output_index, &rust_context);
- if (!bus)
- return {};
- return AudioBus::borrow(bus);
-}
-Optional<AudioBus> RenderGraph::destination_output()
-{
- auto* bus = RustFFI::web_audio_graph_destination_output(m_graph);
- if (!bus)
- return {};
- return AudioBus::borrow(bus);
-}
-Vector<NodeID> RenderGraph::take_ended_nodes()
-{
- Vector<NodeID> nodes;
- RustFFI::web_audio_graph_take_ended_nodes(m_graph, &nodes, [](void* context, ReadonlySpan<u64> ended) {
- auto& nodes = *static_cast<Vector<NodeID>*>(context);
- for (auto node : ended)
- nodes.append(NodeID { node });
- });
- return nodes;
-}
-
-}
diff --git a/Libraries/LibWeb/WebAudio/Rendering/RenderGraph.h b/Libraries/LibWeb/WebAudio/Rendering/RenderGraph.h
deleted file mode 100644
index 39df1e072ec..00000000000
--- a/Libraries/LibWeb/WebAudio/Rendering/RenderGraph.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (c) 2026, Jelle Raaijmakers <[email protected]>
- * Copyright (c) 2026-present, the Ladybird developers.
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#pragma once
-#include <AK/Optional.h>
-#include <AK/Vector.h>
-#include <LibWeb/Export.h>
-#include <LibWeb/WebAudio/Rendering/RenderNode.h>
-namespace Web::WebAudio::Rendering {
-
-class WEB_API RenderGraph {
- AK_MAKE_NONCOPYABLE(RenderGraph);
- AK_MAKE_NONMOVABLE(RenderGraph);
-
-public:
- RenderGraph();
- RenderGraph(void* graph, bool owned)
- : m_graph(graph)
- , m_owned(owned)
- {
- }
- ~RenderGraph();
- void apply_control_messages(void* messages);
- void render_quantum(RenderContext const&);
- Optional<AudioBus> pull_output(NodeID source, size_t output_index, RenderContext const&);
- Optional<AudioBus> destination_output();
- void set_destination(NodeID);
- Vector<NodeID> take_ended_nodes();
- void* rust_graph() const { return m_graph; }
-
-private:
- void* m_graph { nullptr };
- bool m_owned { true };
-};
-
-}
diff --git a/Libraries/LibWeb/WebAudio/Rendering/RenderNode.cpp b/Libraries/LibWeb/WebAudio/Rendering/RenderNode.cpp
deleted file mode 100644
index 8da587bca93..00000000000
--- a/Libraries/LibWeb/WebAudio/Rendering/RenderNode.cpp
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright (c) 2026, Jelle Raaijmakers <[email protected]>
- * Copyright (c) 2026-present, the Ladybird developers.
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#include <LibWeb/WebAudio/Rendering/RenderGraph.h>
-#include <LibWeb/WebAudio/Rendering/RenderNode.h>
-#include <LibWeb/WebAudio/RustFFI.h>
-namespace Web::WebAudio::Rendering {
-
-RenderAudioParam::RenderAudioParam(NonnullRefPtr<AudioParamTimeline> timeline, float min_value, float max_value, Bindings::AutomationRate automation_rate)
- : m_param(RustFFI::web_audio_render_param_create(timeline->rust_timeline(), min_value, max_value, static_cast<RustFFI::AutomationRate>(automation_rate)))
-{
- static_assert(to_underlying(Bindings::AutomationRate::ARate) == to_underlying(RustFFI::AutomationRate::ARate));
- static_assert(to_underlying(Bindings::AutomationRate::KRate) == to_underlying(RustFFI::AutomationRate::KRate));
-}
-
-RenderAudioParam::RenderAudioParam(void const* param)
- : m_param(param)
-{
-}
-
-RenderAudioParam::~RenderAudioParam()
-{
- RustFFI::web_audio_render_param_destroy(m_param);
-}
-
-void RenderAudioParam::set_automation_rate(Bindings::AutomationRate rate)
-{
- RustFFI::web_audio_render_param_set_automation_rate(m_param, static_cast<RustFFI::AutomationRate>(rate));
-}
-
-Bindings::AutomationRate RenderAudioParam::automation_rate() const
-{
- return static_cast<Bindings::AutomationRate>(RustFFI::web_audio_render_param_automation_rate(m_param));
-}
-
-void RenderAudioParam::clear_inputs()
-{
- RustFFI::web_audio_render_param_clear_inputs(m_param);
-}
-
-void RenderAudioParam::add_input(NodeID source, size_t output_index)
-{
- RustFFI::web_audio_render_param_add_input(m_param, source.value(), output_index);
-}
-
-void RenderAudioParam::compute(RenderGraph& graph, RenderContext const& context, Span<float> output)
-{
- RustFFI::RenderContext rust_context { context.sample_rate, context.quantum_size, context.quantum_start_frame };
- RustFFI::web_audio_render_param_compute(m_param, &graph, [](void* graph, u64 source, size_t output_index, RustFFI::RenderContext const* context) -> void const* {
- RenderContext render_context { context->sample_rate, context->quantum_size, context->quantum_start_frame };
- auto bus = static_cast<RenderGraph*>(graph)->pull_output(source, output_index, render_context);
- return bus.has_value() ? bus->rust_bus() : nullptr; }, &rust_context, output);
-}
-
-RenderNode::RenderNode(void* node)
- : m_node(node)
-{
-}
-RenderNode::~RenderNode()
-{
- if (m_owned)
- RustFFI::web_audio_node_destroy(m_node);
-}
-void* RenderNode::release_rust_node()
-{
- m_owned = false;
- return m_node;
-}
-NodeID RenderNode::node_id() const { return RustFFI::web_audio_node_id(m_node); }
-size_t RenderNode::input_count() const { return RustFFI::web_audio_node_input_count(m_node); }
-size_t RenderNode::output_count() const { return RustFFI::web_audio_node_output_count(m_node); }
-AudioBus RenderNode::output(size_t index) const { return AudioBus::borrow(RustFFI::web_audio_node_output(m_node, index)); }
-size_t RenderNode::channel_count() const { return RustFFI::web_audio_node_channel_count(m_node); }
-Bindings::ChannelCountMode RenderNode::channel_count_mode() const { return static_cast<Bindings::ChannelCountMode>(RustFFI::web_audio_node_channel_count_mode(m_node)); }
-Bindings::ChannelInterpretation RenderNode::channel_interpretation() const { return static_cast<Bindings::ChannelInterpretation>(RustFFI::web_audio_node_channel_interpretation(m_node)); }
-void RenderNode::set_channel_count(size_t count) { RustFFI::web_audio_node_set_channel_count(m_node, count); }
-void RenderNode::set_channel_count_mode(Bindings::ChannelCountMode mode) { RustFFI::web_audio_node_set_channel_count_mode(m_node, static_cast<RustFFI::ChannelCountMode>(mode)); }
-void RenderNode::set_channel_interpretation(Bindings::ChannelInterpretation interpretation) { RustFFI::web_audio_node_set_channel_interpretation(m_node, static_cast<RustFFI::ChannelInterpretation>(interpretation)); }
-size_t RenderNode::outgoing_node_connection_count() const { return RustFFI::web_audio_node_outgoing_node_connection_count(m_node); }
-size_t RenderNode::outgoing_param_connection_count() const { return RustFFI::web_audio_node_outgoing_param_connection_count(m_node); }
-bool RenderNode::has_input_connections(size_t input) const { return RustFFI::web_audio_node_has_input_connections(m_node, input); }
-AudioBus RenderNode::pull_input(RenderGraph& graph, RenderContext const& context, size_t input_index)
-{
- RustFFI::RenderContext render_context { context.sample_rate, context.quantum_size, context.quantum_start_frame };
- return AudioBus::borrow(const_cast<void*>(RustFFI::web_audio_node_pull_input(m_node, graph.rust_graph(), &render_context, input_index)));
-}
-
-}
diff --git a/Libraries/LibWeb/WebAudio/Rendering/RenderNode.h b/Libraries/LibWeb/WebAudio/Rendering/RenderNode.h
deleted file mode 100644
index 22276fcbd6b..00000000000
--- a/Libraries/LibWeb/WebAudio/Rendering/RenderNode.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright (c) 2026, Jelle Raaijmakers <[email protected]>
- * Copyright (c) 2026-present, the Ladybird developers.
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#pragma once
-#include <AK/AtomicRefCounted.h>
-#include <AK/Function.h>
-#include <AK/NonnullRefPtr.h>
-#include <AK/Vector.h>
-#include <LibWeb/Bindings/AudioParam.h>
-#include <LibWeb/Export.h>
-#include <LibWeb/WebAudio/AudioParamTimeline.h>
-#include <LibWeb/WebAudio/Rendering/AudioBus.h>
-#include <LibWeb/WebAudio/Rendering/NodeMessage.h>
-#include <LibWeb/WebAudio/Types.h>
-namespace Web::WebAudio::Rendering {
-
-class RenderGraph;
-struct RenderContext {
- double sample_rate { 0 };
- size_t quantum_size { 0 };
- u64 quantum_start_frame { 0 };
- double quantum_start_time() const { return quantum_start_frame / sample_rate; }
- double sample_period() const { return 1 / sample_rate; }
- double frame_time(size_t frame) const { return (quantum_start_frame + frame) / sample_rate; }
-};
-class WEB_API RenderAudioParam : public AtomicRefCounted<RenderAudioParam> {
-public:
- RenderAudioParam(NonnullRefPtr<AudioParamTimeline> timeline, float min_value, float max_value, Bindings::AutomationRate);
-
- explicit RenderAudioParam(void const* param);
- ~RenderAudioParam();
-
- void set_automation_rate(Bindings::AutomationRate);
- Bindings::AutomationRate automation_rate() const;
-
- void compute(RenderGraph&, RenderContext const&, Span<float> output);
-
- void const* rust_param() const { return m_param; }
-
- void clear_inputs();
- void add_input(NodeID source, size_t output_index);
-
-private:
- void const* m_param { nullptr };
-};
-
-class WEB_API RenderNode {
- AK_MAKE_NONCOPYABLE(RenderNode);
- AK_MAKE_NONMOVABLE(RenderNode);
-
-public:
- AK_ALLOC_WITH_KMALLOC;
- virtual ~RenderNode();
- NodeID node_id() const;
- size_t input_count() const;
- size_t output_count() const;
- AudioBus output(size_t index) const;
- void set_channel_count(size_t);
- void set_channel_count_mode(Bindings::ChannelCountMode);
- void set_channel_interpretation(Bindings::ChannelInterpretation);
- size_t channel_count() const;
- Bindings::ChannelCountMode channel_count_mode() const;
- Bindings::ChannelInterpretation channel_interpretation() const;
- bool has_input_connections(size_t) const;
- size_t outgoing_node_connection_count() const;
- size_t outgoing_param_connection_count() const;
- struct OutgoingNodeConnection {
- NodeID destination;
- size_t output_index;
- size_t input_index;
- };
- struct OutgoingParamConnection {
- NonnullRefPtr<RenderAudioParam> destination;
- size_t output_index;
- };
- void* release_rust_node();
-
-protected:
- explicit RenderNode(void*);
- AudioBus pull_input(RenderGraph&, RenderContext const&, size_t input_index);
-
-private:
- void* m_node { nullptr };
- bool m_owned { true };
-};
-
-}
diff --git a/Libraries/LibWeb/WebAudio/Rendering/RenderNodes.cpp b/Libraries/LibWeb/WebAudio/Rendering/RenderNodes.cpp
deleted file mode 100644
index fbf769da8c7..00000000000
--- a/Libraries/LibWeb/WebAudio/Rendering/RenderNodes.cpp
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright (c) 2026, Jelle Raaijmakers <[email protected]>
- * Copyright (c) 2026-present, the Ladybird developers.
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#include <AK/Array.h>
-#include <LibWeb/WebAudio/Rendering/RenderNodes.h>
-#include <LibWeb/WebAudio/RustFFI.h>
-namespace Web::WebAudio::Rendering {
-
-DestinationRenderNode::DestinationRenderNode(NodeID node_id, size_t channel_count, size_t quantum_size)
- : RenderNode(RustFFI::web_audio_node_create_destination(node_id.value(), quantum_size, channel_count))
-{
-}
-GainRenderNode::GainRenderNode(NodeID node_id, size_t quantum_size, NonnullRefPtr<RenderAudioParam> gain)
- : RenderNode(RustFFI::web_audio_node_create_gain(node_id.value(), quantum_size, gain->rust_param()))
-{
-}
-ConstantSourceRenderNode::ConstantSourceRenderNode(NodeID node_id, size_t quantum_size, NonnullRefPtr<RenderAudioParam> offset)
- : RenderNode(RustFFI::web_audio_node_create_constant_source(node_id.value(), quantum_size, offset->rust_param()))
-{
-}
-OscillatorRenderNode::OscillatorRenderNode(NodeID node_id, size_t quantum_size, NonnullRefPtr<RenderAudioParam> frequency, NonnullRefPtr<RenderAudioParam> detune)
- : RenderNode(RustFFI::web_audio_node_create_oscillator(node_id.value(), quantum_size, frequency->rust_param(), detune->rust_param()))
-{
-}
-AudioBufferSourceRenderNode::AudioBufferSourceRenderNode(NodeID node_id, size_t quantum_size, NonnullRefPtr<RenderAudioParam> playback_rate, NonnullRefPtr<RenderAudioParam> detune)
- : RenderNode(RustFFI::web_audio_node_create_audio_buffer_source(node_id.value(), quantum_size, playback_rate->rust_param(), detune->rust_param()))
-{
-}
-DelayRenderNode::DelayRenderNode(NodeID node_id, size_t quantum_size, NonnullRefPtr<RenderAudioParam> delay_time, double max_delay_time)
- : RenderNode(RustFFI::web_audio_node_create_delay(node_id.value(), quantum_size, delay_time->rust_param(), max_delay_time))
-{
-}
-StereoPannerRenderNode::StereoPannerRenderNode(NodeID node_id, size_t quantum_size, NonnullRefPtr<RenderAudioParam> pan)
- : RenderNode(RustFFI::web_audio_node_create_stereo_panner(node_id.value(), quantum_size, pan->rust_param()))
-{
-}
-ChannelSplitterRenderNode::ChannelSplitterRenderNode(NodeID node_id, size_t quantum_size, size_t number_of_outputs)
- : RenderNode(RustFFI::web_audio_node_create_channel_splitter(node_id.value(), quantum_size, number_of_outputs))
-{
-}
-ChannelMergerRenderNode::ChannelMergerRenderNode(NodeID node_id, size_t quantum_size, size_t number_of_inputs)
- : RenderNode(RustFFI::web_audio_node_create_channel_merger(node_id.value(), quantum_size, number_of_inputs))
-{
-}
-BiquadFilterRenderNode::BiquadFilterRenderNode(NodeID node_id, size_t quantum_size, NonnullRefPtr<RenderAudioParam> frequency, NonnullRefPtr<RenderAudioParam> detune, NonnullRefPtr<RenderAudioParam> q, NonnullRefPtr<RenderAudioParam> gain)
- : RenderNode(RustFFI::web_audio_node_create_biquad_filter(node_id.value(), quantum_size, frequency->rust_param(), detune->rust_param(), q->rust_param(), gain->rust_param()))
-{
-}
-IIRFilterRenderNode::IIRFilterRenderNode(NodeID node_id, size_t quantum_size, Vector<double> feedforward, Vector<double> feedback)
- : RenderNode(RustFFI::web_audio_node_create_iir_filter(node_id.value(), quantum_size, feedforward.span(), feedback.span()))
-{
-}
-WaveShaperRenderNode::WaveShaperRenderNode(NodeID node_id, size_t quantum_size)
- : RenderNode(RustFFI::web_audio_node_create_wave_shaper(node_id.value(), quantum_size))
-{
-}
-ConvolverRenderNode::ConvolverRenderNode(NodeID node_id, size_t quantum_size)
- : RenderNode(RustFFI::web_audio_node_create_convolver(node_id.value(), quantum_size))
-{
-}
-PassthroughRenderNode::PassthroughRenderNode(NodeID node_id, size_t quantum_size)
- : RenderNode(RustFFI::web_audio_node_create_passthrough(node_id.value(), quantum_size))
-{
-}
-PannerRenderNode::PannerRenderNode(NodeID node_id, size_t quantum_size, Params params, ListenerParams listener_params)
- : RenderNode([&] {
- Array<void const*, 15> values { params.position_x->rust_param(), params.position_y->rust_param(), params.position_z->rust_param(),
- params.orientation_x->rust_param(), params.orientation_y->rust_param(), params.orientation_z->rust_param(),
- listener_params.position_x->rust_param(), listener_params.position_y->rust_param(), listener_params.position_z->rust_param(),
- listener_params.forward_x->rust_param(), listener_params.forward_y->rust_param(), listener_params.forward_z->rust_param(),
- listener_params.up_x->rust_param(), listener_params.up_y->rust_param(), listener_params.up_z->rust_param() };
- return RustFFI::web_audio_node_create_panner(node_id.value(), quantum_size, values.span());
- }())
-{
-}
-
-}
diff --git a/Libraries/LibWeb/WebAudio/Rendering/RenderNodes.h b/Libraries/LibWeb/WebAudio/Rendering/RenderNodes.h
deleted file mode 100644
index 749d2a4ca1d..00000000000
--- a/Libraries/LibWeb/WebAudio/Rendering/RenderNodes.h
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright (c) 2026, Jelle Raaijmakers <[email protected]>
- * Copyright (c) 2026-present, the Ladybird developers.
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#pragma once
-#include <LibWeb/WebAudio/Rendering/RenderNode.h>
-namespace Web::WebAudio::Rendering {
-
-class DestinationRenderNode final : public RenderNode {
-public:
- DestinationRenderNode(NodeID, size_t channel_count, size_t quantum_size);
-};
-class GainRenderNode final : public RenderNode {
-public:
- GainRenderNode(NodeID, size_t quantum_size, NonnullRefPtr<RenderAudioParam> gain);
-};
-class ConstantSourceRenderNode final : public RenderNode {
-public:
- ConstantSourceRenderNode(NodeID, size_t quantum_size, NonnullRefPtr<RenderAudioParam> offset);
-};
-class OscillatorRenderNode final : public RenderNode {
-public:
- OscillatorRenderNode(NodeID, size_t quantum_size, NonnullRefPtr<RenderAudioParam> frequency, NonnullRefPtr<RenderAudioParam> detune);
-};
-class AudioBufferSourceRenderNode final : public RenderNode {
-public:
- AudioBufferSourceRenderNode(NodeID, size_t quantum_size, NonnullRefPtr<RenderAudioParam> playback_rate, NonnullRefPtr<RenderAudioParam> detune);
-};
-class DelayRenderNode final : public RenderNode {
-public:
- DelayRenderNode(NodeID, size_t quantum_size, NonnullRefPtr<RenderAudioParam> delay_time, double max_delay_time);
-};
-class StereoPannerRenderNode final : public RenderNode {
-public:
- StereoPannerRenderNode(NodeID, size_t quantum_size, NonnullRefPtr<RenderAudioParam> pan);
-};
-class ChannelSplitterRenderNode final : public RenderNode {
-public:
- ChannelSplitterRenderNode(NodeID, size_t quantum_size, size_t number_of_outputs);
-};
-class ChannelMergerRenderNode final : public RenderNode {
-public:
- ChannelMergerRenderNode(NodeID, size_t quantum_size, size_t number_of_inputs);
-};
-class BiquadFilterRenderNode final : public RenderNode {
-public:
- BiquadFilterRenderNode(NodeID, size_t quantum_size, NonnullRefPtr<RenderAudioParam> frequency, NonnullRefPtr<RenderAudioParam> detune, NonnullRefPtr<RenderAudioParam> q, NonnullRefPtr<RenderAudioParam> gain);
-};
-class IIRFilterRenderNode final : public RenderNode {
-public:
- IIRFilterRenderNode(NodeID, size_t quantum_size, Vector<double> feedforward, Vector<double> feedback);
-};
-class WaveShaperRenderNode final : public RenderNode {
-public:
- WaveShaperRenderNode(NodeID, size_t quantum_size);
-};
-class ConvolverRenderNode final : public RenderNode {
-public:
- ConvolverRenderNode(NodeID, size_t quantum_size);
-};
-class PannerRenderNode final : public RenderNode {
-public:
- struct Params {
- NonnullRefPtr<RenderAudioParam> position_x;
- NonnullRefPtr<RenderAudioParam> position_y;
- NonnullRefPtr<RenderAudioParam> position_z;
- NonnullRefPtr<RenderAudioParam> orientation_x;
- NonnullRefPtr<RenderAudioParam> orientation_y;
- NonnullRefPtr<RenderAudioParam> orientation_z;
- };
- struct ListenerParams {
- NonnullRefPtr<RenderAudioParam> position_x;
- NonnullRefPtr<RenderAudioParam> position_y;
- NonnullRefPtr<RenderAudioParam> position_z;
- NonnullRefPtr<RenderAudioParam> forward_x;
- NonnullRefPtr<RenderAudioParam> forward_y;
- NonnullRefPtr<RenderAudioParam> forward_z;
- NonnullRefPtr<RenderAudioParam> up_x;
- NonnullRefPtr<RenderAudioParam> up_y;
- NonnullRefPtr<RenderAudioParam> up_z;
- };
- PannerRenderNode(NodeID, size_t quantum_size, Params, ListenerParams);
-};
-class PassthroughRenderNode final : public RenderNode {
-public:
- PassthroughRenderNode(NodeID, size_t quantum_size);
-};
-
-}
diff --git a/Libraries/LibWeb/WebAudio/Rendering/ScriptProcessorPipe.cpp b/Libraries/LibWeb/WebAudio/Rendering/ScriptProcessorPipe.cpp
index a2a7797e55d..3d73d7a5cf1 100644
--- a/Libraries/LibWeb/WebAudio/Rendering/ScriptProcessorPipe.cpp
+++ b/Libraries/LibWeb/WebAudio/Rendering/ScriptProcessorPipe.cpp
@@ -26,8 +26,7 @@ NonnullRefPtr<ScriptProcessorPipe> ScriptProcessorPipe::create(Config config, Co
}
ScriptProcessorPipe::ScriptProcessorPipe(Config config, Core::EventLoop& event_loop)
- : m_config(move(config))
- , m_callbacks(adopt_ref(*new ScriptProcessorPipeCallbacks(event_loop)))
+ : m_callbacks(adopt_ref(*new ScriptProcessorPipeCallbacks(event_loop)))
{
RustFFI::PipeCallbacks callbacks {
{ m_callbacks.ptr(), [](void* service) { static_cast<ScriptProcessorPipeCallbacks*>(service)->ref(); }, [](void* service) { static_cast<ScriptProcessorPipeCallbacks*>(service)->unref(); } },
@@ -43,30 +42,12 @@ ScriptProcessorPipe::ScriptProcessorPipe(Config config, Core::EventLoop& event_l
return true;
},
};
- RustFFI::ScriptProcessorPipeConfig native_config { m_config.buffer_size, m_config.input_channel_count, m_config.output_channel_count, m_config.block_count, m_config.waits_for_processing };
+ RustFFI::ScriptProcessorPipeConfig native_config { config.buffer_size, config.input_channel_count, config.output_channel_count, config.block_count, config.waits_for_processing };
m_pipe = RustFFI::web_audio_script_pipe_create(native_config, callbacks);
}
ScriptProcessorPipe::~ScriptProcessorPipe() { RustFFI::web_audio_script_pipe_destroy(m_pipe); }
-Span<float> ScriptProcessorPipe::input_channel(size_t block, size_t channel)
-{
- Span<float> samples;
- RustFFI::web_audio_script_pipe_channel(m_pipe, false, block, channel, &samples);
- return samples;
-}
-Span<float> ScriptProcessorPipe::output_channel(size_t block, size_t channel)
-{
- Span<float> samples;
- RustFFI::web_audio_script_pipe_channel(m_pipe, true, block, channel, &samples);
- return samples;
-}
-bool ScriptProcessorPipe::has_output(size_t block) const { return RustFFI::web_audio_script_pipe_has_output(m_pipe, block); }
-bool ScriptProcessorPipe::is_block_owned_by_rendering_thread(size_t block) const { return RustFFI::web_audio_script_pipe_is_rendering_owner(m_pipe, block); }
-void ScriptProcessorPipe::hand_block_to_control_thread(size_t block, u64 frame) { RustFFI::web_audio_script_pipe_to_control(m_pipe, block, frame); }
-void ScriptProcessorPipe::hand_block_back_to_rendering_thread(size_t block, bool has_output) { RustFFI::web_audio_script_pipe_to_rendering(m_pipe, block, has_output); }
void ScriptProcessorPipe::set_process_callback(Function<void(size_t, u64)> callback) { m_callbacks->process_callback = move(callback); }
void ScriptProcessorPipe::clear_process_callback() { m_callbacks->process_callback = nullptr; }
-void ScriptProcessorPipe::shut_down() { RustFFI::web_audio_script_pipe_shutdown(m_pipe); }
-bool ScriptProcessorPipe::is_shut_down() const { return RustFFI::web_audio_script_pipe_is_shutdown(m_pipe); }
}
diff --git a/Libraries/LibWeb/WebAudio/Rendering/ScriptProcessorPipe.h b/Libraries/LibWeb/WebAudio/Rendering/ScriptProcessorPipe.h
index e4c758f58b7..a2fd7c1e571 100644
--- a/Libraries/LibWeb/WebAudio/Rendering/ScriptProcessorPipe.h
+++ b/Libraries/LibWeb/WebAudio/Rendering/ScriptProcessorPipe.h
@@ -7,14 +7,9 @@
#pragma once
-#include <AK/Atomic.h>
#include <AK/AtomicRefCounted.h>
-#include <AK/ConditionVariable.h>
-#include <AK/FixedArray.h>
#include <AK/Function.h>
-#include <AK/Mutex.h>
#include <AK/NonnullRefPtr.h>
-#include <AK/Span.h>
#include <AK/Types.h>
#include <LibCore/Forward.h>
#include <LibWeb/Export.h>
@@ -38,26 +33,12 @@ public:
~ScriptProcessorPipe();
void const* rust_pipe() const { return m_pipe; }
- Config const& config() const { return m_config; }
-
- Span<float> input_channel(size_t block, size_t channel);
- Span<float> output_channel(size_t block, size_t channel);
- bool has_output(size_t block) const;
-
- bool is_block_owned_by_rendering_thread(size_t block) const;
- void hand_block_to_control_thread(size_t block, u64 start_frame);
-
void set_process_callback(Function<void(size_t block, u64 start_frame)>);
void clear_process_callback();
- void hand_block_back_to_rendering_thread(size_t block, bool has_output);
-
- void shut_down();
- bool is_shut_down() const;
private:
ScriptProcessorPipe(Config, Core::EventLoop& control_thread_event_loop);
- Config m_config;
NonnullRefPtr<ScriptProcessorPipeCallbacks> m_callbacks;
void const* m_pipe { nullptr };
};
diff --git a/Libraries/LibWeb/WebAudio/Rendering/ScriptProcessorRenderNode.cpp b/Libraries/LibWeb/WebAudio/Rendering/ScriptProcessorRenderNode.cpp
deleted file mode 100644
index db2642d9ca8..00000000000
--- a/Libraries/LibWeb/WebAudio/Rendering/ScriptProcessorRenderNode.cpp
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * Copyright (c) 2026, Jelle Raaijmakers <[email protected]>
- * Copyright (c) 2026-present, the Ladybird developers.
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#include <LibWeb/WebAudio/Rendering/ScriptProcessorRenderNode.h>
-#include <LibWeb/WebAudio/RustFFI.h>
-
-namespace Web::WebAudio::Rendering {
-
-ScriptProcessorRenderNode::ScriptProcessorRenderNode(NodeID node_id, size_t quantum_size, NonnullRefPtr<ScriptProcessorPipe> pipe)
- : RenderNode(RustFFI::web_audio_node_create_script_processor(node_id.value(), quantum_size, pipe->rust_pipe()))
-{
-}
-
-}
diff --git a/Libraries/LibWeb/WebAudio/Rendering/ScriptProcessorRenderNode.h b/Libraries/LibWeb/WebAudio/Rendering/ScriptProcessorRenderNode.h
deleted file mode 100644
index b34e65bcab0..00000000000
--- a/Libraries/LibWeb/WebAudio/Rendering/ScriptProcessorRenderNode.h
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright (c) 2026, Jelle Raaijmakers <[email protected]>
- * Copyright (c) 2026-present, the Ladybird developers.
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#pragma once
-
-#include <AK/NonnullRefPtr.h>
-#include <LibWeb/WebAudio/Rendering/RenderNode.h>
-#include <LibWeb/WebAudio/Rendering/ScriptProcessorPipe.h>
-
-namespace Web::WebAudio::Rendering {
-
-class ScriptProcessorRenderNode final : public RenderNode {
-public:
- ScriptProcessorRenderNode(NodeID, size_t quantum_size, NonnullRefPtr<ScriptProcessorPipe>);
-};
-
-}
diff --git a/Meta/Generators/libweb_bindings/glue_headers.py b/Meta/Generators/libweb_bindings/glue_headers.py
index 32b37c5cdf0..e8aa3bccd48 100644
--- a/Meta/Generators/libweb_bindings/glue_headers.py
+++ b/Meta/Generators/libweb_bindings/glue_headers.py
@@ -18,7 +18,6 @@ def bindings_glue_header_for_interface(interface: Interface, wrapper_interface_n
"EventTiming": "LibWeb/EventTiming/BindingsGlue.h",
"IndexedDB": "LibWeb/IndexedDB/BindingsGlue.h",
"TrustedTypes": "LibWeb/TrustedTypes/BindingsGlue.h",
- "WebAudio": "LibWeb/WebAudio/BindingsGlue.h",
"WebRTC": "LibWeb/WebRTC/BindingsGlue.h",
}
if module in module_headers:
diff --git a/Meta/Linters/check_libweb_realm_mentions.py b/Meta/Linters/check_libweb_realm_mentions.py
index 3ded26a038a..a579a10dab2 100755
--- a/Meta/Linters/check_libweb_realm_mentions.py
+++ b/Meta/Linters/check_libweb_realm_mentions.py
@@ -93,9 +93,10 @@ ALLOWED_REALM_MENTIONS = {
"the agent cluster of one",
),
"WebAudio": (
- 8,
- 19,
- "WebAudio buffers, AudioParamMap, and AudioWorklet APIs still materialize JS buffers and callback/promise values in selected realms",
+ 7,
+ 27,
+ "the Worklet, event loop, and media services still wrap C++ values or report exceptions in the caller's realm; "
+ "the port passes that realm explicitly across the Rust boundary",
),
"WebDriver": (2, 7, "WebDriver execute/JSON conversion still materializes JS values for automation"),
"WebGL": (4, 8, "WebGL contexts are created in the realm of their canvas, and their events in it"),