rodio
rodio copied to clipboard
How to detect when the Decoder has reached the end of the audio file?
I'm using this function that should return true when the decoder has reached the end of the audio file:
fn sum_channels_return_reached_end(
channel_count: usize,
decoder: &mut Decoder<BufReader<File>>,
output: &mut [f32],
) -> bool {
let mut reached_end = true;
for (chunk, dst) in decoder.chunks(channel_count).into_iter().zip(output.iter_mut()) {
let (sum, count) = chunk.map(sample_conv).fold((0., 0), |(s, c), v| (s + v, c + 1));
*dst = sum / count as f32;
reached_end = false;
}
reached_end
}
It works with wav files but always returns false for mp3 files:
The decoder iterator still yields values after the end of the mp3 file. I tested with several mp3 files, all behave the same.
Is there a reliable way to detect when the decoder has reached the end of the audio file?
next_frame seems to always return Some. So this is a minimp3 bug, not ours.
Maybe our bug after all. #297 has been merged. Could you try out latest master of rodio and check whether the issue still persists?