style clippy fixes

This commit is contained in:
dvdsk 2024-04-06 12:02:51 +02:00
parent 6f1f44f04a
commit 34366fe656
No known key found for this signature in database
GPG key ID: 6CF9D20C5709A836
5 changed files with 23 additions and 25 deletions

View file

@ -104,7 +104,7 @@ where
let new_pos = new_pos.next_multiple_of(self.channels() as usize);
let new_pos = new_pos - curr_channel;
self.pos = new_pos as usize;
self.pos = new_pos;
Ok(())
}
}
@ -172,8 +172,8 @@ mod tests {
#[cfg(test)]
mod try_seek {
use std::time::Duration;
use super::*;
use std::time::Duration;
#[test]
fn channel_order_stays_correct() {

View file

@ -32,7 +32,10 @@ pub(crate) struct SymphoniaDecoder {
}
impl SymphoniaDecoder {
pub(crate) fn new(mss: MediaSourceStream, extension: Option<&str>) -> Result<Self, DecoderError> {
pub(crate) fn new(
mss: MediaSourceStream,
extension: Option<&str>,
) -> Result<Self, DecoderError> {
match SymphoniaDecoder::init(mss, extension) {
Err(e) => match e {
Error::IoError(e) => Err(DecoderError::IoError(e.to_string())),
@ -73,13 +76,8 @@ impl SymphoniaDecoder {
None => return Ok(None),
};
let mut decoder = symphonia::default::get_codecs().make(
&stream.codec_params,
&DecoderOptions {
verify: true,
..Default::default()
},
)?;
let mut decoder = symphonia::default::get_codecs()
.make(&stream.codec_params, &DecoderOptions { verify: true })?;
let total_duration = stream
.codec_params
.time_base
@ -164,13 +162,16 @@ impl Source for SymphoniaDecoder {
// make sure the next sample is for the right channel
let to_skip = self.current_frame_offset % self.channels() as usize;
let seek_res = self.format.seek(
let seek_res = self
.format
.seek(
SeekMode::Accurate,
SeekTo::Time {
time,
track_id: None,
},
).map_err(SeekError::BaseSeek)?;
)
.map_err(SeekError::BaseSeek)?;
self.refine_position(seek_res)?;
self.current_frame_offset += to_skip;
@ -196,10 +197,7 @@ impl SymphoniaDecoder {
fn refine_position(&mut self, seek_res: SeekedTo) -> Result<(), source::SeekError> {
let mut samples_to_pass = seek_res.required_ts - seek_res.actual_ts;
let packet = loop {
let candidate = self
.format
.next_packet()
.map_err(SeekError::Refining)?;
let candidate = self.format.next_packet().map_err(SeekError::Refining)?;
if candidate.dur() > samples_to_pass {
break candidate;
} else {

View file

@ -103,7 +103,7 @@ where
fn next(&mut self) -> Option<i16> {
if let Some(sample) = self.current_data.get(self.next).copied() {
self.next += 1;
if self.current_data.len() == 0 {
if self.current_data.is_empty() {
if let Ok(Some(data)) = self.stream_reader.read_dec_packet_itl() {
self.current_data = data;
self.next = 0;

View file

@ -143,7 +143,7 @@ where
self.reader
.reader
.seek(new_pos as u32)
.seek(new_pos)
.map_err(SeekError::HoundDecoder)?;
self.reader.samples_read = new_pos * self.channels() as u32;