From 90c4a6ecd0e7c8b1b1b5390bae2b1473b70fe313 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sebastian=20Dr=C3=B6ge?= Date: Mon, 15 Jun 2015 12:20:24 +0200 Subject: [PATCH] androidmedia: Don't query supported color formats for non-video codecs --- sys/androidmedia/gstamc.c | 73 ++++++++++++++++++++++++----------------------- 1 file changed, 37 insertions(+), 36 deletions(-) diff --git a/sys/androidmedia/gstamc.c b/sys/androidmedia/gstamc.c index 0578d3c..c0c341c 100644 --- a/sys/androidmedia/gstamc.c +++ b/sys/androidmedia/gstamc.c @@ -1605,10 +1605,8 @@ scan_codecs (GstPlugin * plugin) const gchar *supported_type_str = NULL; jobject capabilities = NULL; jclass capabilities_class = NULL; - jfieldID color_formats_id, profile_levels_id; - jobject color_formats = NULL; + jfieldID profile_levels_id, color_formats_id; jobject profile_levels = NULL; - jint *color_formats_elems = NULL; jsize n_elems, k; gst_codec_type = &gst_codec_info->supported_types[j]; @@ -1668,42 +1666,45 @@ scan_codecs (GstPlugin * plugin) goto next_supported_type; } - color_formats = - (*env)->GetObjectField (env, capabilities, color_formats_id); - if ((*env)->ExceptionCheck (env)) { - GST_ERROR ("Failed to get color formats"); - (*env)->ExceptionDescribe (env); - (*env)->ExceptionClear (env); - valid_codec = FALSE; - goto next_supported_type; - } + if (g_str_has_prefix (gst_codec_type->mime, "video/")) { + jobject color_formats = NULL; + jint *color_formats_elems = NULL; - n_elems = (*env)->GetArrayLength (env, color_formats); - if ((*env)->ExceptionCheck (env)) { - GST_ERROR ("Failed to get color formats array length"); - (*env)->ExceptionDescribe (env); - (*env)->ExceptionClear (env); - valid_codec = FALSE; - goto next_supported_type; - } - gst_codec_type->n_color_formats = n_elems; - gst_codec_type->color_formats = g_new0 (gint, n_elems); - color_formats_elems = - (*env)->GetIntArrayElements (env, color_formats, NULL); - if ((*env)->ExceptionCheck (env)) { - GST_ERROR ("Failed to get color format elements"); - (*env)->ExceptionDescribe (env); - (*env)->ExceptionClear (env); - valid_codec = FALSE; - goto next_supported_type; - } + color_formats = + (*env)->GetObjectField (env, capabilities, color_formats_id); + if ((*env)->ExceptionCheck (env)) { + GST_ERROR ("Failed to get color formats"); + (*env)->ExceptionDescribe (env); + (*env)->ExceptionClear (env); + valid_codec = FALSE; + goto next_supported_type; + } - for (k = 0; k < n_elems; k++) { - GST_INFO ("Color format %d: 0x%x", k, color_formats_elems[k]); - gst_codec_type->color_formats[k] = color_formats_elems[k]; - } + n_elems = (*env)->GetArrayLength (env, color_formats); + if ((*env)->ExceptionCheck (env)) { + GST_ERROR ("Failed to get color formats array length"); + (*env)->ExceptionDescribe (env); + (*env)->ExceptionClear (env); + valid_codec = FALSE; + goto next_supported_type; + } + gst_codec_type->n_color_formats = n_elems; + gst_codec_type->color_formats = g_new0 (gint, n_elems); + color_formats_elems = + (*env)->GetIntArrayElements (env, color_formats, NULL); + if ((*env)->ExceptionCheck (env)) { + GST_ERROR ("Failed to get color format elements"); + (*env)->ExceptionDescribe (env); + (*env)->ExceptionClear (env); + valid_codec = FALSE; + goto next_supported_type; + } + + for (k = 0; k < n_elems; k++) { + GST_INFO ("Color format %d: 0x%x", k, color_formats_elems[k]); + gst_codec_type->color_formats[k] = color_formats_elems[k]; + } - if (g_str_has_prefix (gst_codec_type->mime, "video/")) { if (!n_elems) { GST_ERROR ("No supported color formats for video codec"); valid_codec = FALSE; -- 2.7.4