-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Run diagnostics on live AudioContext #401
Changes from all commits
e2585ec
8464157
4244c5c
b14e486
e0f35a9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -116,6 +116,18 @@ pub trait AudioProcessor: Send { | |
fn onmessage(&mut self, msg: &mut dyn Any) { | ||
log::warn!("Ignoring incoming message"); | ||
} | ||
|
||
/// Return the name of the actual AudioProcessor type | ||
#[doc(hidden)] // not meant to be user facing | ||
fn name(&self) -> &'static str { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This method enables us to ask a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice, I'll try to make to list all the cases I can think of about this graph thing next week |
||
std::any::type_name::<Self>() | ||
} | ||
} | ||
|
||
impl std::fmt::Debug for dyn AudioProcessor { | ||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
f.debug_struct(self.name()).finish_non_exhaustive() | ||
} | ||
} | ||
|
||
struct DerefAudioRenderQuantumChannel<'a>(std::cell::Ref<'a, Node>); | ||
|
@@ -161,3 +173,31 @@ impl<'a> AudioParamValues<'a> { | |
crate::context::LISTENER_AUDIO_PARAM_IDS.map(|p| self.get(&p)) | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
|
||
struct TestNode; | ||
|
||
impl AudioProcessor for TestNode { | ||
fn process( | ||
&mut self, | ||
_inputs: &[AudioRenderQuantum], | ||
_outputs: &mut [AudioRenderQuantum], | ||
_params: AudioParamValues<'_>, | ||
_scope: &RenderScope, | ||
) -> bool { | ||
todo!() | ||
} | ||
} | ||
|
||
#[test] | ||
fn test_debug_fmt() { | ||
let proc = &TestNode as &dyn AudioProcessor; | ||
assert_eq!( | ||
&format!("{:?}", proc), | ||
"web_audio_api::render::processor::tests::TestNode { .. }" | ||
); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wondering if we should mark this method
#[doc(hidden)]
because I could imagine we are not keeping the API stable over different versions. Would be interesting to return more structured data in the futureThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup looks reasonable