diff options
| author | 2024-03-27 10:27:40 -0700 | |
|---|---|---|
| committer | 2024-03-27 13:06:24 -0700 | |
| commit | 03eb2ee132957d73e99373d60e16423be4562854 (patch) | |
| tree | 31af504f57ac1d1ebf3b2300e8ad115f9edcbbff | |
| parent | 90d91e9759daa12c3b3f4f18de41a3a225dbc2af (diff) | |
media: protect around aconfig flag access in MediaCodec::configure
This API is known to be used from contexts where aconfig flag accessors
fail.
Bug: 325389296
Change-Id: I5164b528c3b852bef9a757d9b2399b0af51feeb0
| -rw-r--r-- | media/java/android/media/MediaCodec.java | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/media/java/android/media/MediaCodec.java b/media/java/android/media/MediaCodec.java index 45bf5c415a7e..5bb30ccbfe81 100644 --- a/media/java/android/media/MediaCodec.java +++ b/media/java/android/media/MediaCodec.java @@ -2346,7 +2346,15 @@ final public class MediaCodec { } // at the moment no codecs support detachable surface - if (android.media.codec.Flags.nullOutputSurface()) { + + // HACKY: aconfig flags accessors may not work in all contexts that MediaCodec API is used, + // so allow accessors to fail. In those contexts the flags will just not be enabled + boolean nullOutputSurface = false; + try { + nullOutputSurface = android.media.codec.Flags.nullOutputSurface(); + } catch (java.lang.RuntimeException e) { } + + if (nullOutputSurface) { // Detached surface flag is only meaningful if surface is null. Otherwise, it is // ignored. if (surface == null && (flags & CONFIGURE_FLAG_DETACHED_SURFACE) != 0) { |