Don't notify drop frames when maxDroppedFramesToNotify < 1

With default of value set to -1, every single dropped frame is reported because of expression: if (droppedFrames >= maxDroppedFramesToNotify) {  maybeNotifyDroppedFrames(); }

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=213502573
This commit is contained in:
sharjeel 2018-09-18 13:11:11 -07:00 committed by Oliver Woodman
parent 918a43e48d
commit 1726f9e5fe
2 changed files with 12 additions and 8 deletions

View File

@ -632,7 +632,7 @@ public class LibvpxVideoRenderer extends BaseRenderer {
consecutiveDroppedFrameCount += droppedBufferCount;
decoderCounters.maxConsecutiveDroppedBufferCount =
Math.max(consecutiveDroppedFrameCount, decoderCounters.maxConsecutiveDroppedBufferCount);
if (droppedFrames >= maxDroppedFramesToNotify) {
if (maxDroppedFramesToNotify > 0 && droppedFrames >= maxDroppedFramesToNotify) {
maybeNotifyDroppedFrames();
}
}

View File

@ -160,7 +160,7 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
allowedJoiningTimeMs,
/* eventHandler= */ null,
/* eventListener= */ null,
-1);
/* maxDroppedFramesToNotify= */ -1);
}
/**
@ -171,12 +171,16 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
* @param eventHandler A handler to use when delivering events to {@code eventListener}. May be
* null if delivery of events is not required.
* @param eventListener A listener of events. May be null if delivery of events is not required.
* @param maxDroppedFrameCountToNotify The maximum number of frames that can be dropped between
* @param maxDroppedFramesToNotify The maximum number of frames that can be dropped between
* invocations of {@link VideoRendererEventListener#onDroppedFrames(int, long)}.
*/
public MediaCodecVideoRenderer(Context context, MediaCodecSelector mediaCodecSelector,
long allowedJoiningTimeMs, @Nullable Handler eventHandler,
@Nullable VideoRendererEventListener eventListener, int maxDroppedFrameCountToNotify) {
public MediaCodecVideoRenderer(
Context context,
MediaCodecSelector mediaCodecSelector,
long allowedJoiningTimeMs,
@Nullable Handler eventHandler,
@Nullable VideoRendererEventListener eventListener,
int maxDroppedFramesToNotify) {
this(
context,
mediaCodecSelector,
@ -185,7 +189,7 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
/* playClearSamplesWithoutKeys= */ false,
eventHandler,
eventListener,
maxDroppedFrameCountToNotify);
maxDroppedFramesToNotify);
}
/**
@ -850,7 +854,7 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
consecutiveDroppedFrameCount += droppedBufferCount;
decoderCounters.maxConsecutiveDroppedBufferCount = Math.max(consecutiveDroppedFrameCount,
decoderCounters.maxConsecutiveDroppedBufferCount);
if (droppedFrames >= maxDroppedFramesToNotify) {
if (maxDroppedFramesToNotify > 0 && droppedFrames >= maxDroppedFramesToNotify) {
maybeNotifyDroppedFrames();
}
}