#[cfg(all(feature = "log", not(feature = "tracing")))]
use log::warn;
#[cfg(feature = "tracing")]
use tracing::warn;
use super::LoadError;
const SHRINK_THRESHOLD: usize = 4096;
mod decode_f32;
mod decode_native;
#[cfg(feature = "resampler")]
mod decode_resampled_f32;
#[cfg(feature = "resampler")]
pub(crate) use decode_resampled_f32::*;
pub(crate) use decode_f32::*;
pub(crate) use decode_native::*;
fn check_total_frames(
total_frames: &mut usize,
max_frames: usize,
packet_len: usize,
max_bytes: usize,
) -> Result<(), LoadError> {
*total_frames += packet_len;
if *total_frames > max_frames {
Err(LoadError::FileTooLarge(max_bytes))
} else {
Ok(())
}
}
fn shrink_buffer<T>(channels: &mut [Vec<T>]) {
for ch in channels.iter_mut() {
if ch.capacity() > ch.len() + SHRINK_THRESHOLD {
ch.shrink_to_fit();
}
}
}
fn decode_warning(err: &str) {
#[cfg(any(feature = "tracing", feature = "log"))]
warn!("Symphonia decode warning: {}", err);
#[cfg(not(any(feature = "tracing", feature = "log")))]
let _ = err;
}