Skip to content

Commit

Permalink
use tracing (if enabled) for stream error + sink fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Sep 28, 2024
1 parent 1a7b8e5 commit 95a466e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/sink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ impl Sink {
.periodic_access(Duration::from_millis(5), move |src| {
if controls.stopped.load(Ordering::SeqCst) {
src.stop();
*controls.position.lock().unwrap() = Duration::ZERO;
*controls.position.lock().unwrap() = Duration::ZERO;
}
{
let mut to_clear = controls.to_clear.lock().unwrap();
Expand Down
7 changes: 6 additions & 1 deletion src/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,12 @@ impl CpalDeviceExt for cpal::Device {
let (mixer_tx, mut mixer_rx) =
dynamic_mixer::mixer::<f32>(format.channels(), format.sample_rate().0);

let error_callback = |err| eprintln!("an error occurred on output stream: {err}");
let error_callback = |err| {
#[cfg(feature = "tracing")]
tracing::error!("an error occurred on output stream: {err}");
#[cfg(not(feature = "tracing"))]
eprintln!("an error occurred on output stream: {err}");
};

match format.sample_format() {
cpal::SampleFormat::F32 => self.build_output_stream::<f32, _, _>(
Expand Down

0 comments on commit 95a466e

Please sign in to comment.