Skip to content

Commit

Permalink
This fixes all clippy warnings
Browse files Browse the repository at this point in the history
Made an issue for missing `is_empty()`, see:
#562

The DecoderImpl enum triggerd large_enum_variant. There is not an easy
fix for that. We could box the VorbisDecoder but at 572 bytes
I really do not think thats worth it. Annotated it with an allow
  • Loading branch information
dvdsk committed Mar 26, 2024
1 parent 8d8b5da commit 77ca23a
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/decoder/flac.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ where

// Load the next block.
self.current_block_off = 0;
let buffer = mem::replace(&mut self.current_block, Vec::new());
let buffer = mem::take(&mut self.current_block);
match self.reader.blocks().read_next_or_eof(buffer) {
Ok(Some(block)) => {
self.current_block_channel_len = (block.len() / block.channels()) as usize;
Expand Down
3 changes: 3 additions & 0 deletions src/decoder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ pub struct LoopedDecoder<R>(DecoderImpl<R>)
where
R: Read + Seek;

// can not really reduce the size of the VorbisDecoder. There are not any
// arrays just a lot of struct fields.
#[allow(clippy::large_enum_variant)]
enum DecoderImpl<R>
where
R: Read + Seek,
Expand Down
5 changes: 4 additions & 1 deletion src/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,12 @@ where

// TODO: consider reimplementing this with `from_factory`

type Sound<S> = Box<dyn Source<Item = S> + Send>;
type SignalDone = Option<Sender<()>>;

/// The input of the queue.
pub struct SourcesQueueInput<S> {
next_sounds: Mutex<Vec<(Box<dyn Source<Item = S> + Send>, Option<Sender<()>>)>>,
next_sounds: Mutex<Vec<(Sound<S>, SignalDone)>>,

// See constructor.
keep_alive_if_empty: AtomicBool,
Expand Down
1 change: 1 addition & 0 deletions src/sink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ impl Sink {
}

/// Returns the number of sounds currently in the queue.
#[allow(clippy::len_without_is_empty)]
#[inline]
pub fn len(&self) -> usize {
self.sound_count.load(Ordering::Relaxed)
Expand Down
2 changes: 1 addition & 1 deletion src/source/sine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ impl SineWave {
#[inline]
pub fn new(freq: f32) -> SineWave {
SineWave {
freq: freq,
freq,
num_sample: 0,
}
}
Expand Down
1 change: 1 addition & 0 deletions src/spatial_sink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ impl SpatialSink {
}

/// Returns the number of sounds currently in the queue.
#[allow(clippy::len_without_is_empty)]
#[inline]
pub fn len(&self) -> usize {
self.sink.len()
Expand Down

0 comments on commit 77ca23a

Please sign in to comment.