New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve far seek performance of chunkSampleStream #2318
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good; thanks! I think you can make a few further simplifications, but otherwise think we're good to get this merged. Please take a look.
* Seeks to the specified position in microseconds. | ||
* | ||
* @param positionUs The seek position in microseconds. | ||
*/ | ||
public void seekToUs(long positionUs) { | ||
lastSeekPositionUs = positionUs; | ||
// If we're not pending a reset, see if we can seek within the sample queue. | ||
boolean seekInsideBuffer = !isPendingReset() && sampleQueue.skipToKeyframeBefore(positionUs); | ||
boolean seekInsideBuffer = !isPendingReset() && | ||
sampleQueue.skipToKeyframeBefore(positionUs, isWithinLastChunk(positionUs)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure you need to be as sophisticated as checking whether the position is within the last chunk. Isn't it sufficient just to pass positionUs < getNextLoadPositionUs()
as the second argument? I don't think passing true does any harm in cases where positionUs
is earlier than the last chunk.
This allows you to remove your isWithinLastChunk
and getCurrentLoadPosition
methods ;).
* @return Whether the skip was successful. | ||
*/ | ||
public boolean skipToKeyframeBefore(long timeUs) { | ||
long nextOffset = infoQueue.skipToKeyframeBefore(timeUs); | ||
long nextOffset = infoQueue.skipToKeyframeBefore(timeUs, false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can replace the whole body of this method with just:
return skipToKeyframeBefore(timeUs, false)
Rework to make the patch accordingly by @ojw28 kindly suggestions #as #2247.
Issue report: #2253