fluiddec: Keep fluidsynth from probing audio drivers
authorJan Alexander Steffens (heftig) <jan.steffens@gmail.com>
Wed, 5 Feb 2020 10:17:33 +0000 (11:17 +0100)
committerGStreamer Merge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Tue, 11 Feb 2020 12:10:50 +0000 (12:10 +0000)
It might cause problems and we don't need the drivers anyway. This also
avoids a bunch of stderr spam from the drivers.

https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/merge_requests/1026

ext/fluidsynth/gstfluiddec.c

index 0339ad2..0550f62 100644 (file)
 
 #include "gstfluiddec.h"
 
+#define GST_HAVE_FLUIDSYNTH_VERSION(major,minor,micro) \
+  (FLUIDSYNTH_VERSION_MAJOR > (major) || \
+  (FLUIDSYNTH_VERSION_MAJOR == (major) && FLUIDSYNTH_VERSION_MINOR > (minor)) || \
+  (FLUIDSYNTH_VERSION_MAJOR == (major) && FLUIDSYNTH_VERSION_MINOR == (minor) && FLUIDSYNTH_VERSION_MICRO >= (micro)))
+
 GST_DEBUG_CATEGORY_STATIC (gst_fluid_dec_debug);
 #define GST_CAT_DEFAULT gst_fluid_dec_debug
 
@@ -727,6 +732,17 @@ plugin_init (GstPlugin * plugin)
   GST_DEBUG_CATEGORY_INIT (gst_fluid_dec_debug, "fluiddec",
       0, "Fluidsynth MIDI decoder plugin");
 
+#if GST_HAVE_FLUIDSYNTH_VERSION(1, 1, 9)
+  {
+    /* Disable all audio drivers so new_fluid_settings() does not probe them.
+     * This can crash if FluidSynth is already in use. */
+    const char *empty[] = { NULL };
+    if (fluid_audio_driver_register (empty) != FLUID_OK) {
+      GST_WARNING ("Failed to clear audio drivers");
+    }
+  }
+#endif
+
   return gst_element_register (plugin, "fluiddec",
       GST_RANK_SECONDARY, GST_TYPE_FLUID_DEC);
 }