Skip to content

Commit 70382ce

Browse files
committed
AudioProcessor::onmessage(): Unbox parameter on invocation
1 parent ccf6f05 commit 70382ce

File tree

8 files changed

+10
-10
lines changed

8 files changed

+10
-10
lines changed

examples/worklet.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ impl AudioProcessor for WhiteNoiseProcessor {
143143
true // source node will always be active
144144
}
145145

146-
fn onmessage(&mut self, msg: &mut Box<dyn Any + Send + 'static>) {
146+
fn onmessage(&mut self, msg: &mut dyn Any) {
147147
// handle incoming signals requesting for change of color
148148
if let Some(color) = msg.downcast_ref::<NoiseColor>() {
149149
self.color = *color;

src/node/audio_buffer_source.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,7 @@ impl AudioProcessor for AudioBufferSourceRenderer {
770770
true
771771
}
772772

773-
fn onmessage(&mut self, msg: &mut Box<dyn Any + Send + 'static>) {
773+
fn onmessage(&mut self, msg: &mut dyn Any) {
774774
if let Some(control) = msg.downcast_ref::<ControlMessage>() {
775775
self.handle_control_message(*control);
776776
return;

src/node/constant_source.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ impl AudioProcessor for ConstantSourceRenderer {
204204
still_running
205205
}
206206

207-
fn onmessage(&mut self, msg: &mut Box<dyn Any + Send + 'static>) {
207+
fn onmessage(&mut self, msg: &mut dyn Any) {
208208
if let Some(schedule) = msg.downcast_ref::<Schedule>() {
209209
match *schedule {
210210
Schedule::Start(v) => self.start_time = v,

src/node/oscillator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ impl AudioProcessor for OscillatorRenderer {
432432
true
433433
}
434434

435-
fn onmessage(&mut self, msg: &mut Box<dyn Any + Send + 'static>) {
435+
fn onmessage(&mut self, msg: &mut dyn Any) {
436436
if let Some(&type_) = msg.downcast_ref::<OscillatorType>() {
437437
self.shared_type.store(type_ as u32, Ordering::Release);
438438
self.type_ = type_;

src/param.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,7 @@ impl AudioProcessor for AudioParamProcessor {
642642
true // has intrinsic value
643643
}
644644

645-
fn onmessage(&mut self, msg: &mut Box<dyn Any + Send + 'static>) {
645+
fn onmessage(&mut self, msg: &mut dyn Any) {
646646
if let Some(automation_rate) = msg.downcast_ref::<AutomationRate>() {
647647
self.automation_rate = *automation_rate;
648648
self.shared_parts.store_automation_rate(*automation_rate);
@@ -3167,7 +3167,7 @@ mod tests {
31673167
};
31683168
let (param, mut render) = audio_param_pair(opts, context.mock_registration());
31693169

3170-
render.onmessage(&mut (Box::new(AutomationRate::K) as _));
3170+
render.onmessage(&mut AutomationRate::K);
31713171
render.handle_incoming_event(param.set_value_at_time_raw(2., 0.000001));
31723172

31733173
let vs = render.compute_intrinsic_values(0., 1., 10);
@@ -3186,7 +3186,7 @@ mod tests {
31863186
};
31873187
let (param, mut render) = audio_param_pair(opts, context.mock_registration());
31883188

3189-
render.onmessage(&mut (Box::new(AutomationRate::A) as _));
3189+
render.onmessage(&mut AutomationRate::A);
31903190
render.handle_incoming_event(param.set_value_at_time_raw(2., 0.000001));
31913191

31923192
let vs = render.compute_intrinsic_values(0., 1., 10);

src/render/graph.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ impl Graph {
191191
self.nodes.get_mut(&index).unwrap().get_mut().cycle_breaker = true;
192192
}
193193

194-
pub fn route_message(&mut self, index: AudioNodeId, msg: &mut Box<dyn Any + Send + 'static>) {
194+
pub fn route_message(&mut self, index: AudioNodeId, msg: &mut dyn Any) {
195195
self.nodes
196196
.get_mut(&index)
197197
.unwrap()

src/render/processor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ pub trait AudioProcessor: Send {
114114
/// [`MessagePort`](https://webaudio.github.io/web-audio-api/#dom-audioworkletprocessor-port)
115115
/// `onmessage` functionality of the AudioWorkletProcessor.
116116
#[allow(unused_variables)]
117-
fn onmessage(&mut self, msg: &mut Box<dyn Any + Send + 'static>) {
117+
fn onmessage(&mut self, msg: &mut dyn Any) {
118118
log::warn!("Ignoring incoming message");
119119
}
120120
}

src/render/thread.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ impl RenderThread {
123123
self.graph = Some(graph);
124124
}
125125
NodeMessage { id, mut msg } => {
126-
self.graph.as_mut().unwrap().route_message(id, &mut msg);
126+
self.graph.as_mut().unwrap().route_message(id, msg.as_mut());
127127
// FIXME: Drop the remains of the handled message outside of the render thread.
128128
}
129129
}

0 commit comments

Comments
 (0)