Skip to content

Commit

Permalink
Merge pull request #61 from tomaka/wave-load-better
Browse files Browse the repository at this point in the history
Make `Wave::load_slice` more flexible
  • Loading branch information
SamiPerttu authored Nov 3, 2024
2 parents c4e1e0b + 30edd0e commit 801ad0a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,17 @@ impl Wave {

/// Load first track of audio from the given slice.
/// Supported formats are anything that Symphonia can read.
pub fn load_slice(slice: &'static [u8]) -> WaveResult<Wave> {
pub fn load_slice<S: AsRef<[u8]> + Send + Sync + 'static>(slice: S) -> WaveResult<Wave> {
Wave::load_slice_track(slice, None)
}

/// Load audio from the given slice. Track can be optionally selected.
/// If not selected, the first track with a known codec will be loaded.
/// Supported formats are anything that Symphonia can read.
pub fn load_slice_track(slice: &'static [u8], track: Option<usize>) -> WaveResult<Wave> {
pub fn load_slice_track<S: AsRef<[u8]> + Send + Sync + 'static>(
slice: S,
track: Option<usize>,
) -> WaveResult<Wave> {
let hint = Hint::new();
let source: Box<dyn MediaSource> = Box::new(Cursor::new(slice));
Wave::decode(source, track, hint)
Expand Down

0 comments on commit 801ad0a

Please sign in to comment.