Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
atoktoto committed Jan 8, 2024
1 parent f496c90 commit e543ca1
Show file tree
Hide file tree
Showing 36 changed files with 75 additions and 85 deletions.
1 change: 0 additions & 1 deletion symphonia-bundle-flac/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#![allow(clippy::excessive_precision)]
#![allow(clippy::identity_op)]
#![allow(clippy::manual_range_contains)]

#![no_std]

extern crate alloc;
Expand Down
2 changes: 1 addition & 1 deletion symphonia-bundle-flac/src/validate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

use core::mem;
use alloc::vec::Vec;
use core::mem;

use symphonia_core::audio::{AudioBuffer, Signal};
use symphonia_core::checksum::Md5;
Expand Down
1 change: 0 additions & 1 deletion symphonia-bundle-mp3/src/demuxer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ use symphonia_core::probe::{Descriptor, Instantiate, QueryDescriptor};
use crate::common::{FrameHeader, MpegLayer};
use crate::header::{self, MAX_MPEG_FRAME_SIZE, MPEG_HEADER_LEN};


use log::{debug, info, warn};

/// MPEG1 and MPEG2 audio elementary stream reader.
Expand Down
2 changes: 1 addition & 1 deletion symphonia-bundle-mp3/src/layer3/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
use std::fmt;

use symphonia_core::audio::{AudioBuffer, Signal};
use symphonia_core::errors::{decode_error, Result};
use symphonia_core::errors::SymphoniaError as Error;
use symphonia_core::errors::{decode_error, Result};
use symphonia_core::io::{BitReaderLtr, BufReader, ReadBitsLtr, ReadBytes};

mod bitstream;
Expand Down
2 changes: 1 addition & 1 deletion symphonia-codec-aac/src/aac/codebooks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

use symphonia_core::io::{vlc::*, ReadBitsLtr};
use symphonia_core::errors::Result;
use symphonia_core::io::{vlc::*, ReadBitsLtr};

use lazy_static::lazy_static;

Expand Down
2 changes: 1 addition & 1 deletion symphonia-core/src/audio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
use alloc::borrow::Cow;
use alloc::boxed::Box;
use alloc::vec;
use alloc::vec::Vec;
use core::fmt;
use core::marker::PhantomData;
use core::mem;
use alloc::vec::Vec;

use arrayvec::ArrayVec;
use bitflags::bitflags;
Expand Down
2 changes: 1 addition & 1 deletion symphonia-core/src/dsp/fft.rs
Original file line number Diff line number Diff line change
Expand Up @@ -409,8 +409,8 @@ fn fft2(x: &mut [Complex; 2]) {

#[cfg(test)]
mod tests {
use alloc::vec::Vec;
use super::*;
use alloc::vec::Vec;
use core::f64;

/// Compute a naive DFT.
Expand Down
2 changes: 1 addition & 1 deletion symphonia-core/src/dsp/mdct/simd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
//! The Modified Discrete Cosine Transform (MDCT) implemented with SIMD optimizations.
use alloc::boxed::Box;
use alloc::vec::Vec;
use alloc::sync::Arc;
use alloc::vec;
use alloc::vec::Vec;

use rustfft::num_complex::Complex;

Expand Down
4 changes: 2 additions & 2 deletions symphonia-core/src/dsp/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
//! The `dsp` module provides efficient implementations of common signal processing algorithms.
pub mod complex;
#[cfg(feature="fft")]
#[cfg(feature = "fft")]
pub mod fft;
#[cfg(feature="fft")]
#[cfg(feature = "fft")]
pub mod mdct;
11 changes: 5 additions & 6 deletions symphonia-core/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,17 @@

//! The `errors` module defines the common error type.
use core::{result};
use core::fmt;
use core::fmt::{Display};
use alloc::boxed::Box;
use core::fmt;
use core::fmt::Display;

Check warning on line 12 in symphonia-core/src/errors.rs

View workflow job for this annotation

GitHub Actions / Check ubuntu-latest

unused import: `core::fmt::Display`

Check warning on line 12 in symphonia-core/src/errors.rs

View workflow job for this annotation

GitHub Actions / Check ubuntu-latest

unused import: `core::fmt::Display`

Check warning on line 12 in symphonia-core/src/errors.rs

View workflow job for this annotation

GitHub Actions / Test x86_64-unknown-linux-gnu on ubuntu-latest

unused import: `core::fmt::Display`

Check warning on line 12 in symphonia-core/src/errors.rs

View workflow job for this annotation

GitHub Actions / Check windows-latest

unused import: `core::fmt::Display`

Check warning on line 12 in symphonia-core/src/errors.rs

View workflow job for this annotation

GitHub Actions / Check windows-latest

unused import: `core::fmt::Display`

Check warning on line 12 in symphonia-core/src/errors.rs

View workflow job for this annotation

GitHub Actions / Check macos-latest

unused import: `core::fmt::Display`

Check warning on line 12 in symphonia-core/src/errors.rs

View workflow job for this annotation

GitHub Actions / Check macos-latest

unused import: `core::fmt::Display`
use core::result;

#[cfg(not(feature = "std"))]
use core::error::Error as StdError;

use core::ops::Deref;
#[cfg(feature = "std")]
use std::error::Error as StdError;
use core::ops::Deref;


/// `SeekErrorKind` is a list of generic reasons why a seek may fail.
#[derive(Debug)]
Expand Down Expand Up @@ -116,7 +115,7 @@ impl From<std::io::Error> for SymphoniaError {
match err.kind() {
std::io::ErrorKind::Interrupted => SymphoniaError::IoInterruptedError(Box::new(err)),
std::io::ErrorKind::UnexpectedEof => SymphoniaError::EndOfFile,
_ => SymphoniaError::IoError(Box::new(err))
_ => SymphoniaError::IoError(Box::new(err)),
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions symphonia-core/src/formats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
//! The `format` module provides the traits and support structures necessary to implement media
//! demuxers.
use alloc::boxed::Box;
use alloc::string::String;
use alloc::vec::Vec;
use crate::codecs::CodecParameters;
use crate::errors::Result;
use crate::io::{BufReader, MediaSourceStream};
use crate::meta::{Metadata, Tag};
use crate::units::{Time, TimeStamp};
use alloc::boxed::Box;
use alloc::string::String;
use alloc::vec::Vec;

pub mod prelude {
//! The `formats` module prelude.
Expand Down Expand Up @@ -330,8 +330,8 @@ impl Packet {
pub mod util {
//! Helper utilities for implementing `FormatReader`s.
use alloc::vec::Vec;
use super::Packet;
use alloc::vec::Vec;

/// A `SeekPoint` is a mapping between a sample or frame number to byte offset within a media
/// stream.
Expand Down
12 changes: 6 additions & 6 deletions symphonia-core/src/io/bit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@

use core::cmp::min;

use crate::errors::Result;
use crate::errors::SymphoniaError as Error;
use crate::io::ReadBytes;
use crate::util::bits::*;
use crate::errors::{Result};
use crate::errors::SymphoniaError as Error;

fn end_of_bitstream_error<T>() -> Result<T> {
Err(Error::Other("unexpected end of bitstream"))
Expand All @@ -19,11 +19,11 @@ fn end_of_bitstream_error<T>() -> Result<T> {
pub mod vlc {
//! The `vlc` module provides support for decoding variable-length codes (VLC).
use core::cmp::max;
use crate::errors::Result;
use crate::errors::SymphoniaError as Error;
use alloc::collections::{BTreeMap, VecDeque};
use alloc::vec::Vec;
use crate::errors::{Result};
use crate::errors::SymphoniaError as Error;
use core::cmp::max;

fn codebook_error<T>(desc: &'static str) -> Result<T> {
Err(Error::Other(desc))
Expand Down Expand Up @@ -1469,10 +1469,10 @@ impl<'a> FiniteBitStream for BitReaderRtl<'a> {

#[cfg(test)]
mod tests {
use alloc::vec::Vec;
use super::vlc::{BitOrder, Codebook, CodebookBuilder, Entry8x8};
use super::{BitReaderLtr, ReadBitsLtr};
use super::{BitReaderRtl, ReadBitsRtl};
use alloc::vec::Vec;

#[test]
#[allow(clippy::bool_assert_comparison)]
Expand Down
2 changes: 1 addition & 1 deletion symphonia-core/src/io/buf_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use core::cmp;

use super::{FiniteStream, ReadBytes};
use crate::errors::{Result};
use crate::errors::Result;
use crate::errors::SymphoniaError as Error;

#[inline(always)]
Expand Down
13 changes: 7 additions & 6 deletions symphonia-core/src/io/media_source_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ impl Read for MediaSourceStream {
buf = &mut buf[count..];
self.consume(count);
}
Err(SymphoniaError::IoInterruptedError(_)) => {}
Err(SymphoniaError::IoInterruptedError(_)) => {}
Err(e) => return Err(e),
}
}
Expand Down Expand Up @@ -325,7 +325,7 @@ impl ReadBytes for MediaSourceStream {
Ok(count) => {
buf = &mut buf[count..];
}
Err(SymphoniaError::IoInterruptedError(_)) => {}
Err(SymphoniaError::IoInterruptedError(_)) => {}
Err(e) => return Err(e),
}
}
Expand Down Expand Up @@ -478,7 +478,8 @@ impl Read for &[u8] {
// for a single byte the overhead is significant.
if amt == 1 {
buf[0] = a[0];
} else {
}
else {
buf[..amt].copy_from_slice(a);
}

Expand All @@ -490,12 +491,12 @@ impl Read for &[u8] {
#[cfg(feature = "std")]
#[cfg(test)]
mod tests {
use super::{MediaSourceStream, ReadBytes, SeekBuffered};
use crate::io::Read;
use alloc::boxed::Box;
use alloc::vec;
use alloc::vec::Vec;
use super::{MediaSourceStream, ReadBytes, SeekBuffered};
use std::io::{Cursor};
use crate::io::Read;
use std::io::Cursor;

/// Generate a random vector of bytes of the specified length using a PRNG.
fn generate_random_bytes(len: usize) -> Box<[u8]> {
Expand Down
34 changes: 14 additions & 20 deletions symphonia-core/src/io/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
//! either the [`ReadBitsLtr`] or [`ReadBitsRtl`] traits depending on the order in which they
//! consume bits.
use crate::errors::{Result, SymphoniaError};
use alloc::boxed::Box;
use alloc::vec;
use alloc::vec::Vec;
use core::mem;
use crate::errors::{SymphoniaError, Result};

#[cfg(feature = "std")]
use std::io;
Expand Down Expand Up @@ -82,20 +82,16 @@ pub trait Read {
}

/// Warning: The default implementation in io::Read is much faster
fn default_slow_read_to_end<R: Read + ?Sized>(
r: &mut R,
buf: &mut Vec<u8>
) -> Result<usize> {

fn default_slow_read_to_end<R: Read + ?Sized>(r: &mut R, buf: &mut Vec<u8>) -> Result<usize> {
let mut cnt: usize = 0;
let mut read_buf: [u8; 1024] = [0; 1024];

loop {
let r = r.read(&mut read_buf);
let r = r.read(&mut read_buf);
let n = match r {
Ok(0) => break,
Ok(n) => n,
Err(SymphoniaError::IoInterruptedError(_)) => 0, // Ignored
Err(SymphoniaError::IoInterruptedError(_)) => 0, // Ignored
Err(err) => return Err(err),
};

Expand All @@ -107,29 +103,29 @@ fn default_slow_read_to_end<R: Read + ?Sized>(
}

fn default_read_vectored<F>(read: F, bufs: &mut [IoSliceMut<'_>]) -> Result<usize>
where
F: FnOnce(&mut [u8]) -> Result<usize>,
where
F: FnOnce(&mut [u8]) -> Result<usize>,
{
let buf = bufs.iter_mut().find(|b| !b.is_empty()).map_or(&mut [][..], |b| &mut **b);
read(buf)
}

#[cfg(feature = "std")]
impl <T: std::io::Read> Read for T {
impl<T: std::io::Read> Read for T {
fn read(&mut self, buf: &mut [u8]) -> Result<usize> {
self.read(buf).map_err(|e| { SymphoniaError::from(e) })
self.read(buf).map_err(|e| SymphoniaError::from(e))
}
}

#[cfg(feature = "std")]
impl <T: std::io::Seek> Seek for T {
impl<T: std::io::Seek> Seek for T {
fn seek(&mut self, from: SeekFrom) -> Result<u64> {
let from = match from {
SeekFrom::Start(x) => io::SeekFrom::Start(x),
SeekFrom::End(x) => io::SeekFrom::End(x),
SeekFrom::Current(x) => io::SeekFrom::Current(x),
};
self.seek(from).map_err(|e| { SymphoniaError::from(e) })
self.seek(from).map_err(|e| SymphoniaError::from(e))
}
}

Expand All @@ -139,7 +135,7 @@ impl <T: std::io::Seek> Seek for T {
/// Despite requiring the [`std::io::Seek`] trait, seeking is an optional capability that can be
/// queried at runtime.
// pub trait MediaSource: io::Read + io::Seek + Send + Sync {
pub trait MediaSource: Read + Seek {
pub trait MediaSource: Read + Seek {
/// Returns if the source is seekable. This may be an expensive operation.
fn is_seekable(&self) -> bool;

Expand Down Expand Up @@ -616,11 +612,9 @@ mod no_std_compat {
buf: &'a mut [u8],
}

impl <'a> IoSliceMut<'a> {
impl<'a> IoSliceMut<'a> {
pub fn new(buf: &'a mut [u8]) -> IoSliceMut<'a> {
IoSliceMut {
buf
}
IoSliceMut { buf }
}
}

Expand All @@ -639,4 +633,4 @@ mod no_std_compat {
self.buf
}
}
}
}
1 change: 0 additions & 1 deletion symphonia-core/src/io/monitor_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.


use super::ReadBytes;
use crate::errors::Result;

Expand Down
2 changes: 1 addition & 1 deletion symphonia-core/src/io/scoped_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

use core::cmp;
use crate::errors::{Result, SymphoniaError};
use core::cmp;

use super::{FiniteStream, ReadBytes, SeekBuffered};

Expand Down
1 change: 0 additions & 1 deletion symphonia-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#![allow(clippy::excessive_precision)]
#![allow(clippy::identity_op)]
#![allow(clippy::manual_range_contains)]

#![cfg_attr(not(feature = "std"), feature(error_in_core))]

extern crate alloc;
Expand Down
6 changes: 3 additions & 3 deletions symphonia-core/src/meta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@

//! The `meta` module defines basic metadata elements, and management structures.
use alloc::borrow::Cow;
use alloc::boxed::Box;
use alloc::collections::VecDeque;
use alloc::string::String;
use alloc::string::ToString;
use alloc::vec::Vec;
use alloc::borrow::Cow;
use alloc::collections::VecDeque;
use core::convert::From;
use core::fmt;
use core::num::NonZeroU32;
use alloc::string::ToString;

use crate::errors::Result;
use crate::io::MediaSourceStream;
Expand Down
Loading

0 comments on commit e543ca1

Please sign in to comment.