mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-25 03:01:03 +00:00
gst: Don't ref_sink() GstObject subclasses in instance_init/constructor
This is something bindings can't handle and it causes leaks. Instead move the ref_sink() to the explicit, new() constructors. This means that abstract classes, and anything that can have subclasses, will have to do ref_sink() in their new() function now. Specifically this affects GstClock and GstControlSource. https://bugzilla.gnome.org/show_bug.cgi?id=743062
This commit is contained in:
parent
30f871d274
commit
daa98fc02a
14 changed files with 70 additions and 44 deletions
|
@ -229,9 +229,6 @@ gst_bus_init (GstBus * bus)
|
|||
g_mutex_init (&bus->priv->queue_lock);
|
||||
bus->priv->queue = gst_atomic_queue_new (32);
|
||||
|
||||
/* clear floating flag */
|
||||
gst_object_ref_sink (bus);
|
||||
|
||||
GST_DEBUG_OBJECT (bus, "created");
|
||||
}
|
||||
|
||||
|
@ -288,6 +285,9 @@ gst_bus_new (void)
|
|||
result = g_object_new (gst_bus_get_type (), NULL);
|
||||
GST_DEBUG_OBJECT (result, "created new bus");
|
||||
|
||||
/* clear floating flag */
|
||||
gst_object_ref_sink (result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -741,9 +741,6 @@ gst_clock_init (GstClock * clock)
|
|||
priv->timeout = DEFAULT_TIMEOUT;
|
||||
priv->times = g_new0 (GstClockTime, 4 * priv->window_size);
|
||||
priv->times_temp = priv->times + 2 * priv->window_size;
|
||||
|
||||
/* clear floating flag */
|
||||
gst_object_ref_sink (clock);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -57,15 +57,9 @@ GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
|
|||
G_DEFINE_ABSTRACT_TYPE_WITH_CODE (GstControlSource, gst_control_source,
|
||||
GST_TYPE_OBJECT, _do_init);
|
||||
|
||||
static GObject *gst_control_source_constructor (GType type,
|
||||
guint n_construct_params, GObjectConstructParam * construct_params);
|
||||
|
||||
static void
|
||||
gst_control_source_class_init (GstControlSourceClass * klass)
|
||||
{
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
gobject_class->constructor = gst_control_source_constructor;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -75,20 +69,6 @@ gst_control_source_init (GstControlSource * self)
|
|||
self->get_value_array = NULL;
|
||||
}
|
||||
|
||||
static GObject *
|
||||
gst_control_source_constructor (GType type, guint n_construct_params,
|
||||
GObjectConstructParam * construct_params)
|
||||
{
|
||||
GObject *self;
|
||||
|
||||
self =
|
||||
G_OBJECT_CLASS (gst_control_source_parent_class)->constructor (type,
|
||||
n_construct_params, construct_params);
|
||||
gst_object_ref_sink (self);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_control_source_get_value: (method)
|
||||
* @self: the #GstControlSource object
|
||||
|
|
|
@ -355,8 +355,8 @@ gst_system_clock_obtain (void)
|
|||
clock = g_object_new (GST_TYPE_SYSTEM_CLOCK,
|
||||
"name", "GstSystemClock", NULL);
|
||||
|
||||
g_assert (!g_object_is_floating (G_OBJECT (clock)));
|
||||
|
||||
/* Clear floating flag */
|
||||
gst_object_ref_sink (clock);
|
||||
_the_system_clock = clock;
|
||||
g_mutex_unlock (&_gst_sysclock_mutex);
|
||||
} else {
|
||||
|
|
|
@ -203,9 +203,6 @@ gst_task_init (GstTask * task)
|
|||
g_mutex_lock (&pool_lock);
|
||||
task->priv->pool = gst_object_ref (klass->pool);
|
||||
g_mutex_unlock (&pool_lock);
|
||||
|
||||
/* clear floating flag */
|
||||
gst_object_ref_sink (task);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -430,6 +427,9 @@ gst_task_new (GstTaskFunction func, gpointer user_data, GDestroyNotify notify)
|
|||
|
||||
GST_DEBUG ("Created task %p", task);
|
||||
|
||||
/* clear floating flag */
|
||||
gst_object_ref_sink (task);
|
||||
|
||||
return task;
|
||||
}
|
||||
|
||||
|
|
|
@ -140,8 +140,6 @@ gst_task_pool_class_init (GstTaskPoolClass * klass)
|
|||
static void
|
||||
gst_task_pool_init (GstTaskPool * pool)
|
||||
{
|
||||
/* clear floating flag */
|
||||
gst_object_ref_sink (pool);
|
||||
}
|
||||
|
||||
#ifndef GST_DISABLE_GST_DEBUG
|
||||
|
@ -168,6 +166,9 @@ gst_task_pool_new (void)
|
|||
|
||||
pool = g_object_new (GST_TYPE_TASK_POOL, NULL);
|
||||
|
||||
/* clear floating flag */
|
||||
gst_object_ref_sink (pool);
|
||||
|
||||
return pool;
|
||||
}
|
||||
|
||||
|
|
|
@ -255,9 +255,6 @@ gst_collect_pads_init (GstCollectPads * pads)
|
|||
pads->priv->seeking = FALSE;
|
||||
pads->priv->pending_flush_start = FALSE;
|
||||
pads->priv->pending_flush_stop = FALSE;
|
||||
|
||||
/* clear floating flag */
|
||||
gst_object_ref_sink (pads);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -297,6 +294,9 @@ gst_collect_pads_new (void)
|
|||
|
||||
newcoll = g_object_new (GST_TYPE_COLLECT_PADS, NULL);
|
||||
|
||||
/* clear floating flag */
|
||||
gst_object_ref_sink (newcoll);
|
||||
|
||||
return newcoll;
|
||||
}
|
||||
|
||||
|
|
|
@ -691,8 +691,15 @@ gst_test_clock_new (void)
|
|||
GstClock *
|
||||
gst_test_clock_new_with_start_time (GstClockTime start_time)
|
||||
{
|
||||
GstClock *clock;
|
||||
|
||||
g_assert_cmpuint (start_time, !=, GST_CLOCK_TIME_NONE);
|
||||
return g_object_new (GST_TYPE_TEST_CLOCK, "start-time", start_time, NULL);
|
||||
clock = g_object_new (GST_TYPE_TEST_CLOCK, "start-time", start_time, NULL);
|
||||
|
||||
/* Clear floating flag */
|
||||
gst_object_ref_sink (clock);
|
||||
|
||||
return clock;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -644,7 +644,13 @@ struct _GstInterpolationControlSourcePrivate
|
|||
GstControlSource *
|
||||
gst_interpolation_control_source_new (void)
|
||||
{
|
||||
return g_object_new (GST_TYPE_INTERPOLATION_CONTROL_SOURCE, NULL);
|
||||
GstControlSource *csource =
|
||||
g_object_new (GST_TYPE_INTERPOLATION_CONTROL_SOURCE, NULL);
|
||||
|
||||
/* Clear floating flag */
|
||||
gst_object_ref_sink (csource);
|
||||
|
||||
return csource;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
|
@ -398,7 +398,12 @@ gst_lfo_control_source_reset (GstLFOControlSource * self)
|
|||
GstControlSource *
|
||||
gst_lfo_control_source_new (void)
|
||||
{
|
||||
return g_object_new (GST_TYPE_LFO_CONTROL_SOURCE, NULL);
|
||||
GstControlSource *csource = g_object_new (GST_TYPE_LFO_CONTROL_SOURCE, NULL);
|
||||
|
||||
/* Clear floating flag */
|
||||
gst_object_ref_sink (csource);
|
||||
|
||||
return csource;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
|
@ -188,7 +188,13 @@ G_DEFINE_TYPE_WITH_CODE (GstTriggerControlSource, gst_trigger_control_source,
|
|||
GstControlSource *
|
||||
gst_trigger_control_source_new (void)
|
||||
{
|
||||
return g_object_new (GST_TYPE_TRIGGER_CONTROL_SOURCE, NULL);
|
||||
GstControlSource *csource =
|
||||
g_object_new (GST_TYPE_TRIGGER_CONTROL_SOURCE, NULL);
|
||||
|
||||
/* Clear floating flag */
|
||||
gst_object_ref_sink (csource);
|
||||
|
||||
return csource;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -1332,6 +1332,7 @@ gst_net_client_clock_constructed (GObject * object)
|
|||
g_object_new (GST_TYPE_NET_CLIENT_INTERNAL_CLOCK, "address",
|
||||
self->priv->address, "port", self->priv->port, "is-ntp",
|
||||
self->priv->is_ntp, NULL);
|
||||
gst_object_ref_sink (cache->clock);
|
||||
clocks = g_list_prepend (clocks, cache);
|
||||
|
||||
/* Not actually leaked but is cached for a while before being disposed,
|
||||
|
@ -1382,7 +1383,7 @@ gst_net_client_clock_get_internal_time (GstClock * clock)
|
|||
* provided by the #GstNetTimeProvider on @remote_address and
|
||||
* @remote_port.
|
||||
*
|
||||
* Returns: a new #GstClock that receives a time from the remote
|
||||
* Returns: (transfer full): a new #GstClock that receives a time from the remote
|
||||
* clock.
|
||||
*/
|
||||
GstClock *
|
||||
|
@ -1400,6 +1401,9 @@ gst_net_client_clock_new (const gchar * name, const gchar * remote_address,
|
|||
g_object_new (GST_TYPE_NET_CLIENT_CLOCK, "name", name, "address",
|
||||
remote_address, "port", remote_port, "base-time", base_time, NULL);
|
||||
|
||||
/* Clear floating flag */
|
||||
gst_object_ref_sink (ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -1426,7 +1430,7 @@ gst_ntp_clock_init (GstNtpClock * self)
|
|||
* Create a new #GstNtpClock that will report the time provided by
|
||||
* the NTPv4 server on @remote_address and @remote_port.
|
||||
*
|
||||
* Returns: a new #GstClock that receives a time from the remote
|
||||
* Returns: (transfer full): a new #GstClock that receives a time from the remote
|
||||
* clock.
|
||||
*
|
||||
* Since: 1.6
|
||||
|
@ -1446,5 +1450,7 @@ gst_ntp_clock_new (const gchar * name, const gchar * remote_address,
|
|||
g_object_new (GST_TYPE_NTP_CLOCK, "name", name, "address", remote_address,
|
||||
"port", remote_port, "base-time", base_time, NULL);
|
||||
|
||||
gst_object_ref_sink (ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -855,6 +855,7 @@ handle_announce_message (PtpMessage * msg, GstClockTime receive_time)
|
|||
clock_name = g_strdup_printf ("ptp-clock-%u", domain->domain);
|
||||
domain->domain_clock =
|
||||
g_object_new (GST_TYPE_SYSTEM_CLOCK, "name", clock_name, NULL);
|
||||
gst_object_ref_sink (domain->domain_clock);
|
||||
g_free (clock_name);
|
||||
g_queue_init (&domain->pending_syncs);
|
||||
domain->last_path_delays_missing = 9;
|
||||
|
@ -1445,6 +1446,7 @@ handle_sync_message (PtpMessage * msg, GstClockTime receive_time)
|
|||
clock_name = g_strdup_printf ("ptp-clock-%u", domain->domain);
|
||||
domain->domain_clock =
|
||||
g_object_new (GST_TYPE_SYSTEM_CLOCK, "name", clock_name, NULL);
|
||||
gst_object_ref_sink (domain->domain_clock);
|
||||
g_free (clock_name);
|
||||
g_queue_init (&domain->pending_syncs);
|
||||
domain->last_path_delays_missing = 9;
|
||||
|
@ -2111,6 +2113,7 @@ gst_ptp_init (guint64 clock_id, gchar ** interfaces)
|
|||
observation_system_clock =
|
||||
g_object_new (GST_TYPE_SYSTEM_CLOCK, "name", "ptp-observation-clock",
|
||||
NULL);
|
||||
gst_object_ref_sink (observation_system_clock);
|
||||
|
||||
initted = TRUE;
|
||||
|
||||
|
@ -2510,11 +2513,15 @@ gst_ptp_clock_get_internal_time (GstClock * clock)
|
|||
* check this with gst_clock_wait_for_sync(), the GstClock::synced signal and
|
||||
* gst_clock_is_synced().
|
||||
*
|
||||
* Returns: (transfer full): A new #GstClock
|
||||
*
|
||||
* Since: 1.6
|
||||
*/
|
||||
GstClock *
|
||||
gst_ptp_clock_new (const gchar * name, guint domain)
|
||||
{
|
||||
GstClock *clock;
|
||||
|
||||
g_return_val_if_fail (name != NULL, NULL);
|
||||
g_return_val_if_fail (domain <= G_MAXUINT8, NULL);
|
||||
|
||||
|
@ -2523,8 +2530,13 @@ gst_ptp_clock_new (const gchar * name, guint domain)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
return g_object_new (GST_TYPE_PTP_CLOCK, "name", name, "domain", domain,
|
||||
clock = g_object_new (GST_TYPE_PTP_CLOCK, "name", name, "domain", domain,
|
||||
NULL);
|
||||
|
||||
/* Clear floating flag */
|
||||
gst_object_ref_sink (clock);
|
||||
|
||||
return clock;
|
||||
}
|
||||
|
||||
typedef struct
|
||||
|
|
|
@ -231,7 +231,13 @@ static GType gst_test_control_source_get_type (void);
|
|||
static GstTestControlSource *
|
||||
gst_test_control_source_new (void)
|
||||
{
|
||||
return g_object_new (GST_TYPE_TEST_CONTROL_SOURCE, NULL);
|
||||
GstTestControlSource *csource =
|
||||
g_object_new (GST_TYPE_TEST_CONTROL_SOURCE, NULL);
|
||||
|
||||
/* Clear floating flag */
|
||||
gst_object_ref_sink (csource);
|
||||
|
||||
return csource;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
Loading…
Reference in a new issue