Skip to content

Commit

Permalink
Wait for first sync frame in MediaCodecRenderer
Browse files Browse the repository at this point in the history
For the video renderer, it's not true that the source always
provides from a sync frame specifically in the case where
the surface has been replaced on the renderer. In this case
the source doesn't know that it should be providing from a
sync frame.

Issue: #2093

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=145562222
  • Loading branch information
ojw28 committed Jan 25, 2017
1 parent 98db14e commit 6f5c7b3
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ private static String buildCustomDiagnosticInfo(int errorCode) {
private boolean inputStreamEnded;
private boolean outputStreamEnded;
private boolean waitingForKeys;
private boolean waitingForFirstSyncFrame;

protected DecoderCounters decoderCounters;

Expand Down Expand Up @@ -366,6 +367,7 @@ protected final void maybeInitCodec() throws ExoPlaybackException {
? (SystemClock.elapsedRealtime() + MAX_CODEC_HOTSWAP_TIME_MS) : C.TIME_UNSET;
inputIndex = C.INDEX_UNSET;
outputIndex = C.INDEX_UNSET;
waitingForFirstSyncFrame = true;
decoderCounters.decoderInitCount++;
}

Expand Down Expand Up @@ -504,6 +506,7 @@ protected void flushCodec() throws ExoPlaybackException {
codecHotswapDeadlineMs = C.TIME_UNSET;
inputIndex = C.INDEX_UNSET;
outputIndex = C.INDEX_UNSET;
waitingForFirstSyncFrame = true;
waitingForKeys = false;
shouldSkipOutputBuffer = false;
decodeOnlyPresentationTimestamps.clear();
Expand Down Expand Up @@ -633,6 +636,16 @@ private boolean feedInputBuffer() throws ExoPlaybackException {
}
return false;
}
if (waitingForFirstSyncFrame && !buffer.isKeyFrame()) {
buffer.clear();
if (codecReconfigurationState == RECONFIGURATION_STATE_QUEUE_PENDING) {
// The buffer we just cleared contained reconfiguration data. We need to re-write this
// data into a subsequent buffer (if there is one).
codecReconfigurationState = RECONFIGURATION_STATE_WRITE_PENDING;
}
return true;
}
waitingForFirstSyncFrame = false;
boolean bufferEncrypted = buffer.isEncrypted();
waitingForKeys = shouldWaitForKeys(bufferEncrypted);
if (waitingForKeys) {
Expand Down

0 comments on commit 6f5c7b3

Please sign in to comment.