From f50b3af5d776bbb88f6a577c0ac0399d634e2449 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Tue, 19 Apr 2011 10:52:00 +0200 Subject: [PATCH] audio: Use G_DEFINE_TYPE instead of GST_BOILERPLATE --- gst-libs/gst/audio/gstaudiosink.c | 13 ++---- gst-libs/gst/audio/gstaudiosrc.c | 13 ++---- gst-libs/gst/audio/gstbaseaudiosink.c | 61 +++++++-------------------- gst-libs/gst/audio/gstbaseaudiosrc.c | 13 ++---- 4 files changed, 28 insertions(+), 72 deletions(-) diff --git a/gst-libs/gst/audio/gstaudiosink.c b/gst-libs/gst/audio/gstaudiosink.c index adea6be77a..88c6f7b282 100644 --- a/gst-libs/gst/audio/gstaudiosink.c +++ b/gst-libs/gst/audio/gstaudiosink.c @@ -574,20 +574,15 @@ enum ARG_0, }; -#define _do_init(bla) \ +#define _do_init \ GST_DEBUG_CATEGORY_INIT (gst_audio_sink_debug, "audiosink", 0, "audiosink element"); - -GST_BOILERPLATE_FULL (GstAudioSink, gst_audio_sink, GstBaseAudioSink, +#define gst_audio_sink_parent_class parent_class +G_DEFINE_TYPE_WITH_CODE (GstAudioSink, gst_audio_sink, GST_TYPE_BASE_AUDIO_SINK, _do_init); static GstRingBuffer *gst_audio_sink_create_ringbuffer (GstBaseAudioSink * sink); -static void -gst_audio_sink_base_init (gpointer g_class) -{ -} - static void gst_audio_sink_class_init (GstAudioSinkClass * klass) { @@ -602,7 +597,7 @@ gst_audio_sink_class_init (GstAudioSinkClass * klass) } static void -gst_audio_sink_init (GstAudioSink * audiosink, GstAudioSinkClass * g_class) +gst_audio_sink_init (GstAudioSink * audiosink) { } diff --git a/gst-libs/gst/audio/gstaudiosrc.c b/gst-libs/gst/audio/gstaudiosrc.c index b8f9e0b185..57864d1b79 100644 --- a/gst-libs/gst/audio/gstaudiosrc.c +++ b/gst-libs/gst/audio/gstaudiosrc.c @@ -488,19 +488,14 @@ enum ARG_0, }; -#define _do_init(bla) \ +#define _do_init \ GST_DEBUG_CATEGORY_INIT (gst_audio_src_debug, "audiosrc", 0, "audiosrc element"); - -GST_BOILERPLATE_FULL (GstAudioSrc, gst_audio_src, GstBaseAudioSrc, +#define gst_audio_src_parent_class parent_class +G_DEFINE_TYPE_WITH_CODE (GstAudioSrc, gst_audio_src, GST_TYPE_BASE_AUDIO_SRC, _do_init); static GstRingBuffer *gst_audio_src_create_ringbuffer (GstBaseAudioSrc * src); -static void -gst_audio_src_base_init (gpointer g_class) -{ -} - static void gst_audio_src_class_init (GstAudioSrcClass * klass) { @@ -515,7 +510,7 @@ gst_audio_src_class_init (GstAudioSrcClass * klass) } static void -gst_audio_src_init (GstAudioSrc * audiosrc, GstAudioSrcClass * g_class) +gst_audio_src_init (GstAudioSrc * audiosrc) { } diff --git a/gst-libs/gst/audio/gstbaseaudiosink.c b/gst-libs/gst/audio/gstbaseaudiosink.c index da1bff03c4..69868fee7a 100644 --- a/gst-libs/gst/audio/gstbaseaudiosink.c +++ b/gst-libs/gst/audio/gstbaseaudiosink.c @@ -57,7 +57,6 @@ struct _GstBaseAudioSinkPrivate GstClockTime eos_time; - gboolean do_time_offset; /* number of microseconds we alow timestamps or clock slaving to drift * before resyncing */ guint64 drift_tolerance; @@ -119,10 +118,10 @@ gst_base_audio_sink_slave_method_get_type (void) } -#define _do_init(bla) \ +#define _do_init \ GST_DEBUG_CATEGORY_INIT (gst_base_audio_sink_debug, "baseaudiosink", 0, "baseaudiosink element"); - -GST_BOILERPLATE_FULL (GstBaseAudioSink, gst_base_audio_sink, GstBaseSink, +#define gst_base_audio_sink_parent_class parent_class +G_DEFINE_TYPE_WITH_CODE (GstBaseAudioSink, gst_base_audio_sink, GST_TYPE_BASE_SINK, _do_init); static void gst_base_audio_sink_dispose (GObject * object); @@ -166,11 +165,6 @@ static gboolean gst_base_audio_sink_query_pad (GstPad * pad, GstQuery * query); /* static guint gst_base_audio_sink_signals[LAST_SIGNAL] = { 0 }; */ -static void -gst_base_audio_sink_base_init (gpointer g_class) -{ -} - static void gst_base_audio_sink_class_init (GstBaseAudioSinkClass * klass) { @@ -257,10 +251,8 @@ gst_base_audio_sink_class_init (GstBaseAudioSinkClass * klass) } static void -gst_base_audio_sink_init (GstBaseAudioSink * baseaudiosink, - GstBaseAudioSinkClass * g_class) +gst_base_audio_sink_init (GstBaseAudioSink * baseaudiosink) { - GstPluginFeature *feature; GstBaseSink *basesink; baseaudiosink->priv = GST_BASE_AUDIO_SINK_GET_PRIVATE (baseaudiosink); @@ -283,25 +275,6 @@ gst_base_audio_sink_init (GstBaseAudioSink * baseaudiosink, /* install some custom pad_query functions */ gst_pad_set_query_function (GST_BASE_SINK_PAD (baseaudiosink), GST_DEBUG_FUNCPTR (gst_base_audio_sink_query_pad)); - - baseaudiosink->priv->do_time_offset = TRUE; - - /* check the factory, pulsesink < 0.10.17 does the timestamp offset itself so - * we should not do ourselves */ - feature = - GST_PLUGIN_FEATURE_CAST (GST_ELEMENT_CLASS (g_class)->elementfactory); - GST_DEBUG ("created from factory %p", feature); - - /* HACK for old pulsesink that did the time_offset themselves */ - if (feature) { - if (strcmp (gst_plugin_feature_get_name (feature), "pulsesink") == 0) { - if (!gst_plugin_feature_check_version (feature, 0, 10, 17)) { - /* we're dealing with an old pulsesink, we need to disable time corection */ - GST_DEBUG ("disable time offset"); - baseaudiosink->priv->do_time_offset = FALSE; - } - } - } } static void @@ -1585,20 +1558,18 @@ gst_base_audio_sink_render (GstBaseSink * bsink, GstBuffer * buf) GST_TIME_ARGS (render_start), GST_TIME_ARGS (render_stop)); /* bring to position in the ringbuffer */ - if (sink->priv->do_time_offset) { - time_offset = - GST_AUDIO_CLOCK_CAST (sink->provided_clock)->abidata.ABI.time_offset; - GST_DEBUG_OBJECT (sink, - "time offset %" GST_TIME_FORMAT, GST_TIME_ARGS (time_offset)); - if (render_start > time_offset) - render_start -= time_offset; - else - render_start = 0; - if (render_stop > time_offset) - render_stop -= time_offset; - else - render_stop = 0; - } + time_offset = + GST_AUDIO_CLOCK_CAST (sink->provided_clock)->abidata.ABI.time_offset; + GST_DEBUG_OBJECT (sink, + "time offset %" GST_TIME_FORMAT, GST_TIME_ARGS (time_offset)); + if (render_start > time_offset) + render_start -= time_offset; + else + render_start = 0; + if (render_stop > time_offset) + render_stop -= time_offset; + else + render_stop = 0; /* and bring the time to the rate corrected offset in the buffer */ render_start = gst_util_uint64_scale_int (render_start, diff --git a/gst-libs/gst/audio/gstbaseaudiosrc.c b/gst-libs/gst/audio/gstbaseaudiosrc.c index 8135e432c7..48ac2df0fa 100644 --- a/gst-libs/gst/audio/gstbaseaudiosrc.c +++ b/gst-libs/gst/audio/gstbaseaudiosrc.c @@ -119,8 +119,9 @@ _do_init (GType type) #endif /* ENABLE_NLS */ } -GST_BOILERPLATE_FULL (GstBaseAudioSrc, gst_base_audio_src, GstPushSrc, - GST_TYPE_PUSH_SRC, _do_init); +#define gst_base_audio_src_parent_class parent_class +G_DEFINE_TYPE_WITH_CODE (GstBaseAudioSrc, gst_base_audio_src, GST_TYPE_PUSH_SRC, + _do_init (g_define_type_id)); static void gst_base_audio_src_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec); @@ -148,11 +149,6 @@ static void gst_base_audio_src_fixate (GstBaseSrc * bsrc, GstCaps * caps); /* static guint gst_base_audio_src_signals[LAST_SIGNAL] = { 0 }; */ -static void -gst_base_audio_src_base_init (gpointer g_class) -{ -} - static void gst_base_audio_src_class_init (GstBaseAudioSrcClass * klass) { @@ -241,8 +237,7 @@ gst_base_audio_src_class_init (GstBaseAudioSrcClass * klass) } static void -gst_base_audio_src_init (GstBaseAudioSrc * baseaudiosrc, - GstBaseAudioSrcClass * g_class) +gst_base_audio_src_init (GstBaseAudioSrc * baseaudiosrc) { baseaudiosrc->priv = GST_BASE_AUDIO_SRC_GET_PRIVATE (baseaudiosrc);