Use gst_object_unref() / gst_object_clear() instead of the GObject ones

To allow the refcounting tracer to work better. In childproxy/iterator
these might be plain GObjects but gst_object_unref() also works on them.
In other places where it is never GstObject, g_object_unref() is kept.
This commit is contained in:
Sebastian Dröge 2020-04-20 16:21:10 +03:00 committed by Sebastian Dröge
parent c8bcb9db18
commit ed1022fa81
25 changed files with 52 additions and 55 deletions

View file

@ -625,7 +625,7 @@ _add_element_pad_templates (GString * json, GstElement * element,
g_string_append (json, ",\"object-type\": {"); g_string_append (json, ",\"object-type\": {");
tmpobj = g_object_new (pad_type, NULL); tmpobj = g_object_new (pad_type, NULL);
_add_object_details (json, tmpobj); _add_object_details (json, tmpobj);
g_object_unref (tmpobj); gst_object_unref (tmpobj);
g_string_append (json, "}"); g_string_append (json, "}");
} }
g_string_append (json, "}"); g_string_append (json, "}");

View file

@ -1120,7 +1120,7 @@ gst_bin_do_deep_add_remove (GstBin * bin, gint sig_id, const gchar * sig_name,
do { do {
ires = gst_iterator_foreach (it, bin_deep_iterator_foreach, &elements); ires = gst_iterator_foreach (it, bin_deep_iterator_foreach, &elements);
if (ires != GST_ITERATOR_DONE) { if (ires != GST_ITERATOR_DONE) {
g_queue_foreach (&elements, (GFunc) g_object_unref, NULL); g_queue_foreach (&elements, (GFunc) gst_object_unref, NULL);
g_queue_clear (&elements); g_queue_clear (&elements);
} }
if (ires == GST_ITERATOR_RESYNC) if (ires == GST_ITERATOR_RESYNC)
@ -1139,7 +1139,7 @@ gst_bin_do_deep_add_remove (GstBin * bin, gint sig_id, const gchar * sig_name,
" in bin %" GST_PTR_FORMAT, sig_name, e, parent); " in bin %" GST_PTR_FORMAT, sig_name, e, parent);
g_signal_emit (bin, sig_id, 0, parent, e); g_signal_emit (bin, sig_id, 0, parent, e);
gst_object_unref (parent); gst_object_unref (parent);
g_object_unref (e); gst_object_unref (e);
} }
} }
} }

View file

@ -92,7 +92,7 @@ gst_child_proxy_default_get_child_by_name (GstChildProxy * parent,
break; break;
} }
next: next:
g_object_unref (object); gst_object_unref (object);
} }
return result; return result;
} }
@ -228,7 +228,7 @@ gst_child_proxy_lookup (GstChildProxy * object, const gchar * name,
GST_INFO ("no such object %s", current[0]); GST_INFO ("no such object %s", current[0]);
break; break;
} }
g_object_unref (obj); gst_object_unref (obj);
obj = next; obj = next;
current++; current++;
} }
@ -249,7 +249,7 @@ gst_child_proxy_lookup (GstChildProxy * object, const gchar * name,
res = TRUE; res = TRUE;
} }
} }
g_object_unref (obj); gst_object_unref (obj);
g_strfreev (names); g_strfreev (names);
return res; return res;
} }
@ -278,7 +278,7 @@ gst_child_proxy_get_property (GstChildProxy * object, const gchar * name,
goto not_found; goto not_found;
g_object_get_property (target, pspec->name, value); g_object_get_property (target, pspec->name, value);
g_object_unref (target); gst_object_unref (target);
return; return;
@ -319,7 +319,7 @@ gst_child_proxy_get_valist (GstChildProxy * object,
g_value_init (&value, pspec->value_type); g_value_init (&value, pspec->value_type);
g_object_get_property (target, pspec->name, &value); g_object_get_property (target, pspec->name, &value);
g_object_unref (target); gst_object_unref (target);
G_VALUE_LCOPY (&value, var_args, 0, &error); G_VALUE_LCOPY (&value, var_args, 0, &error);
if (error) if (error)
@ -388,7 +388,7 @@ gst_child_proxy_set_property (GstChildProxy * object, const gchar * name,
goto not_found; goto not_found;
g_object_set_property (target, pspec->name, value); g_object_set_property (target, pspec->name, value);
g_object_unref (target); gst_object_unref (target);
return; return;
not_found: not_found:
@ -433,7 +433,7 @@ gst_child_proxy_set_valist (GstChildProxy * object,
goto cant_copy; goto cant_copy;
g_object_set_property (target, pspec->name, &value); g_object_set_property (target, pspec->name, &value);
g_object_unref (target); gst_object_unref (target);
g_value_unset (&value); g_value_unset (&value);
name = va_arg (var_args, gchar *); name = va_arg (var_args, gchar *);
@ -451,7 +451,7 @@ cant_copy:
g_warning ("error copying value %s in object %s: %s", pspec->name, g_warning ("error copying value %s in object %s: %s", pspec->name,
(GST_IS_OBJECT (object) ? GST_OBJECT_NAME (object) : ""), error); (GST_IS_OBJECT (object) ? GST_OBJECT_NAME (object) : ""), error);
g_value_unset (&value); g_value_unset (&value);
g_object_unref (target); gst_object_unref (target);
g_free (error); g_free (error);
return; return;
} }

View file

@ -212,7 +212,7 @@ static void
gst_list_iterator_free (GstListIterator * it) gst_list_iterator_free (GstListIterator * it)
{ {
if (it->owner) if (it->owner)
g_object_unref (it->owner); gst_object_unref (it->owner);
} }
/** /**

View file

@ -2886,7 +2886,7 @@ gst_pad_get_single_internal_link (GstPad * pad)
ret = g_value_dup_object (&item); ret = g_value_dup_object (&item);
} else { } else {
/* More than one internal link found - don't bother reffing */ /* More than one internal link found - don't bother reffing */
g_clear_object (&ret); gst_clear_object (&ret);
GST_DEBUG_OBJECT (pad, GST_DEBUG_OBJECT (pad,
"Requested single internally linked pad, multiple found"); "Requested single internally linked pad, multiple found");
done = TRUE; done = TRUE;
@ -2895,7 +2895,7 @@ gst_pad_get_single_internal_link (GstPad * pad)
break; break;
} }
case GST_ITERATOR_RESYNC: case GST_ITERATOR_RESYNC:
g_clear_object (&ret); gst_clear_object (&ret);
gst_iterator_resync (iter); gst_iterator_resync (iter);
break; break;
case GST_ITERATOR_ERROR: case GST_ITERATOR_ERROR:

View file

@ -622,7 +622,7 @@ gst_preset_default_get_property_names (GstPreset * preset)
g_free (props); g_free (props);
} }
g_object_unref (child); gst_object_unref (child);
} }
} }
if (!result) { if (!result) {

View file

@ -747,10 +747,7 @@ gst_registry_chunks_load_feature (GstRegistry * registry, gchar ** in,
fail: fail:
GST_INFO ("Reading plugin feature failed"); GST_INFO ("Reading plugin feature failed");
if (feature) { if (feature) {
if (GST_IS_OBJECT (feature)) gst_object_unref (feature);
gst_object_unref (feature);
else
g_object_unref (feature);
} }
return FALSE; return FALSE;
} }

View file

@ -578,7 +578,7 @@ gst_system_clock_set_default (GstClock * new_clock)
clock = _the_system_clock; clock = _the_system_clock;
if (clock != NULL) if (clock != NULL)
g_object_unref (clock); gst_object_unref (clock);
if (new_clock == NULL) { if (new_clock == NULL) {
GST_CAT_DEBUG (GST_CAT_CLOCK, "resetting default system clock"); GST_CAT_DEBUG (GST_CAT_CLOCK, "resetting default system clock");

View file

@ -358,7 +358,7 @@ out:
if (G_IS_VALUE (&v)) if (G_IS_VALUE (&v))
g_value_unset (&v); g_value_unset (&v);
if (target) if (target)
g_object_unref (target); gst_object_unref (target);
return; return;
error: error:
@ -446,7 +446,7 @@ out:
if (G_IS_VALUE (&v)) if (G_IS_VALUE (&v))
g_value_unset (&v); g_value_unset (&v);
if (target) if (target)
g_object_unref (target); gst_object_unref (target);
return; return;
error: error:

View file

@ -405,7 +405,7 @@ unref_data (GstCollectData * data)
if (data->priv->destroy_notify) if (data->priv->destroy_notify)
data->priv->destroy_notify (data); data->priv->destroy_notify (data);
g_object_unref (data->pad); gst_object_unref (data->pad);
if (data->buffer) { if (data->buffer) {
gst_buffer_unref (data->buffer); gst_buffer_unref (data->buffer);
} }

View file

@ -121,7 +121,7 @@ main (gint argc, gchar * argv[])
GST_TIME_ARGS (end - start)); GST_TIME_ARGS (end - start));
start = gst_util_get_timestamp (); start = gst_util_get_timestamp ();
g_object_unref (pipeline); gst_object_unref (pipeline);
end = gst_util_get_timestamp (); end = gst_util_get_timestamp ();
g_print ("%" GST_TIME_FORMAT " - unreffing pipeline\n", g_print ("%" GST_TIME_FORMAT " - unreffing pipeline\n",
GST_TIME_ARGS (end - start)); GST_TIME_ARGS (end - start));

View file

@ -109,7 +109,7 @@ main (gint argc, gchar * argv[])
GST_TIME_ARGS (end - start)); GST_TIME_ARGS (end - start));
start = gst_util_get_timestamp (); start = gst_util_get_timestamp ();
g_object_unref (pipeline); gst_object_unref (pipeline);
end = gst_util_get_timestamp (); end = gst_util_get_timestamp ();
g_print ("%" GST_TIME_FORMAT " - unreffing pipeline\n", g_print ("%" GST_TIME_FORMAT " - unreffing pipeline\n",
GST_TIME_ARGS (end - start)); GST_TIME_ARGS (end - start));

View file

@ -680,8 +680,8 @@ GST_START_TEST (test_allow_not_linked)
gst_buffer_ref (buffer)) == GST_FLOW_NOT_LINKED); gst_buffer_ref (buffer)) == GST_FLOW_NOT_LINKED);
gst_element_release_request_pad (tee, src2); gst_element_release_request_pad (tee, src2);
g_object_unref (src1); gst_object_unref (src1);
g_object_unref (src2); gst_object_unref (src2);
fail_unless (gst_pad_push (srcpad, fail_unless (gst_pad_push (srcpad,
gst_buffer_ref (buffer)) == GST_FLOW_NOT_LINKED); gst_buffer_ref (buffer)) == GST_FLOW_NOT_LINKED);

View file

@ -345,8 +345,8 @@ GST_START_TEST (test_pad_templates)
test = g_object_new (gst_test_element_get_type (), NULL); test = g_object_new (gst_test_element_get_type (), NULL);
test2 = g_object_new (gst_test_element2_get_type (), NULL); test2 = g_object_new (gst_test_element2_get_type (), NULL);
g_object_unref (test); gst_object_unref (test);
g_object_unref (test2); gst_object_unref (test2);
} }
GST_END_TEST; GST_END_TEST;
@ -763,8 +763,8 @@ GST_START_TEST (test_request_pad_templates)
"sink")); "sink"));
gst_element_unlink (GST_ELEMENT (test), sink); gst_element_unlink (GST_ELEMENT (test), sink);
g_object_unref (test); gst_object_unref (test);
g_object_unref (sink); gst_object_unref (sink);
/* gst_parse_launch */ /* gst_parse_launch */
gst_plugin_register_static (GST_VERSION_MAJOR, gst_plugin_register_static (GST_VERSION_MAJOR,

View file

@ -72,7 +72,7 @@ GST_START_TEST (test_create)
factory = setup_factory (); factory = setup_factory ();
fail_if (factory == NULL); fail_if (factory == NULL);
g_object_unref (factory); gst_object_unref (factory);
} }
GST_END_TEST; GST_END_TEST;
@ -93,7 +93,7 @@ GST_START_TEST (test_can_sink_any_caps)
fail_if (!res); fail_if (!res);
gst_caps_unref (caps); gst_caps_unref (caps);
g_object_unref (factory); gst_object_unref (factory);
} }
GST_END_TEST; GST_END_TEST;
@ -114,7 +114,7 @@ GST_START_TEST (test_can_sink_all_caps)
fail_if (res); fail_if (res);
gst_caps_unref (caps); gst_caps_unref (caps);
g_object_unref (factory); gst_object_unref (factory);
} }
GST_END_TEST; GST_END_TEST;

View file

@ -403,7 +403,7 @@ GST_START_TEST (test_fake_object_name_threaded_unique)
g_free (name1); g_free (name1);
/* free stuff */ /* free stuff */
g_list_foreach (object_list, (GFunc) g_object_unref, NULL); g_list_foreach (object_list, (GFunc) gst_object_unref, NULL);
} }
GST_END_TEST; GST_END_TEST;

View file

@ -114,7 +114,7 @@ GST_START_TEST (test_param_spec_fraction)
fail_unless_equals_int (n, 15); fail_unless_equals_int (n, 15);
fail_unless_equals_int (d, 8); fail_unless_equals_int (d, 8);
g_object_unref (obj); gst_object_unref (obj);
} }
GST_END_TEST static Suite * GST_END_TEST static Suite *

View file

@ -81,11 +81,11 @@ GST_START_TEST (test_set_default)
gst_object_ref_sink (clock); gst_object_ref_sink (clock);
gst_system_clock_set_default (clock); gst_system_clock_set_default (clock);
g_assert_cmpint (GST_OBJECT_REFCOUNT (static_clock), ==, 1); g_assert_cmpint (GST_OBJECT_REFCOUNT (static_clock), ==, 1);
g_object_unref (static_clock); gst_object_unref (static_clock);
static_clock = gst_system_clock_obtain (); static_clock = gst_system_clock_obtain ();
fail_unless (static_clock == clock); fail_unless (static_clock == clock);
g_assert_cmpint (GST_OBJECT_REFCOUNT (clock), ==, 3); g_assert_cmpint (GST_OBJECT_REFCOUNT (clock), ==, 3);
g_object_unref (static_clock); gst_object_unref (static_clock);
/* Reset the default clock to the static one */ /* Reset the default clock to the static one */
gst_system_clock_set_default (NULL); gst_system_clock_set_default (NULL);
@ -93,8 +93,8 @@ GST_START_TEST (test_set_default)
fail_unless (static_clock != clock); fail_unless (static_clock != clock);
g_assert_cmpint (GST_OBJECT_REFCOUNT (clock), ==, 1); g_assert_cmpint (GST_OBJECT_REFCOUNT (clock), ==, 1);
g_assert_cmpint (GST_OBJECT_REFCOUNT (static_clock), ==, 2); g_assert_cmpint (GST_OBJECT_REFCOUNT (static_clock), ==, 2);
g_object_unref (clock); gst_object_unref (clock);
g_object_unref (static_clock); gst_object_unref (static_clock);
} }
GST_END_TEST; GST_END_TEST;
@ -221,7 +221,7 @@ GST_START_TEST (test_resolution)
prev_t = now_t; prev_t = now_t;
g_thread_yield (); g_thread_yield ();
} }
g_object_unref (clock); gst_object_unref (clock);
clock = NULL; clock = NULL;
} }
@ -270,7 +270,7 @@ single_shot_wait_thread_func (gpointer data)
g_mutex_unlock (&d->lock); g_mutex_unlock (&d->lock);
} }
g_object_unref (clock); gst_object_unref (clock);
return NULL; return NULL;
} }

View file

@ -118,7 +118,7 @@ GST_START_TEST (test_merge)
gst_tag_list_unref (list2); gst_tag_list_unref (list2);
gst_tag_list_unref (list1); gst_tag_list_unref (list1);
g_object_unref (enc); gst_object_unref (enc);
} }
GST_END_TEST GST_END_TEST
@ -319,7 +319,7 @@ GST_START_TEST (test_threads)
g_thread_join (threads[1]); g_thread_join (threads[1]);
g_thread_join (threads[2]); g_thread_join (threads[2]);
g_object_unref (G_OBJECT (setter)); gst_object_unref (G_OBJECT (setter));
} }
GST_END_TEST static Suite * GST_END_TEST static Suite *

View file

@ -258,7 +258,7 @@ GST_START_TEST (test_set)
fail_unless (toc == NULL); fail_unless (toc == NULL);
g_object_unref (enc); gst_object_unref (enc);
} }
GST_END_TEST static int spin_and_wait = 1; GST_END_TEST static int spin_and_wait = 1;
@ -369,7 +369,7 @@ GST_START_TEST (test_threads)
g_thread_join (threads[1]); g_thread_join (threads[1]);
g_thread_join (threads[2]); g_thread_join (threads[2]);
g_object_unref (G_OBJECT (setter)); gst_object_unref (setter);
} }
GST_END_TEST static Suite * GST_END_TEST static Suite *

View file

@ -90,7 +90,7 @@ GST_START_TEST (serialize_message_logging)
str = (gchar *) messages->data; str = (gchar *) messages->data;
fail_unless (str != NULL); fail_unless (str != NULL);
g_object_unref (tr); gst_object_unref (tr);
} }
GST_END_TEST; GST_END_TEST;
@ -147,7 +147,7 @@ GST_START_TEST (serialize_static_record)
g_free (str_val); g_free (str_val);
gst_structure_free (s); gst_structure_free (s);
g_object_unref (tr); gst_object_unref (tr);
} }
GST_END_TEST; GST_END_TEST;

View file

@ -129,8 +129,8 @@ GST_START_TEST (test_launch_lines)
fail_unless (efac != NULL); fail_unless (efac != NULL);
type = gst_element_factory_get_element_type (efac); type = gst_element_factory_get_element_type (efac);
fail_unless (type != 0); fail_unless (type != 0);
g_object_unref (efac); gst_object_unref (efac);
g_object_unref (efac); gst_object_unref (efac);
fail_unless (gst_element_register (NULL, "1__dentity", GST_RANK_NONE, type)); fail_unless (gst_element_register (NULL, "1__dentity", GST_RANK_NONE, type));
for (s = test_lines; *s != NULL; s++) { for (s = test_lines; *s != NULL; s++) {

View file

@ -67,7 +67,7 @@ main (gint argc, gchar * argv[])
bus = gst_element_get_bus (playbin); bus = gst_element_get_bus (playbin);
bus_watch_id = gst_bus_add_watch (bus, bus_call, loop); bus_watch_id = gst_bus_add_watch (bus, bus_call, loop);
g_object_unref (bus); gst_object_unref (bus);
/* start play back and listed to events */ /* start play back and listed to events */
gst_element_set_state (playbin, GST_STATE_PLAYING); gst_element_set_state (playbin, GST_STATE_PLAYING);
@ -75,7 +75,7 @@ main (gint argc, gchar * argv[])
/* cleanup */ /* cleanup */
gst_element_set_state (playbin, GST_STATE_NULL); gst_element_set_state (playbin, GST_STATE_NULL);
g_object_unref (playbin); gst_object_unref (playbin);
g_source_remove (bus_watch_id); g_source_remove (bus_watch_id);
g_main_loop_unref (loop); g_main_loop_unref (loop);

View file

@ -53,7 +53,7 @@ main (gint argc, gchar * argv[])
/* cleanup */ /* cleanup */
g_main_loop_unref (loop); g_main_loop_unref (loop);
g_object_unref (client_clock); gst_object_unref (client_clock);
return 0; return 0;
} }

View file

@ -189,7 +189,7 @@ main (gint argc, gchar * argv[])
bus = gst_element_get_bus (app->pipeline); bus = gst_element_get_bus (app->pipeline);
bus_watch_id = gst_bus_add_watch (bus, bus_call, loop); bus_watch_id = gst_bus_add_watch (bus, bus_call, loop);
g_object_unref (bus); gst_object_unref (bus);
for (stream_cnt = 0; stream_cnt < NUM_STREAM; stream_cnt++) { for (stream_cnt = 0; stream_cnt < NUM_STREAM; stream_cnt++) {
gst_bin_add_many (GST_BIN (app->pipeline), app->audiotestsrc[stream_cnt], gst_bin_add_many (GST_BIN (app->pipeline), app->audiotestsrc[stream_cnt],
@ -225,7 +225,7 @@ main (gint argc, gchar * argv[])
g_main_loop_run (loop); g_main_loop_run (loop);
gst_element_set_state (app->pipeline, GST_STATE_NULL); gst_element_set_state (app->pipeline, GST_STATE_NULL);
g_object_unref (app->pipeline); gst_object_unref (app->pipeline);
g_source_remove (bus_watch_id); g_source_remove (bus_watch_id);
g_main_loop_unref (loop); g_main_loop_unref (loop);