Skip to content

Commit

Permalink
Fix clippy warnings (#214)
Browse files Browse the repository at this point in the history
* Fix clippy warnings

* Fix implicitly elided lifetimes
  • Loading branch information
GnomedDev authored Jan 3, 2024
1 parent d681b71 commit 1b98c30
Show file tree
Hide file tree
Showing 15 changed files with 35 additions and 39 deletions.
2 changes: 1 addition & 1 deletion src/driver/scheduler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const RESCHEDULE_THRESHOLD: u64 = ((TIMESTEP_LENGTH.subsec_nanos() as u64) * 9)

const DEFAULT_MIXERS_PER_THREAD: NonZeroUsize = match NonZeroUsize::new(16) {
Some(v) => v,
None => [][0],
None => unreachable!(),
};

/// The default shared scheduler instance.
Expand Down
4 changes: 2 additions & 2 deletions src/driver/tasks/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ use crate::{
use flume::Receiver;
use tracing::{debug, info, instrument, trace};

#[instrument(skip(_interconnect, evt_rx))]
pub(crate) async fn runner(_interconnect: Interconnect, evt_rx: Receiver<EventMessage>) {
#[instrument(skip(evt_rx))]
pub(crate) async fn runner(evt_rx: Receiver<EventMessage>) {
let mut global = GlobalEvents::default();

let mut events: Vec<EventStore> = vec![];
Expand Down
3 changes: 1 addition & 2 deletions src/driver/tasks/message/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,9 @@ impl Interconnect {

self.events = evt_tx;

let ic = self.clone();
spawn(async move {
trace!("Event processor restarted.");
super::events::runner(ic, evt_rx).await;
super::events::runner(evt_rx).await;
trace!("Event processor finished.");
});

Expand Down
4 changes: 2 additions & 2 deletions src/driver/tasks/mixer/mix_logic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ pub fn mix_symph_indiv(

#[inline]
fn mix_over_ref(
source: &AudioBufferRef,
source: &AudioBufferRef<'_>,
target: &mut AudioBuffer<f32>,
source_pos: usize,
dest_pos: usize,
Expand Down Expand Up @@ -397,7 +397,7 @@ fn mix_resampled(

#[inline]
pub(crate) fn copy_into_resampler(
source: &AudioBufferRef,
source: &AudioBufferRef<'_>,
target: &mut AudioBuffer<f32>,
source_pos: usize,
dest_pos: usize,
Expand Down
2 changes: 1 addition & 1 deletion src/driver/tasks/mixer/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub enum InputState {
}

impl InputState {
pub fn metadata(&mut self) -> Option<Metadata> {
pub fn metadata(&mut self) -> Option<Metadata<'_>> {
if let Self::Ready(parsed, _) = self {
Some(parsed.into())
} else {
Expand Down
19 changes: 8 additions & 11 deletions src/driver/tasks/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,20 @@ fn start_internals(core: Sender<CoreMessage>, config: &Config) -> Interconnect {
let (evt_tx, evt_rx) = flume::unbounded();
let (mix_tx, mix_rx) = flume::unbounded();

let interconnect = Interconnect {
core,
events: evt_tx,
mixer: mix_tx,
};

let ic = interconnect.clone();
spawn(async move {
trace!("Event processor started.");
events::runner(ic, evt_rx).await;
events::runner(evt_rx).await;
trace!("Event processor finished.");
});

let ic = interconnect.clone();
config.get_scheduler().new_mixer(config, ic, mix_rx);
let ic = Interconnect {
core,
events: evt_tx,
mixer: mix_tx,
};

interconnect
config.get_scheduler().new_mixer(config, ic.clone(), mix_rx);
ic
}

#[instrument(skip(rx, tx))]
Expand Down
18 changes: 9 additions & 9 deletions src/driver/tasks/udp_rx/playout_buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pub enum PacketLookup {

#[derive(Debug)]
pub struct PlayoutBuffer {
playout_buffer: VecDeque<Option<StoredPacket>>,
buffer: VecDeque<Option<StoredPacket>>,
playout_mode: PlayoutMode,
next_seq: RtpSequence,
current_timestamp: Option<RtpTimestamp>,
Expand All @@ -51,7 +51,7 @@ pub struct PlayoutBuffer {
impl PlayoutBuffer {
pub fn new(capacity: usize, next_seq: RtpSequence) -> Self {
Self {
playout_buffer: VecDeque::with_capacity(capacity),
buffer: VecDeque::with_capacity(capacity),
playout_mode: PlayoutMode::Fill,
next_seq,
current_timestamp: None,
Expand Down Expand Up @@ -81,13 +81,13 @@ impl PlayoutBuffer {
trace!("Packet arrived beyond playout max length.");
} else {
let index = desired_index as usize;
while self.playout_buffer.len() <= index {
self.playout_buffer.push_back(None);
while self.buffer.len() <= index {
self.buffer.push_back(None);
}
self.playout_buffer[index] = Some(packet);
self.buffer[index] = Some(packet);
}

if self.playout_buffer.len() >= config.playout_buffer_length.get() {
if self.buffer.len() >= config.playout_buffer_length.get() {
self.playout_mode = PlayoutMode::Drain;
}
}
Expand All @@ -97,7 +97,7 @@ impl PlayoutBuffer {
return PacketLookup::Filling;
}

let out = match self.playout_buffer.pop_front() {
let out = match self.buffer.pop_front() {
Some(Some(pkt)) => {
let rtp = RtpPacket::new(&pkt.packet)
.expect("FATAL: earlier valid packet now invalid (fetch)");
Expand All @@ -111,7 +111,7 @@ impl PlayoutBuffer {
PacketLookup::Packet(pkt)
} else {
trace!("Witholding packet: ts_diff is {ts_diff}");
self.playout_buffer.push_front(Some(pkt));
self.buffer.push_front(Some(pkt));
self.playout_mode = PlayoutMode::Fill;
PacketLookup::Filling
}
Expand All @@ -123,7 +123,7 @@ impl PlayoutBuffer {
None => PacketLookup::Filling,
};

if self.playout_buffer.is_empty() {
if self.buffer.is_empty() {
self.playout_mode = PlayoutMode::Fill;
self.current_timestamp = None;
}
Expand Down
2 changes: 1 addition & 1 deletion src/input/adapters/cached/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ impl MediaSource for ToAudioBytes {

#[inline]
fn write_out(
source: &AudioBufferRef,
source: &AudioBufferRef<'_>,
target: &mut [u8],
source_pos: &mut Range<usize>,
spillover: &mut Vec<f32>,
Expand Down
2 changes: 1 addition & 1 deletion src/input/codecs/opus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ impl Decoder for OpusDecoder {
FinalizeResult::default()
}

fn last_decoded(&self) -> AudioBufferRef {
fn last_decoded(&self) -> AudioBufferRef<'_> {
self.buf.as_audio_buffer_ref()
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/input/live_input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ impl LiveInput {
/// Tries to get any information about this audio stream acquired during parsing.
///
/// Only exists when this input is [`LiveInput::Parsed`].
pub fn metadata(&mut self) -> Result<Metadata, MetadataError> {
pub fn metadata(&mut self) -> Result<Metadata<'_>, MetadataError> {
if let Some(parsed) = self.parsed_mut() {
Ok(parsed.into())
} else {
Expand Down
5 changes: 2 additions & 3 deletions src/input/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,7 @@ impl Input {
/// will always fail with [`AudioStreamError::Unsupported`].
pub async fn aux_metadata(&mut self) -> Result<AuxMetadata, AuxMetadataError> {
match self {
Self::Lazy(ref mut composer) => composer.aux_metadata().await.map_err(Into::into),
Self::Live(_, Some(ref mut composer)) =>
Self::Lazy(ref mut composer) | Self::Live(_, Some(ref mut composer)) =>
composer.aux_metadata().await.map_err(Into::into),
Self::Live(_, None) => Err(AuxMetadataError::NoCompose),
}
Expand All @@ -216,7 +215,7 @@ impl Input {
///
/// Only exists when this input is both [`Self::Live`] and has been fully parsed.
/// In general, you probably want to use [`Self::aux_metadata`].
pub fn metadata(&mut self) -> Result<Metadata, MetadataError> {
pub fn metadata(&mut self) -> Result<Metadata<'_>, MetadataError> {
if let Self::Live(live, _) = self {
live.metadata()
} else {
Expand Down
3 changes: 2 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
//! [codecs and formats provided by Symphonia]: https://github.com/pdeljanov/Symphonia#formats-demuxers
//! [audiopus]: https://github.com/lakelezz/audiopus

#![warn(clippy::pedantic)]
#![warn(clippy::pedantic, rust_2018_idioms)]
#![allow(
// Allowed as they are too pedantic
clippy::module_name_repetitions,
Expand All @@ -76,6 +76,7 @@
// TODO: would require significant rewriting of all existing docs
clippy::missing_errors_doc,
clippy::missing_panics_doc,
clippy::doc_link_with_quotes,
)]

mod config;
Expand Down
2 changes: 1 addition & 1 deletion src/tracks/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub enum TrackCommand {
/// Register an event on this track.
AddEvent(EventData),
/// Run some closure on this track, with direct access to the core object.
Do(Box<dyn FnOnce(View) -> Option<Action> + Send + Sync + 'static>),
Do(Box<dyn FnOnce(View<'_>) -> Option<Action> + Send + Sync + 'static>),
/// Request a copy of this track's state.
Request(Sender<TrackState>),
/// Change the loop count/strategy of this track.
Expand Down
2 changes: 1 addition & 1 deletion src/tracks/handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ impl TrackHandle {
/// [`Metadata`]: crate::input::Metadata
pub fn action<F>(&self, action: F) -> TrackResult<()>
where
F: FnOnce(View) -> Option<Action> + Send + Sync + 'static,
F: FnOnce(View<'_>) -> Option<Action> + Send + Sync + 'static,
{
self.send(TrackCommand::Do(Box::new(action)))
}
Expand Down
4 changes: 2 additions & 2 deletions src/tracks/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,8 @@ impl TrackQueue {

pub(crate) async fn get_preload_time(track: &mut Track) -> Option<Duration> {
let meta = match track.input {
Input::Lazy(ref mut rec) => rec.aux_metadata().await.ok(),
Input::Live(_, Some(ref mut rec)) => rec.aux_metadata().await.ok(),
Input::Lazy(ref mut rec) | Input::Live(_, Some(ref mut rec)) =>
rec.aux_metadata().await.ok(),
Input::Live(_, None) => None,
};

Expand Down

0 comments on commit 1b98c30

Please sign in to comment.