Mark dropped buffers while joining as skipped.
These buffers are intentionally dropped to catch up with the playing audio. Mark them as skipped accordingly. PiperOrigin-RevId: 268703410
This commit is contained in:
parent
dc12982bd1
commit
65748fa8ee
@ -836,11 +836,17 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
|
|||||||
bufferPresentationTimeUs, unadjustedFrameReleaseTimeNs);
|
bufferPresentationTimeUs, unadjustedFrameReleaseTimeNs);
|
||||||
earlyUs = (adjustedReleaseTimeNs - systemTimeNs) / 1000;
|
earlyUs = (adjustedReleaseTimeNs - systemTimeNs) / 1000;
|
||||||
|
|
||||||
|
boolean treatDroppedBuffersAsSkipped = joiningDeadlineMs != C.TIME_UNSET;
|
||||||
if (shouldDropBuffersToKeyframe(earlyUs, elapsedRealtimeUs, isLastBuffer)
|
if (shouldDropBuffersToKeyframe(earlyUs, elapsedRealtimeUs, isLastBuffer)
|
||||||
&& maybeDropBuffersToKeyframe(codec, bufferIndex, presentationTimeUs, positionUs)) {
|
&& maybeDropBuffersToKeyframe(
|
||||||
|
codec, bufferIndex, presentationTimeUs, positionUs, treatDroppedBuffersAsSkipped)) {
|
||||||
return false;
|
return false;
|
||||||
} else if (shouldDropOutputBuffer(earlyUs, elapsedRealtimeUs, isLastBuffer)) {
|
} else if (shouldDropOutputBuffer(earlyUs, elapsedRealtimeUs, isLastBuffer)) {
|
||||||
|
if (treatDroppedBuffersAsSkipped) {
|
||||||
|
skipOutputBuffer(codec, bufferIndex, presentationTimeUs);
|
||||||
|
} else {
|
||||||
dropOutputBuffer(codec, bufferIndex, presentationTimeUs);
|
dropOutputBuffer(codec, bufferIndex, presentationTimeUs);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1033,11 +1039,18 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
|
|||||||
* @param index The index of the output buffer to drop.
|
* @param index The index of the output buffer to drop.
|
||||||
* @param presentationTimeUs The presentation time of the output buffer, in microseconds.
|
* @param presentationTimeUs The presentation time of the output buffer, in microseconds.
|
||||||
* @param positionUs The current playback position, in microseconds.
|
* @param positionUs The current playback position, in microseconds.
|
||||||
|
* @param treatDroppedBuffersAsSkipped Whether dropped buffers should be treated as intentionally
|
||||||
|
* skipped.
|
||||||
* @return Whether any buffers were dropped.
|
* @return Whether any buffers were dropped.
|
||||||
* @throws ExoPlaybackException If an error occurs flushing the codec.
|
* @throws ExoPlaybackException If an error occurs flushing the codec.
|
||||||
*/
|
*/
|
||||||
protected boolean maybeDropBuffersToKeyframe(MediaCodec codec, int index, long presentationTimeUs,
|
protected boolean maybeDropBuffersToKeyframe(
|
||||||
long positionUs) throws ExoPlaybackException {
|
MediaCodec codec,
|
||||||
|
int index,
|
||||||
|
long presentationTimeUs,
|
||||||
|
long positionUs,
|
||||||
|
boolean treatDroppedBuffersAsSkipped)
|
||||||
|
throws ExoPlaybackException {
|
||||||
int droppedSourceBufferCount = skipSource(positionUs);
|
int droppedSourceBufferCount = skipSource(positionUs);
|
||||||
if (droppedSourceBufferCount == 0) {
|
if (droppedSourceBufferCount == 0) {
|
||||||
return false;
|
return false;
|
||||||
@ -1045,7 +1058,12 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
|
|||||||
decoderCounters.droppedToKeyframeCount++;
|
decoderCounters.droppedToKeyframeCount++;
|
||||||
// We dropped some buffers to catch up, so update the decoder counters and flush the codec,
|
// We dropped some buffers to catch up, so update the decoder counters and flush the codec,
|
||||||
// which releases all pending buffers buffers including the current output buffer.
|
// which releases all pending buffers buffers including the current output buffer.
|
||||||
updateDroppedBufferCounters(buffersInCodecCount + droppedSourceBufferCount);
|
int totalDroppedBufferCount = buffersInCodecCount + droppedSourceBufferCount;
|
||||||
|
if (treatDroppedBuffersAsSkipped) {
|
||||||
|
decoderCounters.skippedOutputBufferCount += totalDroppedBufferCount;
|
||||||
|
} else {
|
||||||
|
updateDroppedBufferCounters(totalDroppedBufferCount);
|
||||||
|
}
|
||||||
flushOrReinitializeCodec();
|
flushOrReinitializeCodec();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user