pbutils: Update for g_type_class_add_private() deprecation in recent GLib

https://gitlab.gnome.org/GNOME/glib/merge_requests/7
This commit is contained in:
Tim-Philipp Müller 2018-06-23 21:33:16 +02:00
parent 92579cb845
commit 511a8d7ddd
2 changed files with 16 additions and 10 deletions

View file

@ -60,6 +60,7 @@ enum
}; };
static GstBaseTransformClass *parent_class = NULL; static GstBaseTransformClass *parent_class = NULL;
static gint private_offset = 0;
static void gst_audio_visualizer_class_init (GstAudioVisualizerClass * klass); static void gst_audio_visualizer_class_init (GstAudioVisualizerClass * klass);
static void gst_audio_visualizer_init (GstAudioVisualizer * scope, static void gst_audio_visualizer_init (GstAudioVisualizer * scope,
@ -96,9 +97,6 @@ static gboolean gst_audio_visualizer_do_bufferpool (GstAudioVisualizer * scope,
static gboolean static gboolean
default_decide_allocation (GstAudioVisualizer * scope, GstQuery * query); default_decide_allocation (GstAudioVisualizer * scope, GstQuery * query);
#define GST_AUDIO_VISUALIZER_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), GST_TYPE_AUDIO_VISUALIZER, GstAudioVisualizerPrivate))
struct _GstAudioVisualizerPrivate struct _GstAudioVisualizerPrivate
{ {
gboolean negotiated; gboolean negotiated;
@ -520,18 +518,29 @@ gst_audio_visualizer_get_type (void)
/* TODO: rename when exporting it as a library */ /* TODO: rename when exporting it as a library */
_type = g_type_register_static (GST_TYPE_ELEMENT, _type = g_type_register_static (GST_TYPE_ELEMENT,
"GstAudioVisualizer", &audio_visualizer_info, G_TYPE_FLAG_ABSTRACT); "GstAudioVisualizer", &audio_visualizer_info, G_TYPE_FLAG_ABSTRACT);
private_offset =
g_type_add_instance_private (_type, sizeof (GstAudioVisualizerPrivate));
g_once_init_leave (&audio_visualizer_type, _type); g_once_init_leave (&audio_visualizer_type, _type);
} }
return (GType) audio_visualizer_type; return (GType) audio_visualizer_type;
} }
static inline GstAudioVisualizerPrivate *
gst_audio_visualizer_get_instance_private (GstAudioVisualizer * self)
{
return (G_STRUCT_MEMBER_P (self, private_offset));
}
static void static void
gst_audio_visualizer_class_init (GstAudioVisualizerClass * klass) gst_audio_visualizer_class_init (GstAudioVisualizerClass * klass)
{ {
GObjectClass *gobject_class = (GObjectClass *) klass; GObjectClass *gobject_class = (GObjectClass *) klass;
GstElementClass *element_class = (GstElementClass *) klass; GstElementClass *element_class = (GstElementClass *) klass;
g_type_class_add_private (klass, sizeof (GstAudioVisualizerPrivate)); if (private_offset != 0)
g_type_class_adjust_private_offset (klass, &private_offset);
parent_class = g_type_class_peek_parent (klass); parent_class = g_type_class_peek_parent (klass);
@ -566,7 +575,7 @@ gst_audio_visualizer_init (GstAudioVisualizer * scope,
{ {
GstPadTemplate *pad_template; GstPadTemplate *pad_template;
scope->priv = GST_AUDIO_VISUALIZER_GET_PRIVATE (scope); scope->priv = gst_audio_visualizer_get_instance_private (scope);
/* create the sink and src pads */ /* create the sink and src pads */
pad_template = pad_template =

View file

@ -158,7 +158,7 @@ _do_init (void)
}; };
G_DEFINE_TYPE_EXTENDED (GstDiscoverer, gst_discoverer, G_TYPE_OBJECT, 0, G_DEFINE_TYPE_EXTENDED (GstDiscoverer, gst_discoverer, G_TYPE_OBJECT, 0,
_do_init ()); G_ADD_PRIVATE (GstDiscoverer) _do_init ());
enum enum
{ {
@ -212,8 +212,6 @@ gst_discoverer_class_init (GstDiscovererClass * klass)
gobject_class->set_property = gst_discoverer_set_property; gobject_class->set_property = gst_discoverer_set_property;
gobject_class->get_property = gst_discoverer_get_property; gobject_class->get_property = gst_discoverer_get_property;
g_type_class_add_private (klass, sizeof (GstDiscovererPrivate));
/* properties */ /* properties */
/** /**
* GstDiscoverer:timeout: * GstDiscoverer:timeout:
@ -312,8 +310,7 @@ gst_discoverer_init (GstDiscoverer * dc)
GstElement *tmp; GstElement *tmp;
GstFormat format = GST_FORMAT_TIME; GstFormat format = GST_FORMAT_TIME;
dc->priv = G_TYPE_INSTANCE_GET_PRIVATE (dc, GST_TYPE_DISCOVERER, dc->priv = gst_discoverer_get_instance_private (dc);
GstDiscovererPrivate);
dc->priv->timeout = DEFAULT_PROP_TIMEOUT; dc->priv->timeout = DEFAULT_PROP_TIMEOUT;
dc->priv->async = FALSE; dc->priv->async = FALSE;