Skip to content

Commit

Permalink
[android] Refine MediaCodec error message (youtube#3638)
Browse files Browse the repository at this point in the history
The exception information is now included as part of the error message,
which is forwarded to DOM and can be accessed via
`HTMLMediaElement.error.message`.

b/348438829
  • Loading branch information
xiaomings authored Jun 24, 2024
1 parent 04c8107 commit 8a3efab
Showing 1 changed file with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -752,10 +752,10 @@ public static void createVideoMediaCodecBridge(
// outCreateMediaCodecBridgeResult.mErrorMessage is set inside configureVideo() on error.
return;
}
if (!bridge.start()) {
if (!bridge.start(outCreateMediaCodecBridgeResult)) {
Log.e(TAG, "Failed to start video codec.");
bridge.release();
outCreateMediaCodecBridgeResult.mErrorMessage = "Failed to start video codec";
// outCreateMediaCodecBridgeResult.mErrorMessage is set inside start() on error.
return;
}

Expand All @@ -777,13 +777,21 @@ public void release() {
mMediaCodec.set(null);
}

public boolean start() {
return start(null);
}

@SuppressWarnings("unused")
@UsedByNative
public boolean start() {
public boolean start(CreateMediaCodecBridgeResult outCreateMediaCodecBridgeResult) {
try {
mMediaCodec.get().start();
} catch (IllegalStateException | IllegalArgumentException e) {
Log.e(TAG, "Cannot start the media codec", e);
Log.e(TAG, "Failed to start the media codec", e);
if (outCreateMediaCodecBridgeResult != null) {
outCreateMediaCodecBridgeResult.mErrorMessage =
"Failed to start media codec " + e.toString();
}
return false;
}
return true;
Expand Down

0 comments on commit 8a3efab

Please sign in to comment.