Skip to content

Commit d75aaf4

Browse files
committed
Add missing Debug implementation for Analyser and Media nodes
1 parent d1b43d1 commit d75aaf4

File tree

4 files changed

+22
-1
lines changed

4 files changed

+22
-1
lines changed

src/analysis.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,17 @@ pub(crate) struct Analyser {
156156
blackman: Vec<f32>,
157157
}
158158

159+
impl std::fmt::Debug for Analyser {
160+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
161+
f.debug_struct("Analyser")
162+
.field("fft_size", &self.fft_size())
163+
.field("smoothing_time_constant", &self.smoothing_time_constant())
164+
.field("min_decibels", &self.min_decibels())
165+
.field("max_decibels", &self.max_decibels())
166+
.finish_non_exhaustive()
167+
}
168+
}
169+
159170
impl Analyser {
160171
pub fn new() -> Self {
161172
let ring_buffer = AnalyserRingBuffer::new();

src/media_streams/mod.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,14 @@ pub struct MediaStreamTrack {
3232
inner: Arc<MediaStreamTrackInner>,
3333
}
3434

35+
impl std::fmt::Debug for MediaStreamTrack {
36+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
37+
f.debug_struct("MediaStreamTrack")
38+
.field("ended", &self.inner.ended)
39+
.finish_non_exhaustive()
40+
}
41+
}
42+
3543
struct MediaStreamTrackInner {
3644
data: ArcSwap<FallibleBuffer>,
3745
position: AtomicU64,
@@ -119,7 +127,7 @@ impl Iterator for MediaStreamTrackIter {
119127
///
120128
/// A stream consists of several tracks, such as video or audio tracks. Each track is specified as
121129
/// an instance of [`MediaStreamTrack`].
122-
#[derive(Clone)]
130+
#[derive(Clone, Debug)]
123131
pub struct MediaStream {
124132
tracks: Vec<MediaStreamTrack>,
125133
}

src/node/analyser.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ impl Default for AnalyserOptions {
7777
/// - `cargo run --release --example analyser`
7878
/// - `cd showcase/mic_playback && cargo run --release`
7979
///
80+
#[derive(Debug)]
8081
pub struct AnalyserNode {
8182
registration: AudioContextRegistration,
8283
channel_config: ChannelConfig,

src/node/media_stream_destination.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ use crossbeam_channel::{self, Receiver, Sender};
5353
/// # Examples
5454
///
5555
/// - `cargo run --release --example recorder`
56+
#[derive(Debug)]
5657
pub struct MediaStreamAudioDestinationNode {
5758
registration: AudioContextRegistration,
5859
channel_config: ChannelConfig,

0 commit comments

Comments
 (0)