Fix segment pre-caching to progressively cache all playlist segments #59
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.
Segment pre-caching was only keeping 1-2 segments cached at a time instead of progressively filling the cache with all remaining playlist segments.
Root Cause
cache_next_segment()only cached one segment per invocation. Since it's only called when a cached segment is consumed or a new playlist arrives, the cache filled extremely slowly—leaving most segments uncached.Changes
cache_next_segment()now caches 2 segments per call instead of 1SEGMENT_CACHE_BATCH_SIZEfor maintainabilityBehavior
With 8 uncached segments and
segment_drop=6:Cache progressively fills without blocking client requests.
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.