mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2026-04-22 16:26:41 +00:00
Fix crash after the next fetchNextInputBuffer() if getInputBuffer() failed previously
This commit is contained in:
@@ -690,7 +690,7 @@ public class MediaCodecDecoderRenderer extends VideoDecoderRenderer implements C
|
|||||||
private boolean fetchNextInputBuffer() {
|
private boolean fetchNextInputBuffer() {
|
||||||
long startTime;
|
long startTime;
|
||||||
|
|
||||||
if (nextInputBufferIndex >= 0) {
|
if (nextInputBuffer != null) {
|
||||||
// We already have an input buffer
|
// We already have an input buffer
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -698,10 +698,12 @@ public class MediaCodecDecoderRenderer extends VideoDecoderRenderer implements C
|
|||||||
startTime = SystemClock.uptimeMillis();
|
startTime = SystemClock.uptimeMillis();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
// If we don't have an input buffer index yet, fetch one now
|
||||||
while (nextInputBufferIndex < 0 && !stopping) {
|
while (nextInputBufferIndex < 0 && !stopping) {
|
||||||
nextInputBufferIndex = videoDecoder.dequeueInputBuffer(10000);
|
nextInputBufferIndex = videoDecoder.dequeueInputBuffer(10000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get the backing ByteBuffer for the input buffer index
|
||||||
if (nextInputBufferIndex >= 0) {
|
if (nextInputBufferIndex >= 0) {
|
||||||
// Using the new getInputBuffer() API on Lollipop allows
|
// Using the new getInputBuffer() API on Lollipop allows
|
||||||
// the framework to do some performance optimizations for us
|
// the framework to do some performance optimizations for us
|
||||||
@@ -726,7 +728,7 @@ public class MediaCodecDecoderRenderer extends VideoDecoderRenderer implements C
|
|||||||
LimeLog.warning("Dequeue input buffer ran long: " + deltaMs + " ms");
|
LimeLog.warning("Dequeue input buffer ran long: " + deltaMs + " ms");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nextInputBufferIndex < 0) {
|
if (nextInputBuffer == null) {
|
||||||
// We've been hung for 5 seconds and no other exception was reported,
|
// We've been hung for 5 seconds and no other exception was reported,
|
||||||
// so generate a decoder hung exception
|
// so generate a decoder hung exception
|
||||||
if (deltaMs >= 5000 && initialException == null) {
|
if (deltaMs >= 5000 && initialException == null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user