diff --git a/gst/adder/gstadder.c b/gst/adder/gstadder.c index 58fa8382ee..20ab8cf843 100644 --- a/gst/adder/gstadder.c +++ b/gst/adder/gstadder.c @@ -344,6 +344,7 @@ gst_adder_query_duration (GstAdder * adder, GstQuery * query) GstFormat format; GstIterator *it; gboolean done; + GValue item = { 0, }; /* parse format */ gst_query_parse_duration (query, &format, NULL); @@ -356,8 +357,6 @@ gst_adder_query_duration (GstAdder * adder, GstQuery * query) while (!done) { GstIteratorResult ires; - gpointer item; - ires = gst_iterator_next (it, &item); switch (ires) { case GST_ITERATOR_DONE: @@ -365,8 +364,7 @@ gst_adder_query_duration (GstAdder * adder, GstQuery * query) break; case GST_ITERATOR_OK: { - GstPad *pad = GST_PAD_CAST (item); - + GstPad *pad = g_value_get_object (&item); gint64 duration; /* ask sink peer for duration */ @@ -382,7 +380,7 @@ gst_adder_query_duration (GstAdder * adder, GstQuery * query) else if (duration > max) max = duration; } - gst_object_unref (pad); + g_value_reset (&item); break; } case GST_ITERATOR_RESYNC: @@ -396,6 +394,7 @@ gst_adder_query_duration (GstAdder * adder, GstQuery * query) break; } } + g_value_unset (&item); gst_iterator_free (it); if (res) { @@ -416,6 +415,7 @@ gst_adder_query_latency (GstAdder * adder, GstQuery * query) gboolean res; GstIterator *it; gboolean done; + GValue item = { 0, }; res = TRUE; done = FALSE; @@ -429,8 +429,6 @@ gst_adder_query_latency (GstAdder * adder, GstQuery * query) while (!done) { GstIteratorResult ires; - gpointer item; - ires = gst_iterator_next (it, &item); switch (ires) { case GST_ITERATOR_DONE: @@ -438,7 +436,7 @@ gst_adder_query_latency (GstAdder * adder, GstQuery * query) break; case GST_ITERATOR_OK: { - GstPad *pad = GST_PAD_CAST (item); + GstPad *pad = g_value_get_object (&item); GstQuery *peerquery; GstClockTime min_cur, max_cur; gboolean live_cur; @@ -464,7 +462,7 @@ gst_adder_query_latency (GstAdder * adder, GstQuery * query) } gst_query_unref (peerquery); - gst_object_unref (pad); + g_value_reset (&item); break; } case GST_ITERATOR_RESYNC: @@ -480,6 +478,7 @@ gst_adder_query_latency (GstAdder * adder, GstQuery * query) break; } } + g_value_unset (&item); gst_iterator_free (it); if (res) { @@ -545,8 +544,9 @@ typedef struct } EventData; static gboolean -forward_event_func (GstPad * pad, GValue * ret, EventData * data) +forward_event_func (const GValue * val, GValue * ret, EventData * data) { + GstPad *pad = g_value_get_object (val); GstEvent *event = data->event; gst_event_ref (event); @@ -563,7 +563,6 @@ forward_event_func (GstPad * pad, GValue * ret, EventData * data) GST_LOG_OBJECT (pad, "Sent event %p (%s).", event, GST_EVENT_TYPE_NAME (event)); } - gst_object_unref (pad); /* continue on other pads, even if one failed */ return TRUE; @@ -594,7 +593,8 @@ forward_event (GstAdder * adder, GstEvent * event, gboolean flush) g_value_set_boolean (&vret, FALSE); it = gst_element_iterate_sink_pads (GST_ELEMENT_CAST (adder)); while (TRUE) { - ires = gst_iterator_fold (it, (GstIteratorFoldFunction) forward_event_func, + ires = + gst_iterator_fold (it, (GstIteratorFoldFunction) forward_event_func, &vret, &data); switch (ires) { case GST_ITERATOR_RESYNC: diff --git a/gst/encoding/gstencodebin.c b/gst/encoding/gstencodebin.c index 7b0f1b4822..f45febd34b 100644 --- a/gst/encoding/gstencodebin.c +++ b/gst/encoding/gstencodebin.c @@ -1511,8 +1511,9 @@ stream_error: } static void -release_pads (GstPad * pad, GstElement * elt) +release_pads (const GValue * item, GstElement * elt) { + GstPad *pad = g_value_get_object (item); GstPad *peer = NULL; GST_DEBUG_OBJECT (elt, "Releasing pad %s:%s", GST_DEBUG_PAD_NAME (pad)); @@ -1528,9 +1529,6 @@ release_pads (GstPad * pad, GstElement * elt) /* Release it from the object */ gst_element_release_request_pad (elt, pad); - - /* And remove the reference added by the iterator */ - gst_object_unref (pad); } static void inline @@ -1604,7 +1602,9 @@ stream_group_free (GstEncodeBin * ebin, StreamGroup * sgroup) GstIteratorResult itret = GST_ITERATOR_OK; while (itret == GST_ITERATOR_OK || itret == GST_ITERATOR_RESYNC) { - itret = gst_iterator_foreach (it, (GFunc) release_pads, sgroup->combiner); + itret = + gst_iterator_foreach (it, (GstIteratorForeachFunction) release_pads, + sgroup->combiner); gst_iterator_resync (it); } gst_iterator_free (it); @@ -1616,7 +1616,9 @@ stream_group_free (GstEncodeBin * ebin, StreamGroup * sgroup) GstIterator *it = gst_element_iterate_src_pads (sgroup->splitter); GstIteratorResult itret = GST_ITERATOR_OK; while (itret == GST_ITERATOR_OK || itret == GST_ITERATOR_RESYNC) { - itret = gst_iterator_foreach (it, (GFunc) release_pads, sgroup->splitter); + itret = + gst_iterator_foreach (it, (GstIteratorForeachFunction) release_pads, + sgroup->splitter); gst_iterator_resync (it); } gst_iterator_free (it); diff --git a/gst/playback/gstdecodebin.c b/gst/playback/gstdecodebin.c index 854a28dca1..eaa5ec77ab 100644 --- a/gst/playback/gstdecodebin.c +++ b/gst/playback/gstdecodebin.c @@ -1236,6 +1236,7 @@ static GstPad * get_our_ghost_pad (GstDecodeBin * decode_bin, GstPad * pad) { GstIterator *pad_it = NULL; + GValue item = { 0, }; GstPad *db_pad = NULL; gboolean done = FALSE; @@ -1248,8 +1249,9 @@ get_our_ghost_pad (GstDecodeBin * decode_bin, GstPad * pad) pad_it = gst_element_iterate_src_pads (GST_ELEMENT (decode_bin)); while (!done) { db_pad = NULL; - switch (gst_iterator_next (pad_it, (gpointer) & db_pad)) { - case GST_ITERATOR_OK: + switch (gst_iterator_next (pad_it, &item)) { + case GST_ITERATOR_OK:{ + db_pad = g_value_get_object (&item); GST_DEBUG_OBJECT (decode_bin, "looking at pad %s:%s", GST_DEBUG_PAD_NAME (db_pad)); if (GST_IS_GHOST_PAD (db_pad)) { @@ -1268,8 +1270,9 @@ get_our_ghost_pad (GstDecodeBin * decode_bin, GstPad * pad) } } /* Not the right one */ - gst_object_unref (db_pad); + g_value_reset (&item); break; + } case GST_ITERATOR_RESYNC: gst_iterator_resync (pad_it); break; @@ -1281,6 +1284,7 @@ get_our_ghost_pad (GstDecodeBin * decode_bin, GstPad * pad) break; } } + g_value_unset (&item); gst_iterator_free (pad_it); return db_pad; @@ -1295,7 +1299,7 @@ remove_element_chain (GstDecodeBin * decode_bin, GstPad * pad) { GstIterator *iter; gboolean done = FALSE; - gpointer item; + GValue item = { 0, }; GstElement *elem = GST_ELEMENT (GST_OBJECT_PARENT (pad)); while (GST_OBJECT_PARENT (elem) && @@ -1322,7 +1326,7 @@ remove_element_chain (GstDecodeBin * decode_bin, GstPad * pad) GstPad *ghostpad; GstPad *peer; - pad = GST_PAD (item); + pad = g_value_get_object (&item); GST_DEBUG_OBJECT (decode_bin, "inspecting internal pad %s:%s", GST_DEBUG_PAD_NAME (pad)); @@ -1336,6 +1340,7 @@ remove_element_chain (GstDecodeBin * decode_bin, GstPad * pad) gst_element_remove_pad (GST_ELEMENT (decode_bin), ghostpad); gst_object_unref (ghostpad); + g_value_reset (&item); continue; } else { GST_DEBUG_OBJECT (decode_bin, "not one of our ghostpads"); @@ -1368,7 +1373,7 @@ remove_element_chain (GstDecodeBin * decode_bin, GstPad * pad) } gst_object_unref (peer); } - gst_object_unref (item); + g_value_reset (&item); } break; case GST_ITERATOR_RESYNC: @@ -1384,7 +1389,7 @@ remove_element_chain (GstDecodeBin * decode_bin, GstPad * pad) } } GST_DEBUG_OBJECT (decode_bin, "removing %s", GST_ELEMENT_NAME (elem)); - + g_value_unset (&item); gst_iterator_free (iter); no_iter: @@ -1860,16 +1865,17 @@ disconnect_unlinked_signals (GstDecodeBin * decode_bin, GstElement * element) { GstIterator *pad_it = NULL; gboolean done = FALSE; + GstPad *pad = NULL; + GValue item = { 0, }; pad_it = gst_element_iterate_src_pads (element); while (!done) { - GstPad *pad = NULL; - - switch (gst_iterator_next (pad_it, (gpointer) & pad)) { + switch (gst_iterator_next (pad_it, &item)) { case GST_ITERATOR_OK: + pad = g_value_get_object (&item); g_signal_handlers_disconnect_by_func (pad, (gpointer) unlinked, decode_bin); - gst_object_unref (pad); + g_value_reset (&item); break; case GST_ITERATOR_RESYNC: gst_iterator_resync (pad_it); @@ -1879,6 +1885,7 @@ disconnect_unlinked_signals (GstDecodeBin * decode_bin, GstElement * element) break; } } + g_value_unset (&item); gst_iterator_free (pad_it); } @@ -1889,6 +1896,9 @@ cleanup_decodebin (GstDecodeBin * decode_bin) GstIterator *elem_it = NULL, *gpad_it = NULL; GstPad *typefind_pad = NULL; gboolean done = FALSE; + GstElement *element = NULL; + GstPad *pad = NULL; + GValue item = { 0, }; g_return_if_fail (GST_IS_DECODE_BIN (decode_bin)); @@ -1902,17 +1912,16 @@ cleanup_decodebin (GstDecodeBin * decode_bin) elem_it = gst_bin_iterate_elements (GST_BIN (decode_bin)); while (!done) { - GstElement *element = NULL; - - switch (gst_iterator_next (elem_it, (gpointer) & element)) { + switch (gst_iterator_next (elem_it, &item)) { case GST_ITERATOR_OK: + element = g_value_get_object (&item); if (element != decode_bin->typefind && element != decode_bin->fakesink) { GST_DEBUG_OBJECT (element, "removing autoplugged element"); disconnect_unlinked_signals (decode_bin, element); gst_element_set_state (element, GST_STATE_NULL); gst_bin_remove (GST_BIN (decode_bin), element); } - gst_object_unref (element); + g_value_reset (&item); break; case GST_ITERATOR_RESYNC: gst_iterator_resync (elem_it); @@ -1925,22 +1934,22 @@ cleanup_decodebin (GstDecodeBin * decode_bin) break; } } + g_value_unset (&item); gst_iterator_free (elem_it); done = FALSE; gpad_it = gst_element_iterate_pads (GST_ELEMENT (decode_bin)); while (!done) { - GstPad *pad = NULL; - - switch (gst_iterator_next (gpad_it, (gpointer) & pad)) { + switch (gst_iterator_next (gpad_it, &item)) { case GST_ITERATOR_OK: + pad = g_value_get_object (&item); GST_DEBUG_OBJECT (pad, "inspecting pad %s:%s", GST_DEBUG_PAD_NAME (pad)); if (GST_IS_GHOST_PAD (pad) && GST_PAD_IS_SRC (pad)) { GST_DEBUG_OBJECT (pad, "removing ghost pad"); gst_element_remove_pad (GST_ELEMENT (decode_bin), pad); } - gst_object_unref (pad); + g_value_reset (&item); break; case GST_ITERATOR_RESYNC: gst_iterator_resync (gpad_it); @@ -1953,6 +1962,7 @@ cleanup_decodebin (GstDecodeBin * decode_bin) break; } } + g_value_unset (&item); gst_iterator_free (gpad_it); if (GST_IS_PAD (typefind_pad)) { diff --git a/gst/playback/gstdecodebin2.c b/gst/playback/gstdecodebin2.c index 346b892873..2921f6cce0 100644 --- a/gst/playback/gstdecodebin2.c +++ b/gst/playback/gstdecodebin2.c @@ -2740,6 +2740,7 @@ gst_decode_group_control_demuxer_pad (GstDecodeGroup * group, GstPad * pad) GstDecodeBin *dbin; GstPad *srcpad, *sinkpad; GstIterator *it = NULL; + GValue item = { 0, }; dbin = group->dbin; @@ -2762,19 +2763,19 @@ gst_decode_group_control_demuxer_pad (GstDecodeGroup * group, GstPad * pad) it = gst_pad_iterate_internal_links (sinkpad); - if (!it || (gst_iterator_next (it, (gpointer) & srcpad)) != GST_ITERATOR_OK - || srcpad == NULL) { + if (!it || (gst_iterator_next (it, &item)) != GST_ITERATOR_OK + || ((srcpad = g_value_dup_object (&item)) == NULL)) { GST_ERROR_OBJECT (dbin, "Couldn't get srcpad from multiqueue for sinkpad %" GST_PTR_FORMAT, sinkpad); goto error; } - CHAIN_MUTEX_LOCK (group->parent); group->reqpads = g_list_prepend (group->reqpads, gst_object_ref (sinkpad)); CHAIN_MUTEX_UNLOCK (group->parent); beach: + g_value_unset (&item); if (it) gst_iterator_free (it); gst_object_unref (sinkpad); @@ -3065,11 +3066,13 @@ _gst_element_get_linked_caps (GstElement * src, GstElement * sink) GstPad *pad, *peer; gboolean done = FALSE; GstCaps *caps = NULL; + GValue item = { 0, }; it = gst_element_iterate_src_pads (src); while (!done) { - switch (gst_iterator_next (it, (gpointer) & pad)) { + switch (gst_iterator_next (it, &item)) { case GST_ITERATOR_OK: + pad = g_value_get_object (&item); peer = gst_pad_get_peer (pad); if (peer) { parent = gst_pad_get_parent_element (peer); @@ -3082,7 +3085,7 @@ _gst_element_get_linked_caps (GstElement * src, GstElement * sink) gst_object_unref (parent); gst_object_unref (peer); } - gst_object_unref (pad); + g_value_reset (&item); break; case GST_ITERATOR_RESYNC: gst_iterator_resync (it); @@ -3093,7 +3096,7 @@ _gst_element_get_linked_caps (GstElement * src, GstElement * sink) break; } } - + g_value_unset (&item); gst_iterator_free (it); return caps; @@ -3592,13 +3595,13 @@ find_sink_pad (GstElement * element) { GstIterator *it; GstPad *pad = NULL; - gpointer point; + GValue item = { 0, }; it = gst_element_iterate_sink_pads (element); - if ((gst_iterator_next (it, &point)) == GST_ITERATOR_OK) - pad = (GstPad *) point; - + if ((gst_iterator_next (it, &item)) == GST_ITERATOR_OK) + pad = g_value_dup_object (&item); + g_value_unset (&item); gst_iterator_free (it); return pad; diff --git a/gst/playback/gstplaysink.c b/gst/playback/gstplaysink.c index 832e33a8ee..fe067b6dec 100644 --- a/gst/playback/gstplaysink.c +++ b/gst/playback/gstplaysink.c @@ -952,15 +952,14 @@ typedef struct } FindPropertyHelper; static gint -find_property (GstElement * element, FindPropertyHelper * helper) +find_property (const GValue * item, FindPropertyHelper * helper) { + GstElement *element = g_value_get_object (item); if (helper->need_sink && !element_is_sink (element)) { - gst_object_unref (element); return 1; } if (!element_has_property (element, helper->prop_name, helper->prop_type)) { - gst_object_unref (element); return 1; } @@ -983,15 +982,18 @@ gst_play_sink_find_property_sinks (GstPlaySink * playsink, GstElement * obj, if (element_has_property (obj, name, expected_type)) { result = obj; } else if (GST_IS_BIN (obj)) { + gboolean found; + GValue item = { 0, }; FindPropertyHelper helper = { name, expected_type, TRUE }; it = gst_bin_iterate_recurse (GST_BIN_CAST (obj)); - result = gst_iterator_find_custom (it, - (GCompareFunc) find_property, &helper); + found = gst_iterator_find_custom (it, + (GCompareFunc) find_property, &item, &helper); gst_iterator_free (it); + if (found) + result = g_value_get_object (&item); /* we don't need the extra ref */ - if (result) - gst_object_unref (result); + g_value_unset (&item); } return result; } @@ -1005,12 +1007,17 @@ gst_play_sink_find_property (GstPlaySink * playsink, GstElement * obj, GstIterator *it; if (GST_IS_BIN (obj)) { + gboolean found; + GValue item = { 0, }; FindPropertyHelper helper = { name, expected_type, FALSE }; it = gst_bin_iterate_recurse (GST_BIN_CAST (obj)); - result = gst_iterator_find_custom (it, - (GCompareFunc) find_property, &helper); + found = gst_iterator_find_custom (it, + (GCompareFunc) find_property, &item, &helper); gst_iterator_free (it); + if (found) + result = g_value_dup_object (&item); + g_value_unset (&item); } else { if (element_has_property (obj, name, expected_type)) { result = obj; @@ -2241,6 +2248,7 @@ gst_play_sink_reconfigure (GstPlaySink * playsink) goto no_chain; if (!playsink->video_sinkpad_stream_synchronizer) { + GValue item = { 0, }; GstIterator *it; playsink->video_sinkpad_stream_synchronizer = @@ -2249,8 +2257,9 @@ gst_play_sink_reconfigure (GstPlaySink * playsink) it = gst_pad_iterate_internal_links (playsink->video_sinkpad_stream_synchronizer); g_assert (it); - gst_iterator_next (it, - (gpointer *) & playsink->video_srcpad_stream_synchronizer); + gst_iterator_next (it, &item); + playsink->video_srcpad_stream_synchronizer = g_value_dup_object (&item); + g_value_unset (&item); g_assert (playsink->video_srcpad_stream_synchronizer); gst_iterator_free (it); } @@ -2397,6 +2406,7 @@ gst_play_sink_reconfigure (GstPlaySink * playsink) } if (!playsink->audio_sinkpad_stream_synchronizer) { + GValue item = { 0, }; GstIterator *it; playsink->audio_sinkpad_stream_synchronizer = @@ -2405,8 +2415,9 @@ gst_play_sink_reconfigure (GstPlaySink * playsink) it = gst_pad_iterate_internal_links (playsink->audio_sinkpad_stream_synchronizer); g_assert (it); - gst_iterator_next (it, - (gpointer *) & playsink->audio_srcpad_stream_synchronizer); + gst_iterator_next (it, &item); + playsink->audio_srcpad_stream_synchronizer = g_value_dup_object (&item); + g_value_unset (&item); g_assert (playsink->audio_srcpad_stream_synchronizer); gst_iterator_free (it); } @@ -2516,14 +2527,17 @@ gst_play_sink_reconfigure (GstPlaySink * playsink) add_chain (GST_PLAY_CHAIN (playsink->textchain), TRUE); if (!playsink->text_sinkpad_stream_synchronizer) { + GValue item = { 0, }; + playsink->text_sinkpad_stream_synchronizer = gst_element_get_request_pad (GST_ELEMENT_CAST (playsink->stream_synchronizer), "sink_%d"); it = gst_pad_iterate_internal_links (playsink->text_sinkpad_stream_synchronizer); g_assert (it); - gst_iterator_next (it, - (gpointer *) & playsink->text_srcpad_stream_synchronizer); + gst_iterator_next (it, &item); + playsink->text_srcpad_stream_synchronizer = g_value_dup_object (&item); + g_value_unset (&item); g_assert (playsink->text_srcpad_stream_synchronizer); gst_iterator_free (it); diff --git a/gst/playback/gststreamselector.c b/gst/playback/gststreamselector.c index 713d802fac..573a90bc7a 100644 --- a/gst/playback/gststreamselector.c +++ b/gst/playback/gststreamselector.c @@ -633,13 +633,15 @@ static GstIterator * gst_stream_selector_pad_iterate_linked_pads (GstPad * pad) { GstStreamSelector *sel = GST_STREAM_SELECTOR (gst_pad_get_parent (pad)); + GValue value = { 0, }; GstPad *otherpad; GstIterator *ret; otherpad = gst_stream_selector_get_linked_pad (pad, TRUE); - ret = - gst_iterator_new_single (GST_TYPE_PAD, otherpad, - (GstCopyFunction) gst_object_ref, (GFreeFunc) gst_object_unref); + g_value_init (&value, GST_TYPE_PAD); + g_value_set_object (&value, otherpad); + ret = gst_iterator_new_single (GST_TYPE_PAD, &value); + g_value_unset (&value); if (otherpad) gst_object_unref (otherpad); diff --git a/gst/playback/gststreamsynchronizer.c b/gst/playback/gststreamsynchronizer.c index 9b79192db6..3e7e841362 100644 --- a/gst/playback/gststreamsynchronizer.c +++ b/gst/playback/gststreamsynchronizer.c @@ -121,8 +121,12 @@ gst_stream_synchronizer_iterate_internal_links (GstPad * pad) opad = gst_stream_get_other_pad_from_pad (pad); if (opad) { - it = gst_iterator_new_single (GST_TYPE_PAD, opad, - (GstCopyFunction) gst_object_ref, (GFreeFunc) gst_object_unref); + GValue value = { 0, }; + + g_value_init (&value, GST_TYPE_PAD); + g_value_set_object (&value, opad); + it = gst_iterator_new_single (GST_TYPE_PAD, &value); + g_value_unset (&value); gst_object_unref (opad); }