v4l2: Use G_DEFINE_ macros for added thread safety

This commit is contained in:
Olivier Crête 2013-08-19 12:46:45 -04:00
parent e47ffb203b
commit 24286f1612
4 changed files with 11 additions and 157 deletions

View file

@ -31,47 +31,15 @@
#include "gstv4l2object.h"
#include "v4l2_calls.h"
static void gst_v4l2_tuner_channel_class_init (GstV4l2TunerChannelClass *
klass);
static void gst_v4l2_tuner_channel_init (GstV4l2TunerChannel * channel);
G_DEFINE_TYPE (GstV4l2TunerChannel, gst_v4l2_tuner_channel,
GST_TYPE_TUNER_CHANNEL);
static void gst_v4l2_tuner_norm_class_init (GstV4l2TunerNormClass * klass);
static void gst_v4l2_tuner_norm_init (GstV4l2TunerNorm * norm);
G_DEFINE_TYPE (GstV4l2TunerNorm, gst_v4l2_tuner_norm, GST_TYPE_TUNER_NORM);
static GstTunerNormClass *norm_parent_class = NULL;
static GstTunerChannelClass *channel_parent_class = NULL;
GType
gst_v4l2_tuner_channel_get_type (void)
{
static GType gst_v4l2_tuner_channel_type = 0;
if (!gst_v4l2_tuner_channel_type) {
static const GTypeInfo v4l2_tuner_channel_info = {
sizeof (GstV4l2TunerChannelClass),
NULL,
NULL,
(GClassInitFunc) gst_v4l2_tuner_channel_class_init,
NULL,
NULL,
sizeof (GstV4l2TunerChannel),
0,
(GInstanceInitFunc) gst_v4l2_tuner_channel_init,
NULL
};
gst_v4l2_tuner_channel_type =
g_type_register_static (GST_TYPE_TUNER_CHANNEL,
"GstV4l2TunerChannel", &v4l2_tuner_channel_info, 0);
}
return gst_v4l2_tuner_channel_type;
}
static void
gst_v4l2_tuner_channel_class_init (GstV4l2TunerChannelClass * klass)
{
channel_parent_class = g_type_class_peek_parent (klass);
}
static void
@ -82,37 +50,9 @@ gst_v4l2_tuner_channel_init (GstV4l2TunerChannel * channel)
channel->audio = (guint32) - 1;
}
GType
gst_v4l2_tuner_norm_get_type (void)
{
static GType gst_v4l2_tuner_norm_type = 0;
if (!gst_v4l2_tuner_norm_type) {
static const GTypeInfo v4l2_tuner_norm_info = {
sizeof (GstV4l2TunerNormClass),
NULL,
NULL,
(GClassInitFunc) gst_v4l2_tuner_norm_class_init,
NULL,
NULL,
sizeof (GstV4l2TunerNorm),
0,
(GInstanceInitFunc) gst_v4l2_tuner_norm_init,
NULL
};
gst_v4l2_tuner_norm_type =
g_type_register_static (GST_TYPE_TUNER_NORM,
"GstV4l2TunerNorm", &v4l2_tuner_norm_info, 0);
}
return gst_v4l2_tuner_norm_type;
}
static void
gst_v4l2_tuner_norm_class_init (GstV4l2TunerNormClass * klass)
{
norm_parent_class = g_type_class_peek_parent (klass);
}
static void

View file

@ -82,37 +82,12 @@ enum
LAST_SIGNAL
};
static void gst_tuner_class_init (GstTunerInterface * iface);
static guint gst_tuner_signals[LAST_SIGNAL] = { 0 };
GType
gst_tuner_get_type (void)
{
static GType gst_tuner_type = 0;
if (!gst_tuner_type) {
static const GTypeInfo gst_tuner_info = {
sizeof (GstTunerInterface),
(GBaseInitFunc) gst_tuner_class_init,
NULL,
NULL,
NULL,
NULL,
0,
0,
NULL,
};
gst_tuner_type = g_type_register_static (G_TYPE_INTERFACE,
"GstTuner", &gst_tuner_info, 0);
}
return gst_tuner_type;
}
G_DEFINE_INTERFACE (GstTuner, gst_tuner, G_TYPE_INVALID);
static void
gst_tuner_class_init (GstTunerInterface * iface)
gst_tuner_default_init (GstTunerInterface * iface)
{
static gboolean initialized = FALSE;

View file

@ -51,47 +51,17 @@ enum
LAST_SIGNAL
};
static void gst_tuner_channel_class_init (GstTunerChannelClass * klass);
static void gst_tuner_channel_init (GstTunerChannel * channel);
G_DEFINE_TYPE (GstTunerChannel, gst_tuner_channel, G_TYPE_OBJECT);
static void gst_tuner_channel_dispose (GObject * object);
static GObjectClass *parent_class = NULL;
static guint signals[LAST_SIGNAL] = { 0 };
GType
gst_tuner_channel_get_type (void)
{
static GType gst_tuner_channel_type = 0;
if (!gst_tuner_channel_type) {
static const GTypeInfo tuner_channel_info = {
sizeof (GstTunerChannelClass),
NULL,
NULL,
(GClassInitFunc) gst_tuner_channel_class_init,
NULL,
NULL,
sizeof (GstTunerChannel),
0,
(GInstanceInitFunc) gst_tuner_channel_init,
NULL
};
gst_tuner_channel_type =
g_type_register_static (G_TYPE_OBJECT,
"GstTunerChannel", &tuner_channel_info, 0);
}
return gst_tuner_channel_type;
}
static void
gst_tuner_channel_class_init (GstTunerChannelClass * klass)
{
GObjectClass *object_klass = (GObjectClass *) klass;
parent_class = g_type_class_peek_parent (klass);
/**
* GstTunerChannel::frequency-changed:
* @tunerchannel: The #GstTunerChannel
@ -143,6 +113,5 @@ gst_tuner_channel_dispose (GObject * object)
channel->label = NULL;
}
if (parent_class->dispose)
parent_class->dispose (object);
G_OBJECT_CLASS (gst_tuner_channel_parent_class)->dispose (object);
}

View file

@ -44,47 +44,18 @@ enum
LAST_SIGNAL
};
static void gst_tuner_norm_class_init (GstTunerNormClass * klass);
static void gst_tuner_norm_init (GstTunerNorm * norm);
G_DEFINE_TYPE (GstTunerNorm, gst_tuner_norm, G_TYPE_OBJECT);
static void gst_tuner_norm_dispose (GObject * object);
static GObjectClass *parent_class = NULL;
/*static guint signals[LAST_SIGNAL] = { 0 };*/
GType
gst_tuner_norm_get_type (void)
{
static GType gst_tuner_norm_type = 0;
if (!gst_tuner_norm_type) {
static const GTypeInfo tuner_norm_info = {
sizeof (GstTunerNormClass),
NULL,
NULL,
(GClassInitFunc) gst_tuner_norm_class_init,
NULL,
NULL,
sizeof (GstTunerNorm),
0,
(GInstanceInitFunc) gst_tuner_norm_init,
NULL
};
gst_tuner_norm_type =
g_type_register_static (G_TYPE_OBJECT,
"GstTunerNorm", &tuner_norm_info, 0);
}
return gst_tuner_norm_type;
}
static void
gst_tuner_norm_class_init (GstTunerNormClass * klass)
{
GObjectClass *object_klass = (GObjectClass *) klass;
parent_class = g_type_class_peek_parent (klass);
object_klass->dispose = gst_tuner_norm_dispose;
}
@ -106,6 +77,5 @@ gst_tuner_norm_dispose (GObject * object)
norm->label = NULL;
}
if (parent_class->dispose)
parent_class->dispose (object);
G_OBJECT_CLASS (gst_tuner_norm_parent_class)->dispose (object);
}