Commit eac4b536 by andrewlewis Committed by Rohit Singh

Improve error logging

Log at debug level immediately when MediaCodec throws. This logging will be
output closer to the time when the error actually happened so should make it
easier to identify the order of components failing.

Downgrade logging of errors after export ends to warning level, as output may
still be fine if there was a problem after exporting completed (though it's
still worth logging a warning as the device may not be in a good state).

PiperOrigin-RevId: 523370457
parent c85de801
...@@ -124,6 +124,8 @@ public final class DefaultCodec implements Codec { ...@@ -124,6 +124,8 @@ public final class DefaultCodec implements Codec {
} }
startCodec(mediaCodec); startCodec(mediaCodec);
} catch (Exception e) { } catch (Exception e) {
Log.d(TAG, "MediaCodec error", e);
if (inputSurface != null) { if (inputSurface != null) {
inputSurface.release(); inputSurface.release();
} }
...@@ -179,6 +181,7 @@ public final class DefaultCodec implements Codec { ...@@ -179,6 +181,7 @@ public final class DefaultCodec implements Codec {
try { try {
inputBufferIndex = mediaCodec.dequeueInputBuffer(/* timeoutUs= */ 0); inputBufferIndex = mediaCodec.dequeueInputBuffer(/* timeoutUs= */ 0);
} catch (RuntimeException e) { } catch (RuntimeException e) {
Log.d(TAG, "MediaCodec error", e);
throw createExportException(e); throw createExportException(e);
} }
if (inputBufferIndex < 0) { if (inputBufferIndex < 0) {
...@@ -187,6 +190,7 @@ public final class DefaultCodec implements Codec { ...@@ -187,6 +190,7 @@ public final class DefaultCodec implements Codec {
try { try {
inputBuffer.data = mediaCodec.getInputBuffer(inputBufferIndex); inputBuffer.data = mediaCodec.getInputBuffer(inputBufferIndex);
} catch (RuntimeException e) { } catch (RuntimeException e) {
Log.d(TAG, "MediaCodec error", e);
throw createExportException(e); throw createExportException(e);
} }
inputBuffer.clear(); inputBuffer.clear();
...@@ -214,6 +218,7 @@ public final class DefaultCodec implements Codec { ...@@ -214,6 +218,7 @@ public final class DefaultCodec implements Codec {
try { try {
mediaCodec.queueInputBuffer(inputBufferIndex, offset, size, inputBuffer.timeUs, flags); mediaCodec.queueInputBuffer(inputBufferIndex, offset, size, inputBuffer.timeUs, flags);
} catch (RuntimeException e) { } catch (RuntimeException e) {
Log.d(TAG, "MediaCodec error", e);
throw createExportException(e); throw createExportException(e);
} }
inputBufferIndex = C.INDEX_UNSET; inputBufferIndex = C.INDEX_UNSET;
...@@ -225,6 +230,7 @@ public final class DefaultCodec implements Codec { ...@@ -225,6 +230,7 @@ public final class DefaultCodec implements Codec {
try { try {
mediaCodec.signalEndOfInputStream(); mediaCodec.signalEndOfInputStream();
} catch (RuntimeException e) { } catch (RuntimeException e) {
Log.d(TAG, "MediaCodec error", e);
throw createExportException(e); throw createExportException(e);
} }
} }
...@@ -270,6 +276,7 @@ public final class DefaultCodec implements Codec { ...@@ -270,6 +276,7 @@ public final class DefaultCodec implements Codec {
mediaCodec.releaseOutputBuffer(outputBufferIndex, /* render= */ false); mediaCodec.releaseOutputBuffer(outputBufferIndex, /* render= */ false);
} }
} catch (RuntimeException e) { } catch (RuntimeException e) {
Log.d(TAG, "MediaCodec error", e);
throw createExportException(e); throw createExportException(e);
} }
outputBufferIndex = C.INDEX_UNSET; outputBufferIndex = C.INDEX_UNSET;
...@@ -327,6 +334,7 @@ public final class DefaultCodec implements Codec { ...@@ -327,6 +334,7 @@ public final class DefaultCodec implements Codec {
try { try {
outputBufferIndex = mediaCodec.dequeueOutputBuffer(outputBufferInfo, /* timeoutUs= */ 0); outputBufferIndex = mediaCodec.dequeueOutputBuffer(outputBufferInfo, /* timeoutUs= */ 0);
} catch (RuntimeException e) { } catch (RuntimeException e) {
Log.d(TAG, "MediaCodec error", e);
throw createExportException(e); throw createExportException(e);
} }
if (outputBufferIndex < 0) { if (outputBufferIndex < 0) {
...@@ -368,6 +376,7 @@ public final class DefaultCodec implements Codec { ...@@ -368,6 +376,7 @@ public final class DefaultCodec implements Codec {
try { try {
outputBuffer = checkNotNull(mediaCodec.getOutputBuffer(outputBufferIndex)); outputBuffer = checkNotNull(mediaCodec.getOutputBuffer(outputBufferIndex));
} catch (RuntimeException e) { } catch (RuntimeException e) {
Log.d(TAG, "MediaCodec error", e);
throw createExportException(e); throw createExportException(e);
} }
outputBuffer.position(outputBufferInfo.offset); outputBuffer.position(outputBufferInfo.offset);
......
...@@ -398,7 +398,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; ...@@ -398,7 +398,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
if (exception != null) { if (exception != null) {
if (releasedPreviously) { if (releasedPreviously) {
Log.e(TAG, "Export error after export ended: ", exception); Log.w(TAG, "Export error after export ended", exception);
return; return;
} }
ExportException finalException = exception; ExportException finalException = exception;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment