Conversation
The partition point was searched over a sub-slice of the packets, and so is relative to the start of that sub-slice, but the result was used to index all packets. When seeking forwards from any packet other than the first, the seek landed on an earlier packet than the one requested. The start frame of every packet is monotonically increasing, so searching the sub-slice yields the same packet as searching all of them. Search all packets instead. This also permits seeking once the end of the stream has been reached, which previously failed because the current packet index was then out-of-bounds.
baylesj
force-pushed
the
fix/caf-seek-index
branch
from
August 13, 2026 05:31
785e02b to
ed3e8f1
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently, the seeking logic for the CAF audio container format searches over a sub-slice of the packets relative to the current point in the file, however the result is used to index all packets, causing an offset error that gets worse the deeper into the audio file you get.
This PR updates the logic to search all packets instead, regardless of current position. The implementation uses a binary search so this decision is cheap and also more robust. Test coverage is also added to reduce the risk of a regression.
Progress on #501