pub(super) fn decode<R: io::Read + Send + 'static>(reader: R) -> Result<GenericMusicStream<impl Iterator<Item = f32> + Send, f32>, String> {
    let mut decoder = match Decoder::decode(reader) {
        Ok(d) => d.peekable(),
        Err(e) => return Err(format!("{:?}", e)),
    };

    let sample_rate;
    let channel_count;

    {
        // Get the sample rate and channel count.
        while let &Err(_) = decoder.peek().ok_or("Error finding audio metadata")? {
            decoder.next();
        }

        // This line should never panic
        let frame = decoder.peek().unwrap().as_ref().unwrap();

        sample_rate = frame.sample_rate;
        channel_count = frame.samples.len();
    }
    Ok(GenericMusicStream {
        samples: MP3Samples::new(decoder),
        channel_count: channel_count as u8,
        sample_rate,
    })
}
/// Create a stream that reads from an mp3
Create a stream that reads from an mp3
Create a stream that reads from an mp3
pub(super) fn decode<R: io::Read + Send + 'static>(reader: R) -> Result<GenericMusicStream<impl Iterator<Item = f32> + Send, f32>, String> {
    let mut decoder = match Decoder::decode(reader) {
        Ok(d) => d.peekable(),
        Err(e) => return Err(format!("{:?}", e)),
    };
    let sample_rate;
    let channel_count;
    {
        // Get the sample rate and channel count.
        while let &Err(_) = decoder.peek().ok_or("Error finding audio metadata")? {
            decoder.next();
        }
        // This line should never panic
        let frame = decoder.peek().unwrap().as_ref().unwrap();
        sample_rate = frame.sample_rate;
        channel_count = frame.samples.len();
    }
    Ok(GenericMusicStream {
        samples: MP3Samples::new(decoder),
        channel_count: channel_count as u8,
        sample_rate,
    })
}
pub ( super ) fn decode < R : io :: Read + Send + ' static > ( reader : R ) -> Result < GenericMusicStream < impl Iterator < Item = f32 > + Send , f32 > , String > { let mut decoder = match Decoder :: decode ( reader ) { Ok ( d ) => d . peekable ( ) , Err ( e ) => return Err ( format ! ( " " e ) ) , } ; let sample_rate ; let channel_count ; { // Get the sample rate and channel count. while let & Err ( _ ) = decoder . peek ( ) . ok_or ( " " ) ? { decoder . next ( ) ; } // This line should never panic let frame = decoder . peek ( ) . unwrap ( ) . as_ref ( ) . unwrap ( ) ; sample_rate = frame . sample_rate ; channel_count = frame . samples . len ( ) ; } Ok ( GenericMusicStream { samples : MP3Samples :: new ( decoder ) , channel_count : channel_count as u8 , sample_rate , } ) }
Create a stream that reads from an mp3
Create a stream that reads from an mp3
reader
R
reader
R