pluginloader: make sure gst-plugin-scanner is called with the right arch on OSX
authorJan Schmidt <thaytan@mad.scientist.com>
Mon, 11 Apr 2011 10:29:00 +0000 (11:29 +0100)
committerTim-Philipp Müller <tim.muller@collabora.co.uk>
Mon, 11 Apr 2011 10:41:19 +0000 (11:41 +0100)
On OSX, GStreamer might be built as a 'fat/universal' binary containing
both 32-bit and 64-bit code. We must take care that gst-plugin-scanner
is executed with the same architecture as the GStreamer core, otherwise
bad things may happen and core/scanner will not be able to communicate
properly.

Should fix issues with (32-bit) firefox using a 32-bit GStreamer core
which then spawns a 'universal' gst-plugin-scanner binary which gets
run in 64-bit mode, causing 100% cpu usage / busy loops or just hanging
firefox until killed.

https://bugzilla.gnome.org/show_bug.cgi?id=615357

gst/gstpluginloader.c

index 220e2db..2928ac8 100644 (file)
@@ -353,9 +353,28 @@ plugin_loader_create_blacklist_plugin (GstPluginLoader * l,
 static gboolean
 gst_plugin_loader_try_helper (GstPluginLoader * loader, gchar * location)
 {
+#ifdef __APPLE__
+#if defined(__x86_64__)
+  char *argv[] = { "/usr/bin/arch", "-x86_64", location, (char *) "-l", NULL };
+#elif defined(__i386__)
+  char *argv[] = { "/usr/bin/arch", "-i386", location, (char *) "-l", NULL };
+#elif defined(__ppc__)
+  char *argv[] = { "/usr/bin/arch", "-ppc", location, (char *) "-l", NULL };
+#elif defined(__ppc64__)
+  char *argv[] = { "/usr/bin/arch", "-ppc64", location, (char *) "-l", NULL };
+#endif
+#else /* ! __APPLE__ */
   char *argv[] = { location, (char *) "-l", NULL };
+#endif
+
 
+#ifdef __APPLE__
+  GST_LOG ("Trying to spawn gst-plugin-scanner helper at %s with arch %s",
+      location, argv[1]);
+#else
   GST_LOG ("Trying to spawn gst-plugin-scanner helper at %s", location);
+#endif
+
   if (!g_spawn_async_with_pipes (NULL, argv, NULL,
           G_SPAWN_DO_NOT_REAP_CHILD /* | G_SPAWN_STDERR_TO_DEV_NULL */ ,
           NULL, NULL, &loader->child_pid, &loader->fd_w.fd, &loader->fd_r.fd,