rodio icon indicating copy to clipboard operation
rodio copied to clipboard

Elapsed Duration functionality for the Decoder/LoopedDecoder

Open BastianHentschel opened this issue 2 years ago • 3 comments

The commits add a member to the Decoders, which contains the required information for the elapsed duration.

The functionality is implemented in the impl<R> Iterator for Decoder<R>/LoopedDecoder<R> and ticks an AtomicUsize up each read sample. With the channel count and sample rate the effective elapsed duration of a Decoder can be calculated.

BastianHentschel avatar Sep 07 '23 11:09 BastianHentschel

This could maybe be a solution to #474 and the relevant part of #457

The total duration can be gotten beforehand from the decoder and be cached for later use.

BastianHentschel avatar Sep 07 '23 11:09 BastianHentschel

Could also be useful for #443, I was planning to optimize that in PR #513 by seeking if the duration to skip is long however for that I need the elapsed playtime/duration. (seek = elapsed + skip)

yara-blue avatar Oct 04 '23 14:10 yara-blue

This might fit better as a new method on Source with a default implementation returning None (just like try_seek). Will be a little more work since now all the adapters need to be adjusted. Though one can easily follow what try_seek does for most cases.

The bigger question is what to do about Sink. Since that is what most media player like uses for rodio will use.

yara-blue avatar Apr 16 '24 19:04 yara-blue