[vlc-devel] [PATCH] mediacodec: no software rendering before api 18
Thomas Guillem
tom at gllm.fr
Wed Oct 22 18:03:31 CEST 2014
Avoid crashes by rendering unknown YUV buffers since "color-format" can't be
trusted before api 18.
---
modules/codec/omxil/android_mediacodec.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/modules/codec/omxil/android_mediacodec.c b/modules/codec/omxil/android_mediacodec.c
index 0f291b7..3712a91 100644
--- a/modules/codec/omxil/android_mediacodec.c
+++ b/modules/codec/omxil/android_mediacodec.c
@@ -51,6 +51,7 @@
extern int jni_attach_thread(JNIEnv **env, const char *thread_name);
extern void jni_detach_thread();
+extern int jni_get_sdk_int();
/* JNI functions to get/set an Android Surface object. */
extern jobject jni_LockAndGetAndroidJavaSurface();
extern void jni_UnlockAndroidSurface();
@@ -318,6 +319,12 @@ static int OpenDecoder(vlc_object_t *p_this)
return VLC_EGENERIC;
}
+ bool direct_rendering = jni_IsVideoPlayerActivityCreated() && var_InheritBool(p_dec, CFG_PREFIX "dr");
+ if (!direct_rendering && jni_get_sdk_int() < 18) {
+ msg_Warn(p_dec, "software rendering not supported before api 18");
+ return VLC_EGENERIC;
+ }
+
size_t fmt_profile = 0;
if (p_dec->fmt_in.i_codec == VLC_CODEC_H264)
h264_get_profile_level(&p_dec->fmt_in, &fmt_profile, NULL, NULL);
@@ -502,7 +509,7 @@ static int OpenDecoder(vlc_object_t *p_this)
/* If the VideoPlayerActivity is not started, MediaCodec opaque
direct rendering should be disabled since no surface will be
attached to the JNI. */
- p_sys->direct_rendering = jni_IsVideoPlayerActivityCreated() && var_InheritBool(p_dec, CFG_PREFIX "dr");
+ p_sys->direct_rendering = direct_rendering;
if (p_sys->direct_rendering) {
jobject surf = jni_LockAndGetAndroidJavaSurface();
if (surf) {
--
2.1.0
More information about the vlc-devel
mailing list