From ed1022fa81889bfa651d219056fc5173deb8332d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sebastian=20Dr=C3=B6ge?= Date: Mon, 20 Apr 2020 16:21:10 +0300 Subject: [PATCH] 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. --- docs/gst-hotdoc-plugins-scanner.c | 2 +- gst/gstbin.c | 4 ++-- gst/gstchildproxy.c | 16 ++++++++-------- gst/gstiterator.c | 2 +- gst/gstpad.c | 4 ++-- gst/gstpreset.c | 2 +- gst/gstregistrychunks.c | 5 +---- gst/gstsystemclock.c | 2 +- gst/parse/grammar.y.in | 4 ++-- libs/gst/base/gstcollectpads.c | 2 +- tests/benchmarks/complexity.c | 2 +- tests/benchmarks/mass-elements.c | 2 +- tests/check/elements/tee.c | 4 ++-- tests/check/gst/gstelement.c | 8 ++++---- tests/check/gst/gstelementfactory.c | 6 +++--- tests/check/gst/gstobject.c | 2 +- tests/check/gst/gstparamspecs.c | 2 +- tests/check/gst/gstsystemclock.c | 12 ++++++------ tests/check/gst/gsttagsetter.c | 4 ++-- tests/check/gst/gsttocsetter.c | 4 ++-- tests/check/gst/gsttracerrecord.c | 4 ++-- tests/check/pipelines/parse-launch.c | 4 ++-- tests/examples/helloworld/helloworld.c | 4 ++-- tests/examples/netclock/netclock-client.c | 2 +- tests/examples/streamiddemux/streamiddemux-stream.c | 4 ++-- 25 files changed, 52 insertions(+), 55 deletions(-) diff --git a/docs/gst-hotdoc-plugins-scanner.c b/docs/gst-hotdoc-plugins-scanner.c index 56adfd9..7a3f3d2 100644 --- a/docs/gst-hotdoc-plugins-scanner.c +++ b/docs/gst-hotdoc-plugins-scanner.c @@ -625,7 +625,7 @@ _add_element_pad_templates (GString * json, GstElement * element, g_string_append (json, ",\"object-type\": {"); tmpobj = g_object_new (pad_type, NULL); _add_object_details (json, tmpobj); - g_object_unref (tmpobj); + gst_object_unref (tmpobj); g_string_append (json, "}"); } g_string_append (json, "}"); diff --git a/gst/gstbin.c b/gst/gstbin.c index 178ac22..8c6323a 100644 --- a/gst/gstbin.c +++ b/gst/gstbin.c @@ -1120,7 +1120,7 @@ gst_bin_do_deep_add_remove (GstBin * bin, gint sig_id, const gchar * sig_name, do { ires = gst_iterator_foreach (it, bin_deep_iterator_foreach, &elements); 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); } 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); g_signal_emit (bin, sig_id, 0, parent, e); gst_object_unref (parent); - g_object_unref (e); + gst_object_unref (e); } } } diff --git a/gst/gstchildproxy.c b/gst/gstchildproxy.c index d0214c0..9ac97d3 100644 --- a/gst/gstchildproxy.c +++ b/gst/gstchildproxy.c @@ -92,7 +92,7 @@ gst_child_proxy_default_get_child_by_name (GstChildProxy * parent, break; } next: - g_object_unref (object); + gst_object_unref (object); } return result; } @@ -228,7 +228,7 @@ gst_child_proxy_lookup (GstChildProxy * object, const gchar * name, GST_INFO ("no such object %s", current[0]); break; } - g_object_unref (obj); + gst_object_unref (obj); obj = next; current++; } @@ -249,7 +249,7 @@ gst_child_proxy_lookup (GstChildProxy * object, const gchar * name, res = TRUE; } } - g_object_unref (obj); + gst_object_unref (obj); g_strfreev (names); return res; } @@ -278,7 +278,7 @@ gst_child_proxy_get_property (GstChildProxy * object, const gchar * name, goto not_found; g_object_get_property (target, pspec->name, value); - g_object_unref (target); + gst_object_unref (target); return; @@ -319,7 +319,7 @@ gst_child_proxy_get_valist (GstChildProxy * object, g_value_init (&value, pspec->value_type); g_object_get_property (target, pspec->name, &value); - g_object_unref (target); + gst_object_unref (target); G_VALUE_LCOPY (&value, var_args, 0, &error); if (error) @@ -388,7 +388,7 @@ gst_child_proxy_set_property (GstChildProxy * object, const gchar * name, goto not_found; g_object_set_property (target, pspec->name, value); - g_object_unref (target); + gst_object_unref (target); return; not_found: @@ -433,7 +433,7 @@ gst_child_proxy_set_valist (GstChildProxy * object, goto cant_copy; g_object_set_property (target, pspec->name, &value); - g_object_unref (target); + gst_object_unref (target); g_value_unset (&value); name = va_arg (var_args, gchar *); @@ -451,7 +451,7 @@ cant_copy: g_warning ("error copying value %s in object %s: %s", pspec->name, (GST_IS_OBJECT (object) ? GST_OBJECT_NAME (object) : ""), error); g_value_unset (&value); - g_object_unref (target); + gst_object_unref (target); g_free (error); return; } diff --git a/gst/gstiterator.c b/gst/gstiterator.c index e7e5875..2689435 100644 --- a/gst/gstiterator.c +++ b/gst/gstiterator.c @@ -212,7 +212,7 @@ static void gst_list_iterator_free (GstListIterator * it) { if (it->owner) - g_object_unref (it->owner); + gst_object_unref (it->owner); } /** diff --git a/gst/gstpad.c b/gst/gstpad.c index 0d43108..7005bd4 100644 --- a/gst/gstpad.c +++ b/gst/gstpad.c @@ -2886,7 +2886,7 @@ gst_pad_get_single_internal_link (GstPad * pad) ret = g_value_dup_object (&item); } else { /* More than one internal link found - don't bother reffing */ - g_clear_object (&ret); + gst_clear_object (&ret); GST_DEBUG_OBJECT (pad, "Requested single internally linked pad, multiple found"); done = TRUE; @@ -2895,7 +2895,7 @@ gst_pad_get_single_internal_link (GstPad * pad) break; } case GST_ITERATOR_RESYNC: - g_clear_object (&ret); + gst_clear_object (&ret); gst_iterator_resync (iter); break; case GST_ITERATOR_ERROR: diff --git a/gst/gstpreset.c b/gst/gstpreset.c index 7584c5b..9f1b1b1 100644 --- a/gst/gstpreset.c +++ b/gst/gstpreset.c @@ -622,7 +622,7 @@ gst_preset_default_get_property_names (GstPreset * preset) g_free (props); } - g_object_unref (child); + gst_object_unref (child); } } if (!result) { diff --git a/gst/gstregistrychunks.c b/gst/gstregistrychunks.c index 6eb7c64..e8fb3ac2 100644 --- a/gst/gstregistrychunks.c +++ b/gst/gstregistrychunks.c @@ -747,10 +747,7 @@ gst_registry_chunks_load_feature (GstRegistry * registry, gchar ** in, fail: GST_INFO ("Reading plugin feature failed"); if (feature) { - if (GST_IS_OBJECT (feature)) - gst_object_unref (feature); - else - g_object_unref (feature); + gst_object_unref (feature); } return FALSE; } diff --git a/gst/gstsystemclock.c b/gst/gstsystemclock.c index 9e2491d..550988b 100644 --- a/gst/gstsystemclock.c +++ b/gst/gstsystemclock.c @@ -578,7 +578,7 @@ gst_system_clock_set_default (GstClock * new_clock) clock = _the_system_clock; if (clock != NULL) - g_object_unref (clock); + gst_object_unref (clock); if (new_clock == NULL) { GST_CAT_DEBUG (GST_CAT_CLOCK, "resetting default system clock"); diff --git a/gst/parse/grammar.y.in b/gst/parse/grammar.y.in index 76b66f9..2ef703d 100644 --- a/gst/parse/grammar.y.in +++ b/gst/parse/grammar.y.in @@ -358,7 +358,7 @@ out: if (G_IS_VALUE (&v)) g_value_unset (&v); if (target) - g_object_unref (target); + gst_object_unref (target); return; error: @@ -446,7 +446,7 @@ out: if (G_IS_VALUE (&v)) g_value_unset (&v); if (target) - g_object_unref (target); + gst_object_unref (target); return; error: diff --git a/libs/gst/base/gstcollectpads.c b/libs/gst/base/gstcollectpads.c index 9fb4616..b6f9215 100644 --- a/libs/gst/base/gstcollectpads.c +++ b/libs/gst/base/gstcollectpads.c @@ -405,7 +405,7 @@ unref_data (GstCollectData * data) if (data->priv->destroy_notify) data->priv->destroy_notify (data); - g_object_unref (data->pad); + gst_object_unref (data->pad); if (data->buffer) { gst_buffer_unref (data->buffer); } diff --git a/tests/benchmarks/complexity.c b/tests/benchmarks/complexity.c index 2cf1dc8..0ceb64c 100644 --- a/tests/benchmarks/complexity.c +++ b/tests/benchmarks/complexity.c @@ -121,7 +121,7 @@ main (gint argc, gchar * argv[]) GST_TIME_ARGS (end - start)); start = gst_util_get_timestamp (); - g_object_unref (pipeline); + gst_object_unref (pipeline); end = gst_util_get_timestamp (); g_print ("%" GST_TIME_FORMAT " - unreffing pipeline\n", GST_TIME_ARGS (end - start)); diff --git a/tests/benchmarks/mass-elements.c b/tests/benchmarks/mass-elements.c index cfe6c85..add8f41 100644 --- a/tests/benchmarks/mass-elements.c +++ b/tests/benchmarks/mass-elements.c @@ -109,7 +109,7 @@ main (gint argc, gchar * argv[]) GST_TIME_ARGS (end - start)); start = gst_util_get_timestamp (); - g_object_unref (pipeline); + gst_object_unref (pipeline); end = gst_util_get_timestamp (); g_print ("%" GST_TIME_FORMAT " - unreffing pipeline\n", GST_TIME_ARGS (end - start)); diff --git a/tests/check/elements/tee.c b/tests/check/elements/tee.c index 7e0f4c0..a76779c 100644 --- a/tests/check/elements/tee.c +++ b/tests/check/elements/tee.c @@ -680,8 +680,8 @@ GST_START_TEST (test_allow_not_linked) gst_buffer_ref (buffer)) == GST_FLOW_NOT_LINKED); gst_element_release_request_pad (tee, src2); - g_object_unref (src1); - g_object_unref (src2); + gst_object_unref (src1); + gst_object_unref (src2); fail_unless (gst_pad_push (srcpad, gst_buffer_ref (buffer)) == GST_FLOW_NOT_LINKED); diff --git a/tests/check/gst/gstelement.c b/tests/check/gst/gstelement.c index fa63ee6..62d469c 100644 --- a/tests/check/gst/gstelement.c +++ b/tests/check/gst/gstelement.c @@ -345,8 +345,8 @@ GST_START_TEST (test_pad_templates) test = g_object_new (gst_test_element_get_type (), NULL); test2 = g_object_new (gst_test_element2_get_type (), NULL); - g_object_unref (test); - g_object_unref (test2); + gst_object_unref (test); + gst_object_unref (test2); } GST_END_TEST; @@ -763,8 +763,8 @@ GST_START_TEST (test_request_pad_templates) "sink")); gst_element_unlink (GST_ELEMENT (test), sink); - g_object_unref (test); - g_object_unref (sink); + gst_object_unref (test); + gst_object_unref (sink); /* gst_parse_launch */ gst_plugin_register_static (GST_VERSION_MAJOR, diff --git a/tests/check/gst/gstelementfactory.c b/tests/check/gst/gstelementfactory.c index 294ebf1..7a7cca9 100644 --- a/tests/check/gst/gstelementfactory.c +++ b/tests/check/gst/gstelementfactory.c @@ -72,7 +72,7 @@ GST_START_TEST (test_create) factory = setup_factory (); fail_if (factory == NULL); - g_object_unref (factory); + gst_object_unref (factory); } GST_END_TEST; @@ -93,7 +93,7 @@ GST_START_TEST (test_can_sink_any_caps) fail_if (!res); gst_caps_unref (caps); - g_object_unref (factory); + gst_object_unref (factory); } GST_END_TEST; @@ -114,7 +114,7 @@ GST_START_TEST (test_can_sink_all_caps) fail_if (res); gst_caps_unref (caps); - g_object_unref (factory); + gst_object_unref (factory); } GST_END_TEST; diff --git a/tests/check/gst/gstobject.c b/tests/check/gst/gstobject.c index 4acb0d3..f5faabe 100644 --- a/tests/check/gst/gstobject.c +++ b/tests/check/gst/gstobject.c @@ -403,7 +403,7 @@ GST_START_TEST (test_fake_object_name_threaded_unique) g_free (name1); /* 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; diff --git a/tests/check/gst/gstparamspecs.c b/tests/check/gst/gstparamspecs.c index 696c62b..fc82985 100644 --- a/tests/check/gst/gstparamspecs.c +++ b/tests/check/gst/gstparamspecs.c @@ -114,7 +114,7 @@ GST_START_TEST (test_param_spec_fraction) fail_unless_equals_int (n, 15); fail_unless_equals_int (d, 8); - g_object_unref (obj); + gst_object_unref (obj); } GST_END_TEST static Suite * diff --git a/tests/check/gst/gstsystemclock.c b/tests/check/gst/gstsystemclock.c index b02b046..c1ae6bd 100644 --- a/tests/check/gst/gstsystemclock.c +++ b/tests/check/gst/gstsystemclock.c @@ -81,11 +81,11 @@ GST_START_TEST (test_set_default) gst_object_ref_sink (clock); gst_system_clock_set_default (clock); 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 (); fail_unless (static_clock == clock); 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 */ gst_system_clock_set_default (NULL); @@ -93,8 +93,8 @@ GST_START_TEST (test_set_default) fail_unless (static_clock != clock); g_assert_cmpint (GST_OBJECT_REFCOUNT (clock), ==, 1); g_assert_cmpint (GST_OBJECT_REFCOUNT (static_clock), ==, 2); - g_object_unref (clock); - g_object_unref (static_clock); + gst_object_unref (clock); + gst_object_unref (static_clock); } GST_END_TEST; @@ -221,7 +221,7 @@ GST_START_TEST (test_resolution) prev_t = now_t; g_thread_yield (); } - g_object_unref (clock); + gst_object_unref (clock); clock = NULL; } @@ -270,7 +270,7 @@ single_shot_wait_thread_func (gpointer data) g_mutex_unlock (&d->lock); } - g_object_unref (clock); + gst_object_unref (clock); return NULL; } diff --git a/tests/check/gst/gsttagsetter.c b/tests/check/gst/gsttagsetter.c index 10f68fe..8413d4a 100644 --- a/tests/check/gst/gsttagsetter.c +++ b/tests/check/gst/gsttagsetter.c @@ -118,7 +118,7 @@ GST_START_TEST (test_merge) gst_tag_list_unref (list2); gst_tag_list_unref (list1); - g_object_unref (enc); + gst_object_unref (enc); } GST_END_TEST @@ -319,7 +319,7 @@ GST_START_TEST (test_threads) g_thread_join (threads[1]); g_thread_join (threads[2]); - g_object_unref (G_OBJECT (setter)); + gst_object_unref (G_OBJECT (setter)); } GST_END_TEST static Suite * diff --git a/tests/check/gst/gsttocsetter.c b/tests/check/gst/gsttocsetter.c index f15e198..877dfbd 100644 --- a/tests/check/gst/gsttocsetter.c +++ b/tests/check/gst/gsttocsetter.c @@ -258,7 +258,7 @@ GST_START_TEST (test_set) fail_unless (toc == NULL); - g_object_unref (enc); + gst_object_unref (enc); } 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[2]); - g_object_unref (G_OBJECT (setter)); + gst_object_unref (setter); } GST_END_TEST static Suite * diff --git a/tests/check/gst/gsttracerrecord.c b/tests/check/gst/gsttracerrecord.c index 6dd629a..5627152 100644 --- a/tests/check/gst/gsttracerrecord.c +++ b/tests/check/gst/gsttracerrecord.c @@ -90,7 +90,7 @@ GST_START_TEST (serialize_message_logging) str = (gchar *) messages->data; fail_unless (str != NULL); - g_object_unref (tr); + gst_object_unref (tr); } GST_END_TEST; @@ -147,7 +147,7 @@ GST_START_TEST (serialize_static_record) g_free (str_val); gst_structure_free (s); - g_object_unref (tr); + gst_object_unref (tr); } GST_END_TEST; diff --git a/tests/check/pipelines/parse-launch.c b/tests/check/pipelines/parse-launch.c index b732da0..58c2e53 100644 --- a/tests/check/pipelines/parse-launch.c +++ b/tests/check/pipelines/parse-launch.c @@ -129,8 +129,8 @@ GST_START_TEST (test_launch_lines) fail_unless (efac != NULL); type = gst_element_factory_get_element_type (efac); fail_unless (type != 0); - g_object_unref (efac); - g_object_unref (efac); + gst_object_unref (efac); + gst_object_unref (efac); fail_unless (gst_element_register (NULL, "1__dentity", GST_RANK_NONE, type)); for (s = test_lines; *s != NULL; s++) { diff --git a/tests/examples/helloworld/helloworld.c b/tests/examples/helloworld/helloworld.c index ca6e07c..a95d785 100644 --- a/tests/examples/helloworld/helloworld.c +++ b/tests/examples/helloworld/helloworld.c @@ -67,7 +67,7 @@ main (gint argc, gchar * argv[]) bus = gst_element_get_bus (playbin); 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 */ gst_element_set_state (playbin, GST_STATE_PLAYING); @@ -75,7 +75,7 @@ main (gint argc, gchar * argv[]) /* cleanup */ gst_element_set_state (playbin, GST_STATE_NULL); - g_object_unref (playbin); + gst_object_unref (playbin); g_source_remove (bus_watch_id); g_main_loop_unref (loop); diff --git a/tests/examples/netclock/netclock-client.c b/tests/examples/netclock/netclock-client.c index 2082297..cd43d89 100644 --- a/tests/examples/netclock/netclock-client.c +++ b/tests/examples/netclock/netclock-client.c @@ -53,7 +53,7 @@ main (gint argc, gchar * argv[]) /* cleanup */ g_main_loop_unref (loop); - g_object_unref (client_clock); + gst_object_unref (client_clock); return 0; } diff --git a/tests/examples/streamiddemux/streamiddemux-stream.c b/tests/examples/streamiddemux/streamiddemux-stream.c index 8180221..8302bc1 100644 --- a/tests/examples/streamiddemux/streamiddemux-stream.c +++ b/tests/examples/streamiddemux/streamiddemux-stream.c @@ -189,7 +189,7 @@ main (gint argc, gchar * argv[]) bus = gst_element_get_bus (app->pipeline); 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++) { 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); 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_main_loop_unref (loop); -- 2.7.4