-
Notifications
You must be signed in to change notification settings - Fork 6k
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
Stuck buffering while tunneling. #6407
Draft
stevemayhew
wants to merge
2
commits into
google:dev-v2
Choose a base branch
from
TiVo:stuck-buffering-tunnel-issue
base: dev-v2
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -145,6 +145,8 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer { | |
/* package */ @Nullable OnFrameRenderedListenerV23 tunnelingOnFrameRenderedListener; | ||
@Nullable private VideoFrameMetadataListener frameMetadataListener; | ||
|
||
private long lastInputTimeUs; | ||
private long lastOutputTimeUs; | ||
/** | ||
* @param context A context. | ||
* @param mediaCodecSelector A decoder selector. | ||
|
@@ -231,6 +233,8 @@ public MediaCodecVideoRenderer( | |
frameReleaseTimeHelper = new VideoFrameReleaseTimeHelper(this.context); | ||
eventDispatcher = new EventDispatcher(eventHandler, eventListener); | ||
deviceNeedsNoPostProcessWorkaround = deviceNeedsNoPostProcessWorkaround(); | ||
lastInputTimeUs = C.TIME_UNSET; | ||
lastOutputTimeUs = C.TIME_UNSET; | ||
joiningDeadlineMs = C.TIME_UNSET; | ||
currentWidth = Format.NO_VALUE; | ||
currentHeight = Format.NO_VALUE; | ||
|
@@ -370,6 +374,8 @@ protected void onPositionReset(long positionUs, boolean joining) throws ExoPlayb | |
clearRenderedFirstFrame(); | ||
initialPositionUs = C.TIME_UNSET; | ||
consecutiveDroppedFrameCount = 0; | ||
lastInputTimeUs = C.TIME_UNSET; | ||
lastOutputTimeUs = C.TIME_UNSET; | ||
if (joining) { | ||
setJoiningDeadlineMs(); | ||
} else { | ||
|
@@ -409,7 +415,15 @@ public boolean isReady() { | |
*/ | ||
@Override | ||
protected boolean hasOutputReady() { | ||
return tunneling && buffersInCodecCount > 0 || super.hasOutputReady(); | ||
boolean fifoReady = true; | ||
if (lastOutputTimeUs != C.TIME_UNSET) { | ||
long fifoLengthUs = lastInputTimeUs - lastOutputTimeUs; | ||
|
||
// make sure there is at least 1/3s of video available in decoder FIFO, | ||
// otherwise decoder may start stalling | ||
fifoReady = fifoLengthUs > 333333; | ||
} | ||
return tunneling && fifoReady || super.hasOutputReady(); | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As the comment says, in tunneling mode once we have queued buffers to the video codec to decode it will render it when the matching audio syncs up. The bug occurs because the audio track is stopped before the audio matching the video PTS is queued thus stalling the video codec forever. |
||
@Override | ||
|
@@ -858,6 +872,7 @@ private void notifyFrameMetadataListener( | |
|
||
/** Called when a buffer was processed in tunneling mode. */ | ||
protected void onProcessedTunneledBuffer(long presentationTimeUs) { | ||
lastOutputTimeUs = presentationTimeUs; | ||
@Nullable Format format = updateOutputFormatForTime(presentationTimeUs); | ||
if (format != null) { | ||
processOutputFormat(getCodec(), format.width, format.height); | ||
|
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.
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.
Here we are trying to use FIFO length as renderer readiness criteria. If the frame rate is low such as 1fps on music channels the length would still be satisfactory and player wouldn't go into buffering state as long as there is a frame queued in the FIFO. If network bandwidth is low the FIFO length will get close to zero before decoder starts stalling. It's important to note that Broadcom's decoder will stall before rendering last few frames so zero FIFO length cannot be used as a criteria. The 333ms value is somewhat experimental. It was chosen to accommodate at least 10 frames of 30fps stream.
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.
@andrewlewis @ojw28 Where are you guys at with addressing this issue. I'm preparing to update our code base to what will likely by your 2.11.5 release. We would very much like to not keep merging conflicted changes to the
MediaCodecVideoRenderer
, for obvious reasons.Pretty sure we can send you an STB (Broadcom based) that reproduces the issue #6366 I think I included the URL for a section of music choice content that reproduces the issue 100% of the time
We are also see this, as Dasha explained, in other streams where audio is buffered sufficiently ahead of video. As I'm sure you guys are aware, Broadcom codecs often require some special spoon feeding.
Thanks again for looking at this with us, please tell me what I need to do to help the process along.