mirror of
https://github.com/RustAudio/rodio
synced 2024-11-10 06:04:16 +00:00
style clippy fixes
This commit is contained in:
parent
6f1f44f04a
commit
34366fe656
5 changed files with 23 additions and 25 deletions
|
@ -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() {
|
||||
|
|
|
@ -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(
|
||||
SeekMode::Accurate,
|
||||
SeekTo::Time {
|
||||
time,
|
||||
track_id: None,
|
||||
},
|
||||
).map_err(SeekError::BaseSeek)?;
|
||||
let seek_res = self
|
||||
.format
|
||||
.seek(
|
||||
SeekMode::Accurate,
|
||||
SeekTo::Time {
|
||||
time,
|
||||
track_id: None,
|
||||
},
|
||||
)
|
||||
.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 {
|
||||
|
|
|
@ -76,7 +76,7 @@ where
|
|||
None
|
||||
}
|
||||
|
||||
/// seek is broken, https://github.com/RustAudio/lewton/issues/73.
|
||||
/// seek is broken, https://github.com/RustAudio/lewton/issues/73.
|
||||
// We could work around it by:
|
||||
// - using unsafe to create an instance of Self
|
||||
// - use mem::swap to turn the &mut self into a mut self
|
||||
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -180,7 +180,7 @@ where
|
|||
// We would then however need to enable seeking backwards across sources too.
|
||||
// That no longer seems in line with the queue behaviour.
|
||||
//
|
||||
// A final pain point is that we would need the total duration for the
|
||||
// A final pain point is that we would need the total duration for the
|
||||
// next few songs.
|
||||
#[inline]
|
||||
fn try_seek(&mut self, pos: Duration) -> Result<(), SeekError> {
|
||||
|
|
Loading…
Reference in a new issue