rodio icon indicating copy to clipboard operation
rodio copied to clipboard

Seek breaks span

Open yara-blue opened this issue 11 months ago • 4 comments

Seek might need padding silence when resample rate or channel count change. Since the consumer has no way to know they have.

Alternative, make seek an exception and make the consumer recall sample_rate, channel count & span len.

yara-blue avatar Jan 23 '25 16:01 yara-blue

We may require that all variable sources are wrapped into something like UniformSourceIterator, so in most cases spans can only change channels, not sample rate...

PetrGlad avatar Jan 23 '25 18:01 PetrGlad

would not help since seek is implemented at the decoder level. Those inherently do not have a uniform sample rate. And we can not resample to such a uniform source if the spans are not correct.

yara-blue avatar Jan 24 '25 10:01 yara-blue

At least it would help to not care about the sample rate changes downstream, in sources that come after decoders.

With decoders themselves, I am thinking of more comprehensive test harness that would generate both various source audio files and random seeks, something like property testing but for our case.

PetrGlad avatar Jan 25 '25 08:01 PetrGlad

At least it would help to not care about the sample rate changes downstream

it would, but it would come at a performance cost. Hifi-resampling is performance intensive, resampling everything at the edges might be wasteful. Maybe we can make the resampler very lazy, that would help....

Honestly I think we would need a prototype before making any decision. A rodio fork that only supports a few sources (lets say queue & mix) and works by informed resampling at the input. With informed I mean that idea I had earlier with the output communicating its preferred sample rate down and everything adjusting along the way.

After I finish fixing queue I can work on the informed sample rate bit, once that's done you could make the prototype. Then we have to figure out some workloads to compare the implementations with. If the performance difference is positive or trivial the code simplifications might be worth it.

yara-blue avatar Jan 25 '25 11:01 yara-blue