roc-streaming / roc-toolkit

Real-time audio streaming over the network.
https://roc-streaming.org
Mozilla Public License 2.0
1.02k stars 203 forks source link

Support soft and hard reads #730

Closed gavv closed 1 week ago

gavv commented 2 weeks ago

Summary

Implement two reading modes for IFrameReader: soft read and hard read.

Hard read is current behavior - return as much samples as possible (up to requested size), fill gaps caused by packet loss with zeros.

Soft read enables new behavior - stop reading when encountered gap (caused by packet loss). E.g. when 10 samples requested, but only 5 samples are available, and then there is a gap, only 5 samples will be returned (using partial read mechanism implemented in #615).

Use-cases

Soft reads are needed when next chunk in pipeline can help if it arrived earlier than deadline, but on the other hand if it haven't arrived yet, we don't want to mark it as late and create a gap.

It can be used in:

Impl