mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2025-07-20 19:42:45 +00:00
Fix race conditions when frames are submitted after stop() has been called
This commit is contained in:
parent
214461e123
commit
7d289f1134
@ -573,25 +573,11 @@ public class MediaCodecDecoderRenderer extends VideoDecoderRenderer {
|
|||||||
// May be called already, but we'll call it now to be safe
|
// May be called already, but we'll call it now to be safe
|
||||||
prepareForStop();
|
prepareForStop();
|
||||||
|
|
||||||
try {
|
|
||||||
// Invalidate pending decode buffers
|
|
||||||
videoDecoder.flush();
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Wait for the renderer thread to shut down
|
// Wait for the renderer thread to shut down
|
||||||
try {
|
try {
|
||||||
rendererThread.join();
|
rendererThread.join();
|
||||||
} catch (InterruptedException ignored) { }
|
} catch (InterruptedException ignored) { }
|
||||||
|
|
||||||
try {
|
|
||||||
// Stop the video decoder
|
|
||||||
videoDecoder.stop();
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Halt the spinner threads
|
// Halt the spinner threads
|
||||||
stopSpinnerThreads();
|
stopSpinnerThreads();
|
||||||
}
|
}
|
||||||
@ -657,6 +643,11 @@ public class MediaCodecDecoderRenderer extends VideoDecoderRenderer {
|
|||||||
@Override
|
@Override
|
||||||
public int submitDecodeUnit(byte[] decodeUnitData, int decodeUnitLength, int decodeUnitType,
|
public int submitDecodeUnit(byte[] decodeUnitData, int decodeUnitLength, int decodeUnitType,
|
||||||
int frameNumber, long receiveTimeMs) {
|
int frameNumber, long receiveTimeMs) {
|
||||||
|
if (stopping) {
|
||||||
|
// Don't bother if we're stopping
|
||||||
|
return MoonBridge.DR_OK;
|
||||||
|
}
|
||||||
|
|
||||||
totalFramesReceived++;
|
totalFramesReceived++;
|
||||||
|
|
||||||
// We can receive the same "frame" multiple times if it's an IDR frame.
|
// We can receive the same "frame" multiple times if it's an IDR frame.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user