Fix codec display after streaming and restore polling behavior of non-direct submit decoders

This commit is contained in:
Cameron Gutman 2017-05-15 21:41:41 -07:00
parent 36b248be4b
commit 732311c2a4
3 changed files with 12 additions and 4 deletions

View File

@ -424,7 +424,7 @@ public class Game extends Activity implements SurfaceHolder.Callback,
} }
if (conn != null) { if (conn != null) {
int videoFormat = conn.getActiveVideoFormat(); int videoFormat = decoderRenderer.getActiveVideoFormat();
displayedFailureDialog = true; displayedFailureDialog = true;
stopConnection(); stopConnection();

View File

@ -133,6 +133,10 @@ public class MediaCodecDecoderRenderer extends VideoDecoderRenderer {
return avcDecoder != null; return avcDecoder != null;
} }
public int getActiveVideoFormat() {
return this.videoFormat;
}
@Override @Override
public boolean setup(int format, int width, int height, int redrawRate) { public boolean setup(int format, int width, int height, int redrawRate) {
this.initialWidth = width; this.initialWidth = width;
@ -274,7 +278,8 @@ public class MediaCodecDecoderRenderer extends VideoDecoderRenderer {
while (!isInterrupted()) { while (!isInterrupted()) {
try { try {
// Try to output a frame // Try to output a frame
int outIndex = videoDecoder.dequeueOutputBuffer(info, 50000); int outIndex = videoDecoder.dequeueOutputBuffer(info,
directSubmit ? 50000 : 0);
if (outIndex >= 0) { if (outIndex >= 0) {
long presentationTimeUs = info.presentationTimeUs; long presentationTimeUs = info.presentationTimeUs;
int lastIndex = outIndex; int lastIndex = outIndex;
@ -301,6 +306,9 @@ public class MediaCodecDecoderRenderer extends VideoDecoderRenderer {
} else { } else {
switch (outIndex) { switch (outIndex) {
case MediaCodec.INFO_TRY_AGAIN_LATER: case MediaCodec.INFO_TRY_AGAIN_LATER:
if (!directSubmit) {
Thread.yield();
}
break; break;
case MediaCodec.INFO_OUTPUT_FORMAT_CHANGED: case MediaCodec.INFO_OUTPUT_FORMAT_CHANGED:
LimeLog.info("Output format changed"); LimeLog.info("Output format changed");
@ -328,7 +336,7 @@ public class MediaCodecDecoderRenderer extends VideoDecoderRenderer {
startTime = MediaCodecHelper.getMonotonicMillis(); startTime = MediaCodecHelper.getMonotonicMillis();
while (rendererThread.isAlive() && index < 0) { while (rendererThread.isAlive() && index < 0) {
index = videoDecoder.dequeueInputBuffer(500); index = videoDecoder.dequeueInputBuffer(10000);
} }
if (index < 0) { if (index < 0) {

@ -1 +1 @@
Subproject commit e9b406c52e552dca6e3ad98771f5ea1b94363248 Subproject commit bda8e3b84ddb633d47b00ffc7ec4d5f20c7eecae