diff --git a/examples/worklet.rs b/examples/worklet.rs index 32c115a7..81845ac9 100644 --- a/examples/worklet.rs +++ b/examples/worklet.rs @@ -143,7 +143,7 @@ impl AudioProcessor for WhiteNoiseProcessor { true // source node will always be active } - fn onmessage(&mut self, msg: &mut Box) { + fn onmessage(&mut self, msg: &mut dyn Any) { // handle incoming signals requesting for change of color if let Some(color) = msg.downcast_ref::() { self.color = *color; diff --git a/src/node/audio_buffer_source.rs b/src/node/audio_buffer_source.rs index 313d80c8..817b3a6f 100644 --- a/src/node/audio_buffer_source.rs +++ b/src/node/audio_buffer_source.rs @@ -770,7 +770,7 @@ impl AudioProcessor for AudioBufferSourceRenderer { true } - fn onmessage(&mut self, msg: &mut Box) { + fn onmessage(&mut self, msg: &mut dyn Any) { if let Some(control) = msg.downcast_ref::() { self.handle_control_message(*control); return; diff --git a/src/node/constant_source.rs b/src/node/constant_source.rs index 519337b6..74557629 100644 --- a/src/node/constant_source.rs +++ b/src/node/constant_source.rs @@ -204,7 +204,7 @@ impl AudioProcessor for ConstantSourceRenderer { still_running } - fn onmessage(&mut self, msg: &mut Box) { + fn onmessage(&mut self, msg: &mut dyn Any) { if let Some(schedule) = msg.downcast_ref::() { match *schedule { Schedule::Start(v) => self.start_time = v, diff --git a/src/node/oscillator.rs b/src/node/oscillator.rs index b63fe8ba..128e5960 100644 --- a/src/node/oscillator.rs +++ b/src/node/oscillator.rs @@ -432,7 +432,7 @@ impl AudioProcessor for OscillatorRenderer { true } - fn onmessage(&mut self, msg: &mut Box) { + fn onmessage(&mut self, msg: &mut dyn Any) { if let Some(&type_) = msg.downcast_ref::() { self.shared_type.store(type_ as u32, Ordering::Release); self.type_ = type_; diff --git a/src/param.rs b/src/param.rs index 1bf871bc..f83a919f 100644 --- a/src/param.rs +++ b/src/param.rs @@ -642,7 +642,7 @@ impl AudioProcessor for AudioParamProcessor { true // has intrinsic value } - fn onmessage(&mut self, msg: &mut Box) { + fn onmessage(&mut self, msg: &mut dyn Any) { if let Some(automation_rate) = msg.downcast_ref::() { self.automation_rate = *automation_rate; self.shared_parts.store_automation_rate(*automation_rate); @@ -3167,7 +3167,7 @@ mod tests { }; let (param, mut render) = audio_param_pair(opts, context.mock_registration()); - render.onmessage(&mut (Box::new(AutomationRate::K) as _)); + render.onmessage(&mut AutomationRate::K); render.handle_incoming_event(param.set_value_at_time_raw(2., 0.000001)); let vs = render.compute_intrinsic_values(0., 1., 10); @@ -3186,7 +3186,7 @@ mod tests { }; let (param, mut render) = audio_param_pair(opts, context.mock_registration()); - render.onmessage(&mut (Box::new(AutomationRate::A) as _)); + render.onmessage(&mut AutomationRate::A); render.handle_incoming_event(param.set_value_at_time_raw(2., 0.000001)); let vs = render.compute_intrinsic_values(0., 1., 10); diff --git a/src/render/graph.rs b/src/render/graph.rs index 1dda5118..b691fb8f 100644 --- a/src/render/graph.rs +++ b/src/render/graph.rs @@ -197,7 +197,7 @@ impl Graph { .unwrap() .get_mut() .processor - .onmessage(msg); + .onmessage(msg.as_mut()); } /// Helper function for `order_nodes` - traverse node and outgoing edges diff --git a/src/render/processor.rs b/src/render/processor.rs index 8db7c731..2e244c5e 100644 --- a/src/render/processor.rs +++ b/src/render/processor.rs @@ -114,7 +114,7 @@ pub trait AudioProcessor: Send { /// [`MessagePort`](https://webaudio.github.io/web-audio-api/#dom-audioworkletprocessor-port) /// `onmessage` functionality of the AudioWorkletProcessor. #[allow(unused_variables)] - fn onmessage(&mut self, msg: &mut Box) { + fn onmessage(&mut self, msg: &mut dyn Any) { log::warn!("Ignoring incoming message"); } }