From 961e941e3d9ad3d6efbb789575cf081e48bfada0 Mon Sep 17 00:00:00 2001 From: dvdsk Date: Wed, 11 Oct 2023 14:17:12 +0200 Subject: [PATCH] formats everything with cargo fmt --- src/buffer.rs | 7 +++---- src/decoder/flac.rs | 6 ++++-- src/decoder/mp3.rs | 12 ++++++------ src/dynamic_mixer.rs | 4 +++- src/sink.rs | 2 +- src/source/amplify.rs | 3 --- src/source/blt.rs | 3 --- src/source/buffered.rs | 7 +++---- src/source/channel_volume.rs | 3 --- src/source/delay.rs | 3 --- src/source/done.rs | 3 --- src/source/empty.rs | 7 +++---- src/source/empty_callback.rs | 7 +++---- src/source/fadein.rs | 3 --- src/source/from_iter.rs | 3 --- src/source/pausable.rs | 3 --- src/source/periodic.rs | 3 --- src/source/repeat.rs | 3 --- src/source/samples_converter.rs | 3 --- src/source/sine.rs | 8 +++----- src/source/skip.rs | 3 --- src/source/skippable.rs | 3 --- src/source/spatial.rs | 3 --- src/source/speed.rs | 3 --- src/source/stoppable.rs | 3 --- src/source/take.rs | 3 --- src/source/zero.rs | 3 --- src/spatial_sink.rs | 4 ++-- tests/seek.rs | 4 ++-- 29 files changed, 33 insertions(+), 89 deletions(-) diff --git a/src/buffer.rs b/src/buffer.rs index 9bd97706..84989b7e 100644 --- a/src/buffer.rs +++ b/src/buffer.rs @@ -88,11 +88,10 @@ where #[inline] fn try_seek(&mut self, _: Duration) -> Result<(), SeekError> { - Err(SeekError::NotSupported { underlying_source: std::any::type_name::() }) + Err(SeekError::NotSupported { + underlying_source: std::any::type_name::(), + }) } - - - } impl Iterator for SamplesBuffer diff --git a/src/decoder/flac.rs b/src/decoder/flac.rs index 77fa73e7..50ddcdd8 100644 --- a/src/decoder/flac.rs +++ b/src/decoder/flac.rs @@ -3,8 +3,8 @@ use std::io::{Read, Seek, SeekFrom}; use std::mem; use std::time::Duration; -use crate::Source; use crate::source::SeekError; +use crate::Source; use claxon::FlacReader; @@ -83,7 +83,9 @@ where #[inline] fn try_seek(&mut self, _: Duration) -> Result<(), SeekError> { - Err(SeekError::NotSupported { underlying_source: std::any::type_name::() }) + Err(SeekError::NotSupported { + underlying_source: std::any::type_name::(), + }) } } diff --git a/src/decoder/mp3.rs b/src/decoder/mp3.rs index 102b9bd4..4365ce22 100644 --- a/src/decoder/mp3.rs +++ b/src/decoder/mp3.rs @@ -4,9 +4,9 @@ use std::time::Duration; use crate::source::SeekError; use crate::Source; -use minimp3_fixed as minimp3; -use minimp3::Frame; use minimp3::Decoder; +use minimp3::Frame; +use minimp3_fixed as minimp3; // use minimp3::{Decoder, SeekDecoder}; pub struct Mp3Decoder @@ -29,9 +29,9 @@ where } // let mut decoder = SeekDecoder::new(data) let mut decoder = Decoder::new(data); - // paramaters are correct and minimp3 is used correctly - // thus if we crash here one of these invariants is broken: - // .expect("should be able to allocate memory, perform IO"); + // paramaters are correct and minimp3 is used correctly + // thus if we crash here one of these invariants is broken: + // .expect("should be able to allocate memory, perform IO"); // let current_frame = decoder.decode_frame() let current_frame = decoder.next_frame() // the reader makes enough data availible therefore @@ -97,7 +97,7 @@ where fn next(&mut self) -> Option { if self.current_frame_offset == self.current_frame_len().unwrap() { if let Ok(frame) = self.decoder.next_frame() { - // if let Ok(frame) = self.decoder.decode_frame() { + // if let Ok(frame) = self.decoder.decode_frame() { self.current_frame = frame; self.current_frame_offset = 0; } else { diff --git a/src/dynamic_mixer.rs b/src/dynamic_mixer.rs index 0db887ec..c2abd1c7 100644 --- a/src/dynamic_mixer.rs +++ b/src/dynamic_mixer.rs @@ -109,7 +109,9 @@ where #[inline] fn try_seek(&mut self, _: Duration) -> Result<(), SeekError> { - Err(SeekError::NotSupported { underlying_source: std::any::type_name::() }) + Err(SeekError::NotSupported { + underlying_source: std::any::type_name::(), + }) // uncomment when #510 is implemented (query position of playback) diff --git a/src/sink.rs b/src/sink.rs index 0cf699a6..03fa0983 100644 --- a/src/sink.rs +++ b/src/sink.rs @@ -206,7 +206,7 @@ impl Sink { /// This blocks between 0 and ~5 milliseconds. /// /// As long as the *duration of the source is known* seeking saturates. This means - /// when you try to seek beyong the length of the source this function will seek + /// when you try to seek beyong the length of the source this function will seek /// to the end of the source instead. /// /// If the duration of the source is known and the seek position lies beyond diff --git a/src/source/amplify.rs b/src/source/amplify.rs index bdb5324f..42e6955c 100644 --- a/src/source/amplify.rs +++ b/src/source/amplify.rs @@ -100,7 +100,4 @@ where fn try_seek(&mut self, pos: Duration) -> Result<(), SeekError> { self.input.try_seek(pos) } - - - } diff --git a/src/source/blt.rs b/src/source/blt.rs index ac20307e..ac0c1de3 100644 --- a/src/source/blt.rs +++ b/src/source/blt.rs @@ -154,9 +154,6 @@ where fn try_seek(&mut self, pos: Duration) -> Result<(), SeekError> { self.input.try_seek(pos) } - - - } #[derive(Clone, Debug)] diff --git a/src/source/buffered.rs b/src/source/buffered.rs index 908d9a30..23b6c4d0 100644 --- a/src/source/buffered.rs +++ b/src/source/buffered.rs @@ -244,11 +244,10 @@ where #[inline] fn try_seek(&mut self, _: Duration) -> Result<(), SeekError> { - Err(SeekError::NotSupported { underlying_source: std::any::type_name::() }) + Err(SeekError::NotSupported { + underlying_source: std::any::type_name::(), + }) } - - - } impl Clone for Buffered diff --git a/src/source/channel_volume.rs b/src/source/channel_volume.rs index ee60f952..87ee9919 100644 --- a/src/source/channel_volume.rs +++ b/src/source/channel_volume.rs @@ -145,7 +145,4 @@ where fn try_seek(&mut self, pos: Duration) -> Result<(), SeekError> { self.input.try_seek(pos) } - - - } diff --git a/src/source/delay.rs b/src/source/delay.rs index d6cff305..d3a8f897 100644 --- a/src/source/delay.rs +++ b/src/source/delay.rs @@ -113,7 +113,4 @@ where let pos_without_delay = pos.saturating_sub(self.requested_duration); self.input.try_seek(pos_without_delay) } - - - } diff --git a/src/source/done.rs b/src/source/done.rs index 2ab03cbd..dc6d6760 100644 --- a/src/source/done.rs +++ b/src/source/done.rs @@ -94,7 +94,4 @@ where fn try_seek(&mut self, pos: Duration) -> Result<(), SeekError> { self.input.try_seek(pos) } - - - } diff --git a/src/source/empty.rs b/src/source/empty.rs index 5c9ae953..3c8f4722 100644 --- a/src/source/empty.rs +++ b/src/source/empty.rs @@ -58,9 +58,8 @@ where #[inline] fn try_seek(&mut self, _: Duration) -> Result<(), SeekError> { - Err(SeekError::NotSupported { underlying_source: std::any::type_name::() }) + Err(SeekError::NotSupported { + underlying_source: std::any::type_name::(), + }) } - - - } diff --git a/src/source/empty_callback.rs b/src/source/empty_callback.rs index d003b4af..1752c366 100644 --- a/src/source/empty_callback.rs +++ b/src/source/empty_callback.rs @@ -57,9 +57,8 @@ where #[inline] fn try_seek(&mut self, _: Duration) -> Result<(), SeekError> { - Err(SeekError::NotSupported { underlying_source: std::any::type_name::() }) + Err(SeekError::NotSupported { + underlying_source: std::any::type_name::(), + }) } - - - } diff --git a/src/source/fadein.rs b/src/source/fadein.rs index 79a14c39..68cf4298 100644 --- a/src/source/fadein.rs +++ b/src/source/fadein.rs @@ -112,7 +112,4 @@ where fn try_seek(&mut self, pos: Duration) -> Result<(), SeekError> { self.input.try_seek(pos) } - - - } diff --git a/src/source/from_iter.rs b/src/source/from_iter.rs index 67f64683..45e4b23a 100644 --- a/src/source/from_iter.rs +++ b/src/source/from_iter.rs @@ -146,9 +146,6 @@ where Ok(()) } } - - - } #[cfg(test)] diff --git a/src/source/pausable.rs b/src/source/pausable.rs index 05b3ead1..c41dfc1a 100644 --- a/src/source/pausable.rs +++ b/src/source/pausable.rs @@ -122,7 +122,4 @@ where fn try_seek(&mut self, pos: Duration) -> Result<(), SeekError> { self.input.try_seek(pos) } - - - } diff --git a/src/source/periodic.rs b/src/source/periodic.rs index 97671126..58ed89a1 100644 --- a/src/source/periodic.rs +++ b/src/source/periodic.rs @@ -124,9 +124,6 @@ where fn try_seek(&mut self, pos: Duration) -> Result<(), SeekError> { self.input.try_seek(pos) } - - - } #[cfg(test)] diff --git a/src/source/repeat.rs b/src/source/repeat.rs index b9d39bd1..90b652f2 100644 --- a/src/source/repeat.rs +++ b/src/source/repeat.rs @@ -91,9 +91,6 @@ where fn try_seek(&mut self, pos: Duration) -> Result<(), SeekError> { self.inner.try_seek(pos) } - - - } impl Clone for Repeat diff --git a/src/source/samples_converter.rs b/src/source/samples_converter.rs index 637b7dea..84beb4c8 100644 --- a/src/source/samples_converter.rs +++ b/src/source/samples_converter.rs @@ -102,7 +102,4 @@ where fn try_seek(&mut self, pos: Duration) -> Result<(), SeekError> { self.inner.try_seek(pos) } - - - } diff --git a/src/source/sine.rs b/src/source/sine.rs index 6c815b5f..44aa48ee 100644 --- a/src/source/sine.rs +++ b/src/source/sine.rs @@ -60,12 +60,10 @@ impl Source for SineWave { #[inline] fn try_seek(&mut self, _: Duration) -> Result<(), SeekError> { - // This is a constant sound, normal seeking would not have any effect. - // While changing the phase of the sine wave could change how it sounds in - // combination with another sound (beating) such precision is not the intend + // This is a constant sound, normal seeking would not have any effect. + // While changing the phase of the sine wave could change how it sounds in + // combination with another sound (beating) such precision is not the intend // of seeking Ok(()) } - - } diff --git a/src/source/skip.rs b/src/source/skip.rs index e8ee170e..8a8391f1 100644 --- a/src/source/skip.rs +++ b/src/source/skip.rs @@ -164,9 +164,6 @@ where fn try_seek(&mut self, pos: Duration) -> Result<(), SeekError> { self.input.try_seek(pos) } - - - } #[cfg(test)] diff --git a/src/source/skippable.rs b/src/source/skippable.rs index c2413412..400a4fec 100644 --- a/src/source/skippable.rs +++ b/src/source/skippable.rs @@ -96,7 +96,4 @@ where fn try_seek(&mut self, pos: Duration) -> Result<(), SeekError> { self.input.try_seek(pos) } - - - } diff --git a/src/source/spatial.rs b/src/source/spatial.rs index 1dc08c5b..2976703b 100644 --- a/src/source/spatial.rs +++ b/src/source/spatial.rs @@ -124,7 +124,4 @@ where fn try_seek(&mut self, pos: Duration) -> Result<(), SeekError> { self.input.try_seek(pos) } - - - } diff --git a/src/source/speed.rs b/src/source/speed.rs index 09db9168..d24cb8ac 100644 --- a/src/source/speed.rs +++ b/src/source/speed.rs @@ -106,7 +106,4 @@ where let pos_accounting_for_speedup = pos.mul_f32(self.factor); self.input.try_seek(pos_accounting_for_speedup) } - - - } diff --git a/src/source/stoppable.rs b/src/source/stoppable.rs index af176858..71ba8d2f 100644 --- a/src/source/stoppable.rs +++ b/src/source/stoppable.rs @@ -95,7 +95,4 @@ where fn try_seek(&mut self, pos: Duration) -> Result<(), SeekError> { self.input.try_seek(pos) } - - - } diff --git a/src/source/take.rs b/src/source/take.rs index d843b495..fa20c64f 100644 --- a/src/source/take.rs +++ b/src/source/take.rs @@ -183,7 +183,4 @@ where fn try_seek(&mut self, pos: Duration) -> Result<(), SeekError> { self.input.try_seek(pos) } - - - } diff --git a/src/source/zero.rs b/src/source/zero.rs index e1ceb3c9..5337a90c 100644 --- a/src/source/zero.rs +++ b/src/source/zero.rs @@ -84,7 +84,4 @@ where fn try_seek(&mut self, _: Duration) -> Result<(), SeekError> { Ok(()) } - - - } diff --git a/src/spatial_sink.rs b/src/spatial_sink.rs index 0a2dc85b..f1e7026b 100644 --- a/src/spatial_sink.rs +++ b/src/spatial_sink.rs @@ -4,7 +4,7 @@ use std::time::Duration; use cpal::FromSample; -use crate::source::{Spatial, SeekError}; +use crate::source::{SeekError, Spatial}; use crate::stream::{OutputStreamHandle, PlayError}; use crate::{Sample, Sink, Source}; @@ -170,7 +170,7 @@ impl SpatialSink { /// This blocks between 0 and ~5 milliseconds. /// /// As long as the *duration of the source is known* seeking saturates. This means - /// when you try to seek beyong the length of the source this function will seek + /// when you try to seek beyong the length of the source this function will seek /// to the end of the source instead. /// /// If the duration of the source is known and the seek position lies beyond diff --git a/tests/seek.rs b/tests/seek.rs index 7b97f482..223b109c 100644 --- a/tests/seek.rs +++ b/tests/seek.rs @@ -30,7 +30,7 @@ fn sink_and_decoder(format: &str) -> (Sink, Decoder) { (sink, decoder) } -// run the following to get the other configuration: +// run the following to get the other configuration: // cargo test --no-default-features // --features symphonia-wav --features symphonia-vorbis // --features symphonia-flac --features symphonia-isomp4 --features minimp3 @@ -83,7 +83,7 @@ fn seek_beyond_end_saturates() { println!("seeking beyond end for: {format}\t decoded by: {decoder_name}"); let res = sink.try_seek(Duration::from_secs(999)); - assert!(dbg!(res).is_ok()); + assert!(res.is_ok()); let now = Instant::now(); sink.sleep_until_end();