Make DecoderCountersUtil error message clearer
By including the full counters in the failure message we have a clearer insight into the cause of the failure. PiperOrigin-RevId: 415982732
This commit is contained in:
parent
8c837c6e2d
commit
1fa69a9080
@ -18,6 +18,7 @@ package androidx.media3.exoplayer;
|
|||||||
import static java.lang.Math.max;
|
import static java.lang.Math.max;
|
||||||
|
|
||||||
import androidx.media3.common.util.UnstableApi;
|
import androidx.media3.common.util.UnstableApi;
|
||||||
|
import androidx.media3.common.util.Util;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Maintains decoder event counts, for debugging purposes only.
|
* Maintains decoder event counts, for debugging purposes only.
|
||||||
@ -157,4 +158,34 @@ public final class DecoderCounters {
|
|||||||
totalVideoFrameProcessingOffsetUs += totalProcessingOffsetUs;
|
totalVideoFrameProcessingOffsetUs += totalProcessingOffsetUs;
|
||||||
videoFrameProcessingOffsetCount += count;
|
videoFrameProcessingOffsetCount += count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return Util.formatInvariant(
|
||||||
|
"DecoderCounters {\n "
|
||||||
|
+ "decoderInits=%s,\n "
|
||||||
|
+ "decoderReleases=%s\n "
|
||||||
|
+ "queuedInputBuffers=%s\n "
|
||||||
|
+ "skippedInputBuffers=%s\n "
|
||||||
|
+ "renderedOutputBuffers=%s\n "
|
||||||
|
+ "skippedOutputBuffers=%s\n "
|
||||||
|
+ "droppedBuffers=%s\n "
|
||||||
|
+ "droppedInputBuffers=%s\n "
|
||||||
|
+ "maxConsecutiveDroppedBuffers=%s\n "
|
||||||
|
+ "droppedToKeyframeEvents=%s\n "
|
||||||
|
+ "totalVideoFrameProcessingOffsetUs=%s\n "
|
||||||
|
+ "videoFrameProcessingOffsetCount=%s\n}",
|
||||||
|
decoderInitCount,
|
||||||
|
decoderReleaseCount,
|
||||||
|
queuedInputBufferCount,
|
||||||
|
skippedInputBufferCount,
|
||||||
|
renderedOutputBufferCount,
|
||||||
|
skippedOutputBufferCount,
|
||||||
|
droppedBufferCount,
|
||||||
|
droppedInputBufferCount,
|
||||||
|
maxConsecutiveDroppedBufferCount,
|
||||||
|
droppedToKeyframeCount,
|
||||||
|
totalVideoFrameProcessingOffsetUs,
|
||||||
|
videoFrameProcessingOffsetCount);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ public final class DecoderCountersUtil {
|
|||||||
counters.ensureUpdated();
|
counters.ensureUpdated();
|
||||||
int actual = counters.skippedOutputBufferCount;
|
int actual = counters.skippedOutputBufferCount;
|
||||||
assertWithMessage(
|
assertWithMessage(
|
||||||
"Codec(" + name + ") skipped " + actual + " buffers. Expected " + expected + ".")
|
"Codec(%s) skipped an unexpected number of buffers. Counters:\n%s", name, counters)
|
||||||
.that(actual)
|
.that(actual)
|
||||||
.isEqualTo(expected);
|
.isEqualTo(expected);
|
||||||
}
|
}
|
||||||
@ -68,32 +68,19 @@ public final class DecoderCountersUtil {
|
|||||||
public static void assertTotalBufferCount(
|
public static void assertTotalBufferCount(
|
||||||
String name, DecoderCounters counters, int minCount, int maxCount) {
|
String name, DecoderCounters counters, int minCount, int maxCount) {
|
||||||
int actual = getTotalBufferCount(counters);
|
int actual = getTotalBufferCount(counters);
|
||||||
assertWithMessage(
|
assertWithMessage("Codec(%s) output too few buffers. Counters:\n%s", name, counters)
|
||||||
"Codec("
|
.that(actual)
|
||||||
+ name
|
.isAtLeast(minCount);
|
||||||
+ ") output "
|
assertWithMessage("Codec(%s) output too many buffers. Counters:\n%s", name, counters)
|
||||||
+ actual
|
.that(actual)
|
||||||
+ " buffers. Expected in range ["
|
.isAtMost(maxCount);
|
||||||
+ minCount
|
|
||||||
+ ", "
|
|
||||||
+ maxCount
|
|
||||||
+ "].")
|
|
||||||
.that(minCount <= actual && actual <= maxCount)
|
|
||||||
.isTrue();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void assertDroppedBufferLimit(String name, DecoderCounters counters, int limit) {
|
public static void assertDroppedBufferLimit(String name, DecoderCounters counters, int limit) {
|
||||||
counters.ensureUpdated();
|
counters.ensureUpdated();
|
||||||
int actual = counters.droppedBufferCount;
|
int actual = counters.droppedBufferCount;
|
||||||
assertWithMessage(
|
assertWithMessage(
|
||||||
"Codec("
|
"Codec(%s) was late decoding too many buffers. Counters:\n%s: ", name, counters)
|
||||||
+ name
|
|
||||||
+ ") was late decoding: "
|
|
||||||
+ actual
|
|
||||||
+ " buffers. "
|
|
||||||
+ "Limit: "
|
|
||||||
+ limit
|
|
||||||
+ ".")
|
|
||||||
.that(actual)
|
.that(actual)
|
||||||
.isAtMost(limit);
|
.isAtMost(limit);
|
||||||
}
|
}
|
||||||
@ -103,14 +90,8 @@ public final class DecoderCountersUtil {
|
|||||||
counters.ensureUpdated();
|
counters.ensureUpdated();
|
||||||
int actual = counters.maxConsecutiveDroppedBufferCount;
|
int actual = counters.maxConsecutiveDroppedBufferCount;
|
||||||
assertWithMessage(
|
assertWithMessage(
|
||||||
"Codec("
|
"Codec(%s) was late decoding too many buffers consecutively. Counters:\n%s",
|
||||||
+ name
|
name, counters)
|
||||||
+ ") was late decoding: "
|
|
||||||
+ actual
|
|
||||||
+ " buffers consecutively. "
|
|
||||||
+ "Limit: "
|
|
||||||
+ limit
|
|
||||||
+ ".")
|
|
||||||
.that(actual)
|
.that(actual)
|
||||||
.isAtMost(limit);
|
.isAtMost(limit);
|
||||||
}
|
}
|
||||||
@ -119,16 +100,14 @@ public final class DecoderCountersUtil {
|
|||||||
String name, DecoderCounters counters, int minCount, int maxCount) {
|
String name, DecoderCounters counters, int minCount, int maxCount) {
|
||||||
int actual = counters.videoFrameProcessingOffsetCount;
|
int actual = counters.videoFrameProcessingOffsetCount;
|
||||||
assertWithMessage(
|
assertWithMessage(
|
||||||
"Codec("
|
"Codec(%s) videoFrameProcessingOffsetSampleCount too low. Counters:\n%s",
|
||||||
+ name
|
name, counters)
|
||||||
+ ") videoFrameProcessingOffsetSampleCount "
|
.that(actual)
|
||||||
+ actual
|
.isAtLeast(minCount);
|
||||||
+ ". Expected in range ["
|
assertWithMessage(
|
||||||
+ minCount
|
"Codec(%s) videoFrameProcessingOffsetSampleCount too high. Counters:\n%s",
|
||||||
+ ", "
|
name, counters)
|
||||||
+ maxCount
|
.that(actual)
|
||||||
+ "].")
|
.isAtMost(maxCount);
|
||||||
.that(minCount <= actual && actual <= maxCount)
|
|
||||||
.isTrue();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user