Fix deadlocks in audio and video stream shutdown using the new callbacks

This commit is contained in:
Cameron Gutman 2017-05-21 13:07:19 -07:00
parent 83141d3f91
commit 8962497a8c
3 changed files with 24 additions and 19 deletions

View File

@ -84,10 +84,18 @@ public class AndroidAudioRenderer implements AudioRenderer {
track.write(audioData, 0, audioData.length);
}
@Override
public void start() {}
@Override
public void stop() {
// Immediately drop all pending data
track.pause();
track.flush();
}
@Override
public void cleanup() {
if (track != null) {
track.release();
}
}
}

View File

@ -260,8 +260,6 @@ public class MediaCodecDecoderRenderer extends VideoDecoderRenderer {
return -5;
}
startRendererThread();
return 0;
}
@ -380,27 +378,26 @@ public class MediaCodecDecoderRenderer extends VideoDecoderRenderer {
return index;
}
// This method is used by the hack in Game, not called by the streaming core.
@Override
public void start() {
startRendererThread();
}
@Override
public void stop() {
stopping = true;
if (rendererThread != null) {
// Halt the rendering thread
rendererThread.interrupt();
try {
rendererThread.join();
} catch (InterruptedException ignored) { }
}
}
@Override
public void cleanup() {
stop();
if (videoDecoder != null) {
videoDecoder.release();
}
}
private boolean queueInputBuffer(int inputBufferIndex, int offset, int length, long timestampUs, int codecFlags) {
// Try 25 times to submit the input buffer before throwing a real exception

@ -1 +1 @@
Subproject commit 525a8ac322129ee54d674da5d0a3518f6f56ef64
Subproject commit 4c2dc16aefbb516da42399c0fb06bff19a2629e6