androidmedia: Don't query supported color formats for non-video codecs
authorSebastian Dröge <sebastian@centricular.com>
Mon, 15 Jun 2015 10:20:24 +0000 (12:20 +0200)
committerSebastian Dröge <sebastian@centricular.com>
Mon, 15 Jun 2015 10:20:24 +0000 (12:20 +0200)
sys/androidmedia/gstamc.c

index 0578d3c..c0c341c 100644 (file)
@@ -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;