Fix clippy warnings (#214)

* Fix clippy warnings

* Fix implicitly elided lifetimes
This commit is contained in:
Gnome!
2024-01-03 16:45:23 +00:00
committed by GitHub
parent d681b71b1f
commit 1b98c30746
15 changed files with 36 additions and 40 deletions

View File

@@ -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) { const DEFAULT_MIXERS_PER_THREAD: NonZeroUsize = match NonZeroUsize::new(16) {
Some(v) => v, Some(v) => v,
None => [][0], None => unreachable!(),
}; };
/// The default shared scheduler instance. /// The default shared scheduler instance.

View File

@@ -6,8 +6,8 @@ use crate::{
use flume::Receiver; use flume::Receiver;
use tracing::{debug, info, instrument, trace}; use tracing::{debug, info, instrument, trace};
#[instrument(skip(_interconnect, evt_rx))] #[instrument(skip(evt_rx))]
pub(crate) async fn runner(_interconnect: Interconnect, evt_rx: Receiver<EventMessage>) { pub(crate) async fn runner(evt_rx: Receiver<EventMessage>) {
let mut global = GlobalEvents::default(); let mut global = GlobalEvents::default();
let mut events: Vec<EventStore> = vec![]; let mut events: Vec<EventStore> = vec![];

View File

@@ -40,10 +40,9 @@ impl Interconnect {
self.events = evt_tx; self.events = evt_tx;
let ic = self.clone();
spawn(async move { spawn(async move {
trace!("Event processor restarted."); trace!("Event processor restarted.");
super::events::runner(ic, evt_rx).await; super::events::runner(evt_rx).await;
trace!("Event processor finished."); trace!("Event processor finished.");
}); });

View File

@@ -259,7 +259,7 @@ pub fn mix_symph_indiv(
#[inline] #[inline]
fn mix_over_ref( fn mix_over_ref(
source: &AudioBufferRef, source: &AudioBufferRef<'_>,
target: &mut AudioBuffer<f32>, target: &mut AudioBuffer<f32>,
source_pos: usize, source_pos: usize,
dest_pos: usize, dest_pos: usize,
@@ -397,7 +397,7 @@ fn mix_resampled(
#[inline] #[inline]
pub(crate) fn copy_into_resampler( pub(crate) fn copy_into_resampler(
source: &AudioBufferRef, source: &AudioBufferRef<'_>,
target: &mut AudioBuffer<f32>, target: &mut AudioBuffer<f32>,
source_pos: usize, source_pos: usize,
dest_pos: usize, dest_pos: usize,

View File

@@ -15,7 +15,7 @@ pub enum InputState {
} }
impl InputState { impl InputState {
pub fn metadata(&mut self) -> Option<Metadata> { pub fn metadata(&mut self) -> Option<Metadata<'_>> {
if let Self::Ready(parsed, _) = self { if let Self::Ready(parsed, _) = self {
Some(parsed.into()) Some(parsed.into())
} else { } else {

View File

@@ -38,23 +38,20 @@ fn start_internals(core: Sender<CoreMessage>, config: &Config) -> Interconnect {
let (evt_tx, evt_rx) = flume::unbounded(); let (evt_tx, evt_rx) = flume::unbounded();
let (mix_tx, mix_rx) = flume::unbounded(); let (mix_tx, mix_rx) = flume::unbounded();
let interconnect = Interconnect { spawn(async move {
trace!("Event processor started.");
events::runner(evt_rx).await;
trace!("Event processor finished.");
});
let ic = Interconnect {
core, core,
events: evt_tx, events: evt_tx,
mixer: mix_tx, mixer: mix_tx,
}; };
let ic = interconnect.clone(); config.get_scheduler().new_mixer(config, ic.clone(), mix_rx);
spawn(async move { ic
trace!("Event processor started.");
events::runner(ic, evt_rx).await;
trace!("Event processor finished.");
});
let ic = interconnect.clone();
config.get_scheduler().new_mixer(config, ic, mix_rx);
interconnect
} }
#[instrument(skip(rx, tx))] #[instrument(skip(rx, tx))]

View File

@@ -42,7 +42,7 @@ pub enum PacketLookup {
#[derive(Debug)] #[derive(Debug)]
pub struct PlayoutBuffer { pub struct PlayoutBuffer {
playout_buffer: VecDeque<Option<StoredPacket>>, buffer: VecDeque<Option<StoredPacket>>,
playout_mode: PlayoutMode, playout_mode: PlayoutMode,
next_seq: RtpSequence, next_seq: RtpSequence,
current_timestamp: Option<RtpTimestamp>, current_timestamp: Option<RtpTimestamp>,
@@ -51,7 +51,7 @@ pub struct PlayoutBuffer {
impl PlayoutBuffer { impl PlayoutBuffer {
pub fn new(capacity: usize, next_seq: RtpSequence) -> Self { pub fn new(capacity: usize, next_seq: RtpSequence) -> Self {
Self { Self {
playout_buffer: VecDeque::with_capacity(capacity), buffer: VecDeque::with_capacity(capacity),
playout_mode: PlayoutMode::Fill, playout_mode: PlayoutMode::Fill,
next_seq, next_seq,
current_timestamp: None, current_timestamp: None,
@@ -81,13 +81,13 @@ impl PlayoutBuffer {
trace!("Packet arrived beyond playout max length."); trace!("Packet arrived beyond playout max length.");
} else { } else {
let index = desired_index as usize; let index = desired_index as usize;
while self.playout_buffer.len() <= index { while self.buffer.len() <= index {
self.playout_buffer.push_back(None); 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; self.playout_mode = PlayoutMode::Drain;
} }
} }
@@ -97,7 +97,7 @@ impl PlayoutBuffer {
return PacketLookup::Filling; return PacketLookup::Filling;
} }
let out = match self.playout_buffer.pop_front() { let out = match self.buffer.pop_front() {
Some(Some(pkt)) => { Some(Some(pkt)) => {
let rtp = RtpPacket::new(&pkt.packet) let rtp = RtpPacket::new(&pkt.packet)
.expect("FATAL: earlier valid packet now invalid (fetch)"); .expect("FATAL: earlier valid packet now invalid (fetch)");
@@ -111,7 +111,7 @@ impl PlayoutBuffer {
PacketLookup::Packet(pkt) PacketLookup::Packet(pkt)
} else { } else {
trace!("Witholding packet: ts_diff is {ts_diff}"); 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; self.playout_mode = PlayoutMode::Fill;
PacketLookup::Filling PacketLookup::Filling
} }
@@ -123,7 +123,7 @@ impl PlayoutBuffer {
None => PacketLookup::Filling, None => PacketLookup::Filling,
}; };
if self.playout_buffer.is_empty() { if self.buffer.is_empty() {
self.playout_mode = PlayoutMode::Fill; self.playout_mode = PlayoutMode::Fill;
self.current_timestamp = None; self.current_timestamp = None;
} }

View File

@@ -335,7 +335,7 @@ impl MediaSource for ToAudioBytes {
#[inline] #[inline]
fn write_out( fn write_out(
source: &AudioBufferRef, source: &AudioBufferRef<'_>,
target: &mut [u8], target: &mut [u8],
source_pos: &mut Range<usize>, source_pos: &mut Range<usize>,
spillover: &mut Vec<f32>, spillover: &mut Vec<f32>,

View File

@@ -133,7 +133,7 @@ impl Decoder for OpusDecoder {
FinalizeResult::default() FinalizeResult::default()
} }
fn last_decoded(&self) -> AudioBufferRef { fn last_decoded(&self) -> AudioBufferRef<'_> {
self.buf.as_audio_buffer_ref() self.buf.as_audio_buffer_ref()
} }
} }

View File

@@ -136,7 +136,7 @@ impl LiveInput {
/// Tries to get any information about this audio stream acquired during parsing. /// Tries to get any information about this audio stream acquired during parsing.
/// ///
/// Only exists when this input is [`LiveInput::Parsed`]. /// 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() { if let Some(parsed) = self.parsed_mut() {
Ok(parsed.into()) Ok(parsed.into())
} else { } else {

View File

@@ -205,8 +205,7 @@ impl Input {
/// will always fail with [`AudioStreamError::Unsupported`]. /// will always fail with [`AudioStreamError::Unsupported`].
pub async fn aux_metadata(&mut self) -> Result<AuxMetadata, AuxMetadataError> { pub async fn aux_metadata(&mut self) -> Result<AuxMetadata, AuxMetadataError> {
match self { match self {
Self::Lazy(ref mut composer) => composer.aux_metadata().await.map_err(Into::into), Self::Lazy(ref mut composer) | Self::Live(_, Some(ref mut composer)) =>
Self::Live(_, Some(ref mut composer)) =>
composer.aux_metadata().await.map_err(Into::into), composer.aux_metadata().await.map_err(Into::into),
Self::Live(_, None) => Err(AuxMetadataError::NoCompose), Self::Live(_, None) => Err(AuxMetadataError::NoCompose),
} }
@@ -216,7 +215,7 @@ impl Input {
/// ///
/// Only exists when this input is both [`Self::Live`] and has been fully parsed. /// Only exists when this input is both [`Self::Live`] and has been fully parsed.
/// In general, you probably want to use [`Self::aux_metadata`]. /// 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 { if let Self::Live(live, _) = self {
live.metadata() live.metadata()
} else { } else {

View File

@@ -62,7 +62,7 @@
//! [codecs and formats provided by Symphonia]: https://github.com/pdeljanov/Symphonia#formats-demuxers //! [codecs and formats provided by Symphonia]: https://github.com/pdeljanov/Symphonia#formats-demuxers
//! [audiopus]: https://github.com/lakelezz/audiopus //! [audiopus]: https://github.com/lakelezz/audiopus
#![warn(clippy::pedantic)] #![warn(clippy::pedantic, rust_2018_idioms)]
#![allow( #![allow(
// Allowed as they are too pedantic // Allowed as they are too pedantic
clippy::module_name_repetitions, clippy::module_name_repetitions,
@@ -76,6 +76,7 @@
// TODO: would require significant rewriting of all existing docs // TODO: would require significant rewriting of all existing docs
clippy::missing_errors_doc, clippy::missing_errors_doc,
clippy::missing_panics_doc, clippy::missing_panics_doc,
clippy::doc_link_with_quotes,
)] )]
mod config; mod config;

View File

@@ -28,7 +28,7 @@ pub enum TrackCommand {
/// Register an event on this track. /// Register an event on this track.
AddEvent(EventData), AddEvent(EventData),
/// Run some closure on this track, with direct access to the core object. /// 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 a copy of this track's state.
Request(Sender<TrackState>), Request(Sender<TrackState>),
/// Change the loop count/strategy of this track. /// Change the loop count/strategy of this track.

View File

@@ -150,7 +150,7 @@ impl TrackHandle {
/// [`Metadata`]: crate::input::Metadata /// [`Metadata`]: crate::input::Metadata
pub fn action<F>(&self, action: F) -> TrackResult<()> pub fn action<F>(&self, action: F) -> TrackResult<()>
where where
F: FnOnce(View) -> Option<Action> + Send + Sync + 'static, F: FnOnce(View<'_>) -> Option<Action> + Send + Sync + 'static,
{ {
self.send(TrackCommand::Do(Box::new(action))) self.send(TrackCommand::Do(Box::new(action)))
} }

View File

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