Skip to content

Commit

Permalink
AudioProcessor::onmessage(): Unbox parameter on invocation
Browse files Browse the repository at this point in the history
  • Loading branch information
uklotzde committed Jul 18, 2023
1 parent ccf6f05 commit a5c1e5e
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion examples/worklet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ impl AudioProcessor for WhiteNoiseProcessor {
true // source node will always be active
}

fn onmessage(&mut self, msg: &mut Box<dyn Any + Send + 'static>) {
fn onmessage(&mut self, msg: &mut dyn Any) {
// handle incoming signals requesting for change of color
if let Some(color) = msg.downcast_ref::<NoiseColor>() {
self.color = *color;
Expand Down
2 changes: 1 addition & 1 deletion src/node/audio_buffer_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,7 @@ impl AudioProcessor for AudioBufferSourceRenderer {
true
}

fn onmessage(&mut self, msg: &mut Box<dyn Any + Send + 'static>) {
fn onmessage(&mut self, msg: &mut dyn Any) {
if let Some(control) = msg.downcast_ref::<ControlMessage>() {
self.handle_control_message(*control);
return;
Expand Down
2 changes: 1 addition & 1 deletion src/node/constant_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ impl AudioProcessor for ConstantSourceRenderer {
still_running
}

fn onmessage(&mut self, msg: &mut Box<dyn Any + Send + 'static>) {
fn onmessage(&mut self, msg: &mut dyn Any) {
if let Some(schedule) = msg.downcast_ref::<Schedule>() {
match *schedule {
Schedule::Start(v) => self.start_time = v,
Expand Down
2 changes: 1 addition & 1 deletion src/node/oscillator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ impl AudioProcessor for OscillatorRenderer {
true
}

fn onmessage(&mut self, msg: &mut Box<dyn Any + Send + 'static>) {
fn onmessage(&mut self, msg: &mut dyn Any) {
if let Some(&type_) = msg.downcast_ref::<OscillatorType>() {
self.shared_type.store(type_ as u32, Ordering::Release);
self.type_ = type_;
Expand Down
6 changes: 3 additions & 3 deletions src/param.rs
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ impl AudioProcessor for AudioParamProcessor {
true // has intrinsic value
}

fn onmessage(&mut self, msg: &mut Box<dyn Any + Send + 'static>) {
fn onmessage(&mut self, msg: &mut dyn Any) {
if let Some(automation_rate) = msg.downcast_ref::<AutomationRate>() {
self.automation_rate = *automation_rate;
self.shared_parts.store_automation_rate(*automation_rate);
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/render/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/render/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<dyn Any + Send + 'static>) {
fn onmessage(&mut self, msg: &mut dyn Any) {
log::warn!("Ignoring incoming message");
}
}
Expand Down

0 comments on commit a5c1e5e

Please sign in to comment.