changeset 10702:bad75af55855 jdk-10+32

8187594: Media crashes with libavcodec 57 on Ubuntu 17.04 32-bit Reviewed-by: kcr, ddehaven
author almatvee
date Mon, 13 Nov 2017 18:37:33 -0800
parents 70758983aa19
children d9b7ff88960d ac3cdb4b273f
files modules/javafx.media/src/main/native/gstreamer/gstreamer-lite/gstreamer/gst/gstregistry.c
diffstat 1 files changed, 41 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/modules/javafx.media/src/main/native/gstreamer/gstreamer-lite/gstreamer/gst/gstregistry.c	Thu Nov 09 07:56:48 2017 -0800
+++ b/modules/javafx.media/src/main/native/gstreamer/gstreamer-lite/gstreamer/gst/gstregistry.c	Mon Nov 13 18:37:33 2017 -0800
@@ -1294,6 +1294,37 @@
 }
 #endif
 
+#ifdef GSTREAMER_LITE
+// Only for Linux 32-bit
+#if defined(LINUX) && !defined(__x86_64__)
+gpointer load_plugin(gpointer data)
+{
+  return dlopen((gchar*)data, RTLD_GLOBAL|RTLD_NOW);
+}
+
+gboolean preload_plugin_on_thread(int version, gchar *filename)
+{
+  void *handle = NULL;
+
+  if (version != 57) // Only needed for 57
+    return TRUE;
+
+  if (filename == NULL)
+    return FALSE;
+
+  GThread *thread = g_thread_new(NULL, load_plugin, filename);
+  if (thread != NULL) {
+    handle = g_thread_join(thread);
+    if (handle != NULL) {
+      return TRUE;
+    }
+  }
+
+  return FALSE;
+}
+#endif
+#endif // GSTREAMER_LITE
+
 static gboolean
 gst_registry_scan_path_level (GstRegistryScanContext * context,
     const gchar * path, int level)
@@ -1444,7 +1475,16 @@
             filename = g_strdup_printf("%s-ffmpeg-%d%s", filename_partial, plugin_version, GST_EXTRA_MODULE_SUFFIX);
           else
             filename = g_strdup_printf("%s-%d%s", filename_partial, plugin_version, GST_EXTRA_MODULE_SUFFIX);
-          }
+        }
+#if defined(LINUX) && !defined(__x86_64__)
+        if (!preload_plugin_on_thread(plugin_version, filename)) {
+          g_free(filename_partial);
+          filename_partial = NULL;
+          g_free(filename);
+          filename = NULL;
+          continue; // If we fail preload do not load such plugin.
+        }
+#endif
       } else {
         g_free(filename_partial);
         continue; // No libavcodec.so installed.