mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2025-07-20 19:42:45 +00:00
Some devices don't properly get interrupted while waiting for an input buffer, so wait 100 ms then check the interrupt flag
This commit is contained in:
parent
875eb1e773
commit
829532c572
@ -177,8 +177,14 @@ public class MediaCodecDecoderRenderer implements VideoDecoderRenderer {
|
|||||||
{
|
{
|
||||||
du = depacketizer.pollNextDecodeUnit();
|
du = depacketizer.pollNextDecodeUnit();
|
||||||
if (du != null) {
|
if (du != null) {
|
||||||
submitDecodeUnit(du);
|
if (!submitDecodeUnit(du)) {
|
||||||
|
// Thread was interrupted
|
||||||
depacketizer.freeDecodeUnit(du);
|
depacketizer.freeDecodeUnit(du);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
depacketizer.freeDecodeUnit(du);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int outIndex = videoDecoder.dequeueOutputBuffer(info, 0);
|
int outIndex = videoDecoder.dequeueOutputBuffer(info, 0);
|
||||||
@ -250,9 +256,16 @@ public class MediaCodecDecoderRenderer implements VideoDecoderRenderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean submitDecodeUnit(DecodeUnit decodeUnit) {
|
private boolean submitDecodeUnit(DecodeUnit decodeUnit) {
|
||||||
int inputIndex = videoDecoder.dequeueInputBuffer(-1);
|
int inputIndex;
|
||||||
if (inputIndex >= 0)
|
|
||||||
{
|
do {
|
||||||
|
if (Thread.interrupted()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
inputIndex = videoDecoder.dequeueInputBuffer(100000);
|
||||||
|
} while (inputIndex < 0);
|
||||||
|
|
||||||
ByteBuffer buf = videoDecoderInputBuffers[inputIndex];
|
ByteBuffer buf = videoDecoderInputBuffers[inputIndex];
|
||||||
|
|
||||||
long currentTime = System.currentTimeMillis();
|
long currentTime = System.currentTimeMillis();
|
||||||
@ -348,7 +361,6 @@ public class MediaCodecDecoderRenderer implements VideoDecoderRenderer {
|
|||||||
videoDecoder.queueInputBuffer(inputIndex,
|
videoDecoder.queueInputBuffer(inputIndex,
|
||||||
0, decodeUnit.getDataLength(),
|
0, decodeUnit.getDataLength(),
|
||||||
currentTime * 1000, codecFlags);
|
currentTime * 1000, codecFlags);
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user