videoaggregator: Update for g_type_class_add_private() deprecation in recent GLib
authorTim-Philipp Müller <tim@centricular.com>
Sat, 23 Jun 2018 22:17:26 +0000 (00:17 +0200)
committerTim-Philipp Müller <tim@centricular.com>
Sat, 23 Jun 2018 23:47:29 +0000 (01:47 +0200)
gst-libs/gst/video/gstvideoaggregator.c

index 4e1fc26..dafd59d 100644 (file)
@@ -83,7 +83,7 @@ struct _GstVideoAggregatorPadPrivate
 };
 
 
-G_DEFINE_TYPE (GstVideoAggregatorPad, gst_video_aggregator_pad,
+G_DEFINE_TYPE_WITH_PRIVATE (GstVideoAggregatorPad, gst_video_aggregator_pad,
     GST_TYPE_AGGREGATOR_PAD);
 
 static void
@@ -218,8 +218,6 @@ gst_video_aggregator_pad_class_init (GstVideoAggregatorPadClass * klass)
           DEFAULT_PAD_REPEAT_AFTER_EOS,
           G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE | G_PARAM_STATIC_STRINGS));
 
-  g_type_class_add_private (klass, sizeof (GstVideoAggregatorPadPrivate));
-
   aggpadclass->flush = GST_DEBUG_FUNCPTR (_flush_pad);
   aggpadclass->skip_buffer =
       GST_DEBUG_FUNCPTR (gst_video_aggregator_pad_skip_buffer);
@@ -231,9 +229,7 @@ gst_video_aggregator_pad_class_init (GstVideoAggregatorPadClass * klass)
 static void
 gst_video_aggregator_pad_init (GstVideoAggregatorPad * vaggpad)
 {
-  vaggpad->priv =
-      G_TYPE_INSTANCE_GET_PRIVATE (vaggpad, GST_TYPE_VIDEO_AGGREGATOR_PAD,
-      GstVideoAggregatorPadPrivate);
+  vaggpad->priv = gst_video_aggregator_pad_get_instance_private (vaggpad);
 
   vaggpad->priv->zorder = DEFAULT_PAD_ZORDER;
   vaggpad->priv->repeat_after_eos = DEFAULT_PAD_REPEAT_AFTER_EOS;
@@ -354,8 +350,8 @@ struct _GstVideoAggregatorConvertPadPrivate
   gboolean converter_config_changed;
 };
 
-G_DEFINE_TYPE (GstVideoAggregatorConvertPad, gst_video_aggregator_convert_pad,
-    GST_TYPE_VIDEO_AGGREGATOR_PAD);
+G_DEFINE_TYPE_WITH_PRIVATE (GstVideoAggregatorConvertPad,
+    gst_video_aggregator_convert_pad, GST_TYPE_VIDEO_AGGREGATOR_PAD);
 
 static void
 gst_video_aggregator_convert_pad_finalize (GObject * o)
@@ -596,9 +592,6 @@ gst_video_aggregator_convert_pad_class_init (GstVideoAggregatorConvertPadClass *
   gobject_class->set_property =
       GST_DEBUG_FUNCPTR (gst_video_aggregator_convert_pad_set_property);
 
-  g_type_class_add_private (klass,
-      sizeof (GstVideoAggregatorConvertPadPrivate));
-
   g_object_class_install_property (gobject_class,
       PROP_CONVERT_PAD_CONVERTER_CONFIG, g_param_spec_boxed ("converter-config",
           "Converter configuration",
@@ -622,9 +615,7 @@ static void
 gst_video_aggregator_convert_pad_init (GstVideoAggregatorConvertPad * vaggpad)
 {
   vaggpad->priv =
-      G_TYPE_INSTANCE_GET_PRIVATE (vaggpad,
-      GST_TYPE_VIDEO_AGGREGATOR_CONVERT_PAD,
-      GstVideoAggregatorConvertPadPrivate);
+      gst_video_aggregator_convert_pad_get_instance_private (vaggpad);
 
   vaggpad->priv->converted_buffer = NULL;
   vaggpad->priv->convert = NULL;
@@ -700,6 +691,7 @@ static void gst_video_aggregator_init (GstVideoAggregator * self,
     GstVideoAggregatorClass * klass);
 static void gst_video_aggregator_class_init (GstVideoAggregatorClass * klass);
 static gpointer gst_video_aggregator_parent_class = NULL;
+static gint video_aggregator_private_offset = 0;
 
 GType
 gst_video_aggregator_get_type (void)
@@ -714,11 +706,22 @@ gst_video_aggregator_get_type (void)
         sizeof (GstVideoAggregator),
         (GInstanceInitFunc) gst_video_aggregator_init,
         (GTypeFlags) G_TYPE_FLAG_ABSTRACT);
+
+    video_aggregator_private_offset =
+        g_type_add_instance_private (g_define_type_id,
+        sizeof (GstVideoAggregatorPrivate));
+
     g_once_init_leave (&g_define_type_id_volatile, g_define_type_id);
   }
   return g_define_type_id_volatile;
 }
 
+static inline GstVideoAggregatorPrivate *
+gst_video_aggregator_get_instance_private (GstVideoAggregator * self)
+{
+  return (G_STRUCT_MEMBER_P (self, video_aggregator_private_offset));
+}
+
 static void
 gst_video_aggregator_find_best_format (GstVideoAggregator * vagg,
     GstCaps * downstream_caps, GstVideoInfo * best_info,
@@ -2515,7 +2518,9 @@ gst_video_aggregator_class_init (GstVideoAggregatorClass * klass)
 
   gst_video_aggregator_parent_class = g_type_class_peek_parent (klass);
 
-  g_type_class_add_private (klass, sizeof (GstVideoAggregatorPrivate));
+  if (video_aggregator_private_offset != 0)
+    g_type_class_adjust_private_offset (klass,
+        &video_aggregator_private_offset);
 
   gobject_class->finalize = gst_video_aggregator_finalize;
   gobject_class->dispose = gst_video_aggregator_dispose;
@@ -2556,9 +2561,7 @@ static void
 gst_video_aggregator_init (GstVideoAggregator * vagg,
     GstVideoAggregatorClass * klass)
 {
-  vagg->priv =
-      G_TYPE_INSTANCE_GET_PRIVATE (vagg, GST_TYPE_VIDEO_AGGREGATOR,
-      GstVideoAggregatorPrivate);
+  vagg->priv = gst_video_aggregator_get_instance_private (vagg);
 
   vagg->priv->current_caps = NULL;