[gtk/wip/otte/no-media-modules: 2/2] media: Block loading of the old modules




commit 64369d14098cfa28fb58b2418ee2df8101e88703
Author: Benjamin Otte <otte redhat com>
Date:   Tue Aug 10 23:50:46 2021 +0200

    media: Block loading of the old modules
    
    When media modules from previous versions still exist that conflict with
    the now built-in modules, block loading them.
    
    Determining the module name was done with the best way I could come up
    with, because apparently g_io_module_scope_block() requires the full
    library name.

 gtk/gtkmediafile.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtkmediafile.c b/gtk/gtkmediafile.c
index 0c856e80fd..a6dd289657 100644
--- a/gtk/gtkmediafile.c
+++ b/gtk/gtkmediafile.c
@@ -612,6 +612,15 @@ gtk_media_file_get_input_stream (GtkMediaFile *self)
   return priv->input_stream;
 }
 
+/* stolen from the glib testsuite */
+#ifdef _MSC_VER
+#  define MODULE_PREFIX ""
+#else
+#  define MODULE_PREFIX "lib"
+#endif
+
+#define MODULE_NAME(name) (MODULE_PREFIX name "." G_MODULE_SUFFIX)
+
 void
 gtk_media_file_extension_init (void)
 {
@@ -628,21 +637,23 @@ gtk_media_file_extension_init (void)
 
   g_type_ensure (GTK_TYPE_NO_MEDIA_FILE);
 
+  scope = g_io_module_scope_new (G_IO_MODULE_SCOPE_BLOCK_DUPLICATES);
+
 #ifdef HAVE_FFMPEG
   g_io_extension_point_implement (GTK_MEDIA_FILE_EXTENSION_POINT_NAME,
                                   GTK_TYPE_FF_MEDIA_FILE,
                                   "ffmpeg",
                                   0);
+  g_io_module_scope_block (scope, MODULE_NAME ("media-ffmpeg"));
 #endif
 #ifdef HAVE_GSTREAMER
   g_io_extension_point_implement (GTK_MEDIA_FILE_EXTENSION_POINT_NAME,
                                   GTK_TYPE_GST_MEDIA_FILE,
                                   "gstreamer",
                                   10);
+  g_io_module_scope_block (scope, MODULE_NAME ("media-gstreamer"));
 #endif
 
-  scope = g_io_module_scope_new (G_IO_MODULE_SCOPE_BLOCK_DUPLICATES);
-
   paths = _gtk_get_module_path ("media");
   for (i = 0; paths[i]; i++)
     {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]