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) {
int videoFormat = conn.getActiveVideoFormat();
int videoFormat = decoderRenderer.getActiveVideoFormat();
displayedFailureDialog = true;
stopConnection();

View File

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

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