[farsight2/master] Fix the plugin loading code again

Olivier Crête olivier.crete at collabora.co.uk
Tue Dec 23 15:19:30 PST 2008


---
 gst-libs/gst/farsight/fs-plugin.c                  |    4 +-
 gst-libs/gst/farsight/fs-plugin.h                  |    7 +--
 transmitters/rawudp/fs-rawudp-stream-transmitter.c |   40 +++++++++--------
 transmitters/rawudp/fs-rawudp-stream-transmitter.h |    5 +-
 transmitters/rawudp/fs-rawudp-transmitter.c        |   46 +++++++++++--------
 transmitters/rawudp/fs-rawudp-transmitter.h        |    4 --
 6 files changed, 57 insertions(+), 49 deletions(-)

diff --git a/gst-libs/gst/farsight/fs-plugin.c b/gst-libs/gst/farsight/fs-plugin.c
index e3222ca..1eae591 100644
--- a/gst-libs/gst/farsight/fs-plugin.c
+++ b/gst-libs/gst/farsight/fs-plugin.c
@@ -217,8 +217,8 @@ static gboolean fs_plugin_load (GTypeModule *module)
     return FALSE;
   }
 
-
-  if (!fs_init_plugin (plugin)) {
+  fs_init_plugin (plugin);
+  if (!plugin->type) {
     /* TODO error handling (init error or no info defined) */
     g_warning ("init error or no info defined");
     goto err_close_module;
diff --git a/gst-libs/gst/farsight/fs-plugin.h b/gst-libs/gst/farsight/fs-plugin.h
index d9abd2f..28abd63 100644
--- a/gst-libs/gst/farsight/fs-plugin.h
+++ b/gst-libs/gst/farsight/fs-plugin.h
@@ -100,11 +100,10 @@ GObject *fs_plugin_create_valist (const gchar *name,
  * in any farsight plugin.
  */
 
-#define FS_INIT_PLUGIN(intype, inunload)                        \
-    G_MODULE_EXPORT GType fs_init_plugin (FsPlugin *plugin) {   \
-      plugin->type = (intype);                                  \
+#define FS_INIT_PLUGIN(type_register_func, inunload)            \
+    G_MODULE_EXPORT void fs_init_plugin (FsPlugin *plugin) {    \
+      plugin->type = (type_register_func (plugin));             \
       plugin->unload = (inunload);                              \
-      return intype;                                            \
     }
 
 
diff --git a/transmitters/rawudp/fs-rawudp-stream-transmitter.c b/transmitters/rawudp/fs-rawudp-stream-transmitter.c
index 68be41f..c39de47 100644
--- a/transmitters/rawudp/fs-rawudp-stream-transmitter.c
+++ b/transmitters/rawudp/fs-rawudp-stream-transmitter.c
@@ -147,27 +147,31 @@ static gboolean fs_rawudp_stream_transmitter_finish_candidate_generation (
 static GObjectClass *parent_class = NULL;
 // static guint signals[LAST_SIGNAL] = { 0 };
 
+static GType type = 0;
+
 GType
 fs_rawudp_stream_transmitter_get_type (void)
 {
-  static GType type = 0;
-
-  if (type == 0) {
-    static const GTypeInfo info = {
-      sizeof (FsRawUdpStreamTransmitterClass),
-      NULL,
-      NULL,
-      (GClassInitFunc) fs_rawudp_stream_transmitter_class_init,
-      NULL,
-      NULL,
-      sizeof (FsRawUdpStreamTransmitter),
-      0,
-      (GInstanceInitFunc) fs_rawudp_stream_transmitter_init
-    };
+  return type;
+}
 
-    type = g_type_register_static (G_TYPE_OBJECT,
-        "FsRawUdpStreamTransmitter", &info, G_TYPE_FLAG_ABSTRACT);
-  }
+GType
+fs_rawudp_stream_transmitter_register_type (FsPlugin *module)
+{
+  static const GTypeInfo info = {
+    sizeof (FsRawUdpStreamTransmitterClass),
+    NULL,
+    NULL,
+    (GClassInitFunc) fs_rawudp_stream_transmitter_class_init,
+    NULL,
+    NULL,
+    sizeof (FsRawUdpStreamTransmitter),
+    0,
+    (GInstanceInitFunc) fs_rawudp_stream_transmitter_init
+  };
+
+  type = g_type_module_register_type (G_TYPE_MODULE (module),
+    FS_TYPE_STREAM_TRANSMITTER, "FsRawUdpStreamTransmitter", &info, 0);
 
   return type;
 }
diff --git a/transmitters/rawudp/fs-rawudp-stream-transmitter.h b/transmitters/rawudp/fs-rawudp-stream-transmitter.h
index 040bfa5..148ae5b 100644
--- a/transmitters/rawudp/fs-rawudp-stream-transmitter.h
+++ b/transmitters/rawudp/fs-rawudp-stream-transmitter.h
@@ -29,6 +29,7 @@
 #include <glib-object.h>
 
 #include <gst/farsight/fs-stream-transmitter.h>
+#include <gst/farsight/fs-plugin.h>
 #include "fs-rawudp-transmitter.h"
 
 G_BEGIN_DECLS
@@ -68,7 +69,6 @@ struct _FsRawUdpStreamTransmitterClass
 
   /*virtual functions */
   /*< private >*/
-  gpointer _padding[8];
 };
 
 /**
@@ -82,9 +82,10 @@ struct _FsRawUdpStreamTransmitter
 
   /*< private >*/
   FsRawUdpStreamTransmitterPrivate *priv;
-  gpointer _padding[8];
 };
 
+GType fs_rawudp_stream_transmitter_register_type (FsPlugin *module);
+
 GType fs_rawudp_stream_transmitter_get_type (void);
 
 FsRawUdpStreamTransmitter *
diff --git a/transmitters/rawudp/fs-rawudp-transmitter.c b/transmitters/rawudp/fs-rawudp-transmitter.c
index 0c6a0d6..571ea14 100644
--- a/transmitters/rawudp/fs-rawudp-transmitter.c
+++ b/transmitters/rawudp/fs-rawudp-transmitter.c
@@ -113,33 +113,41 @@ static GObjectClass *parent_class = NULL;
  * Lets register the plugin
  */
 
-FS_INIT_PLUGIN(FS_TYPE_RAWUDP_TRANSMITTER, NULL)
+static GType type = 0;
 
 GType
 fs_rawudp_transmitter_get_type (void)
 {
-  static GType type = 0;
-
-  if (type == 0) {
-    static const GTypeInfo info = {
-      sizeof (FsRawUdpTransmitterClass),
-      NULL,
-      NULL,
-      (GClassInitFunc) fs_rawudp_transmitter_class_init,
-      NULL,
-      NULL,
-      sizeof (FsRawUdpTransmitter),
-      0,
-      (GInstanceInitFunc) fs_rawudp_transmitter_init
-    };
-
-    type = g_type_register_static (FS_TYPE_TRANSMITTER,
-        "FsRawUdpTransmitter", &info, 0);
-  }
+  g_assert (type);
+  return type;
+}
 
+static GType
+fs_rawudp_transmitter_register_type (FsPlugin *module)
+{
+  static const GTypeInfo info = {
+    sizeof (FsRawUdpTransmitterClass),
+    NULL,
+    NULL,
+    (GClassInitFunc) fs_rawudp_transmitter_class_init,
+    NULL,
+    NULL,
+    sizeof (FsRawUdpTransmitter),
+    0,
+    (GInstanceInitFunc) fs_rawudp_transmitter_init
+  };
+
+  fs_rawudp_stream_transmitter_register_type (module);
+
+  type = g_type_module_register_type (G_TYPE_MODULE (module),
+    FS_TYPE_TRANSMITTER, "FsRawUdpTransmitter", &info, 0);
+  
   return type;
 }
 
+FS_INIT_PLUGIN (fs_rawudp_transmitter_register_type, NULL)
+
+
 static void
 fs_rawudp_transmitter_class_init (FsRawUdpTransmitterClass *klass)
 {
diff --git a/transmitters/rawudp/fs-rawudp-transmitter.h b/transmitters/rawudp/fs-rawudp-transmitter.h
index 4519a44..6eada3e 100644
--- a/transmitters/rawudp/fs-rawudp-transmitter.h
+++ b/transmitters/rawudp/fs-rawudp-transmitter.h
@@ -65,9 +65,6 @@ typedef struct _FsRawUdpTransmitterPrivate FsRawUdpTransmitterPrivate;
 struct _FsRawUdpTransmitterClass
 {
   FsTransmitterClass parent_class;
-
-  /*< private >*/
-  gpointer _padding[8];
 };
 
 /**
@@ -81,7 +78,6 @@ struct _FsRawUdpTransmitter
 
   /*< private >*/
   FsRawUdpTransmitterPrivate *priv;
-  gpointer _padding[8];
 };
 
 /* Private declaration */
-- 
1.5.6.5




More information about the farsight-commits mailing list