Skip to content

Commit

Permalink
drainOutputBuffer return false on EOS
Browse files Browse the repository at this point in the history
I can't see how this would ever make a difference, but there's no
point in returning true. Either we've really reached EOS (in which
case outputStreamEnded will be true and the next drainOutputBuffer
will be turned into a no-op) or we've re-initialized the codec (in
which case there wont be anything to drain since we wont have fed
anything to the codec yet).

This change should also prevent the hypothetical NPE described in
issue #2096, although we're unsure how that NPE would occur unless
MediaCodecRenderer has been extended in an unusual way.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=140338581
  • Loading branch information
ojw28 committed Nov 30, 2016
1 parent f7132a7 commit 73220be
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,9 @@ public void render(long positionUs, long elapsedRealtimeUs) throws ExoPlaybackEx
if (codec != null) {
TraceUtil.beginSection("drainAndFeed");
while (drainOutputBuffer(positionUs, elapsedRealtimeUs)) {}
while (feedInputBuffer()) {}
if (codec != null) {
while (feedInputBuffer()) {}
}
TraceUtil.endSection();
} else if (format != null) {
skipToKeyframeBefore(positionUs);
Expand Down Expand Up @@ -864,7 +866,7 @@ private boolean drainOutputBuffer(long positionUs, long elapsedRealtimeUs)
// The dequeued buffer indicates the end of the stream. Process it immediately.
processEndOfStream();
outputIndex = C.INDEX_UNSET;
return true;
return false;
} else {
// The dequeued buffer is a media buffer. Do some initial setup. The buffer will be
// processed by calling processOutputBuffer (possibly multiple times) below.
Expand All @@ -885,7 +887,6 @@ private boolean drainOutputBuffer(long positionUs, long elapsedRealtimeUs)
if (codecNeedsEosPropagationWorkaround && (inputStreamEnded
|| codecReinitializationState == REINITIALIZATION_STATE_WAIT_END_OF_STREAM)) {
processEndOfStream();
return true;
}
return false;
}
Expand Down

0 comments on commit 73220be

Please sign in to comment.