ext/ladspa/gstladspa.c: Don't use GST_BOILERPLATE as the stuff generated from it is not used anyway and can't be used.

Original commit message from CVS:
* ext/ladspa/gstladspa.c: (gst_ladspa_base_init),
(gst_ladspa_class_init), (ladspa_describe_plugin), (plugin_init):
Don't use GST_BOILERPLATE as the stuff generated from it is not used
anyway and can't be used.
Store the class struct of the correct type in parent_class.
Pass the LADSPA_Descriptor as class_data to the class_init function
as preparation for the time, when we can add pad templates and friends
in class_init and add a FIXME for that.
Don't use a custom hash table for passing the LADSPA_Descriptors to
base_init but use g_type_set_qdata and g_type_get_qdata.
This commit is contained in:
Sebastian Dröge 2008-02-04 19:15:39 +00:00
parent b250827579
commit 96d74fb23a
2 changed files with 36 additions and 34 deletions

View file

@ -1,3 +1,16 @@
2008-02-04 Sebastian Dröge <slomo@circular-chaos.org>
* ext/ladspa/gstladspa.c: (gst_ladspa_base_init),
(gst_ladspa_class_init), (ladspa_describe_plugin), (plugin_init):
Don't use GST_BOILERPLATE as the stuff generated from it is not used
anyway and can't be used.
Store the class struct of the correct type in parent_class.
Pass the LADSPA_Descriptor as class_data to the class_init function
as preparation for the time, when we can add pad templates and friends
in class_init and add a FIXME for that.
Don't use a custom hash table for passing the LADSPA_Descriptors to
base_init but use g_type_set_qdata and g_type_get_qdata.
2008-02-04 Edward Hervey <edward.hervey@collabora.co.uk> 2008-02-04 Edward Hervey <edward.hervey@collabora.co.uk>
* ext/mpeg2enc/gstmpeg2encpicturereader.cc: * ext/mpeg2enc/gstmpeg2encpicturereader.cc:

View file

@ -37,8 +37,7 @@
#define LADSPA_VERSION "1.0" #define LADSPA_VERSION "1.0"
#endif #endif
GST_BOILERPLATE (GstLADSPA, gst_ladspa, GstSignalProcessor, #define GST_LADSPA_DESCRIPTOR_QDATA g_quark_from_static_string("ladspa-descriptor")
GST_TYPE_SIGNAL_PROCESSOR);
static void gst_ladspa_set_property (GObject * object, guint prop_id, static void gst_ladspa_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec); const GValue * value, GParamSpec * pspec);
@ -52,10 +51,9 @@ static void gst_ladspa_stop (GstSignalProcessor * sigproc);
static void gst_ladspa_cleanup (GstSignalProcessor * sigproc); static void gst_ladspa_cleanup (GstSignalProcessor * sigproc);
static void gst_ladspa_process (GstSignalProcessor * sigproc, guint nframes); static void gst_ladspa_process (GstSignalProcessor * sigproc, guint nframes);
static GstSignalProcessorClass *parent_class;
static GstPlugin *ladspa_plugin; static GstPlugin *ladspa_plugin;
static GHashTable *ladspa_descriptors;
GST_DEBUG_CATEGORY_STATIC (ladspa_debug); GST_DEBUG_CATEGORY_STATIC (ladspa_debug);
#define GST_CAT_DEFAULT ladspa_debug #define GST_CAT_DEFAULT ladspa_debug
@ -73,13 +71,10 @@ gst_ladspa_base_init (gpointer g_class)
GST_DEBUG ("base_init %p", g_class); GST_DEBUG ("base_init %p", g_class);
desc = g_hash_table_lookup (ladspa_descriptors, desc = (LADSPA_Descriptor *) g_type_get_qdata (G_OBJECT_CLASS_TYPE (klass),
GINT_TO_POINTER (G_TYPE_FROM_CLASS (klass))); GST_LADSPA_DESCRIPTOR_QDATA);
if (!desc)
desc = g_hash_table_lookup (ladspa_descriptors, GINT_TO_POINTER (0));
g_assert (desc); g_assert (desc);
klass->descriptor = desc; klass->descriptor = desc;
g_assert (desc);
/* pad templates */ /* pad templates */
gsp_class->num_audio_in = 0; gsp_class->num_audio_in = 0;
@ -320,7 +315,7 @@ gst_ladspa_class_get_param_spec (GstLADSPAClass * klass, gint portnum)
} }
static void static void
gst_ladspa_class_init (GstLADSPAClass * klass) gst_ladspa_class_init (GstLADSPAClass * klass, LADSPA_Descriptor * desc)
{ {
GObjectClass *gobject_class; GObjectClass *gobject_class;
GstSignalProcessorClass *gsp_class; GstSignalProcessorClass *gsp_class;
@ -569,23 +564,24 @@ ladspa_describe_plugin (const char *pcFullFilename,
{ {
const LADSPA_Descriptor *desc; const LADSPA_Descriptor *desc;
gint i; gint i;
GTypeInfo typeinfo = {
sizeof (GstLADSPAClass),
(GBaseInitFunc) gst_ladspa_base_init,
NULL,
(GClassInitFunc) gst_ladspa_class_init,
NULL,
NULL,
sizeof (GstLADSPA),
0,
(GInstanceInitFunc) gst_ladspa_init,
};
GType type;
/* walk through all the plugins in this pluginlibrary */ /* walk through all the plugins in this pluginlibrary */
i = 0; i = 0;
while ((desc = pfDescriptorFunction (i++))) { while ((desc = pfDescriptorFunction (i++))) {
gchar *type_name; gchar *type_name;
GTypeInfo typeinfo = {
sizeof (GstLADSPAClass),
(GBaseInitFunc) gst_ladspa_base_init,
NULL,
(GClassInitFunc) gst_ladspa_class_init,
NULL,
desc,
sizeof (GstLADSPA),
0,
(GInstanceInitFunc) gst_ladspa_init,
};
GType type;
/* construct the type */ /* construct the type */
type_name = g_strdup_printf ("ladspa-%s", desc->Label); type_name = g_strdup_printf ("ladspa-%s", desc->Label);
@ -594,26 +590,20 @@ ladspa_describe_plugin (const char *pcFullFilename,
if (g_type_from_name (type_name)) if (g_type_from_name (type_name))
goto next; goto next;
/* base-init temp alloc */
g_hash_table_insert (ladspa_descriptors,
GINT_TO_POINTER (0), (gpointer) desc);
/* create the type now */ /* create the type now */
type = type =
g_type_register_static (GST_TYPE_SIGNAL_PROCESSOR, type_name, &typeinfo, g_type_register_static (GST_TYPE_SIGNAL_PROCESSOR, type_name, &typeinfo,
0); 0);
/* FIXME: not needed anymore when we can add pad templates, etc in class_init
* as class_data contains the LADSPA_Descriptor too */
g_type_set_qdata (type, GST_LADSPA_DESCRIPTOR_QDATA, (gpointer) desc);
if (!gst_element_register (ladspa_plugin, type_name, GST_RANK_NONE, type)) if (!gst_element_register (ladspa_plugin, type_name, GST_RANK_NONE, type))
goto next; goto next;
/* add this plugin to the hash */
g_hash_table_insert (ladspa_descriptors,
GINT_TO_POINTER (type), (gpointer) desc);
next: next:
g_free (type_name); g_free (type_name);
} }
g_hash_table_remove (ladspa_descriptors, GINT_TO_POINTER (0));
} }
static gboolean static gboolean
@ -622,8 +612,7 @@ plugin_init (GstPlugin * plugin)
GST_DEBUG_CATEGORY_INIT (ladspa_debug, "ladspa", GST_DEBUG_CATEGORY_INIT (ladspa_debug, "ladspa",
GST_DEBUG_FG_GREEN | GST_DEBUG_BG_BLACK | GST_DEBUG_BOLD, "LADSPA"); GST_DEBUG_FG_GREEN | GST_DEBUG_BG_BLACK | GST_DEBUG_BOLD, "LADSPA");
ladspa_descriptors = g_hash_table_new (NULL, NULL); parent_class = g_type_class_ref (GST_TYPE_SIGNAL_PROCESSOR);
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
ladspa_plugin = plugin; ladspa_plugin = plugin;