diff options
author | Thiago Santos <thiagoss@osg.samsung.com> | 2014-12-10 13:23:23 -0300 |
---|---|---|
committer | Tim-Philipp Müller <tim@centricular.com> | 2014-12-11 14:24:26 +0000 |
commit | ffb284efc37f1011aca7677a9f294366b9c493c0 (patch) | |
tree | 59067cfbc389c87991822fce6b0b1eaaafcfcf3e | |
parent | e84276bc24eaae24453952cb7914ddeaf880fea4 (diff) |
playbin2: always unref the combiner sinkpad when removing the srcpad
Create a function to do the pad cleanup of the GstSourceCombine struct
and use it to not forget to also cleanup the sink pad and fix a memory
leak.
https://bugzilla.gnome.org/show_bug.cgi?id=741198
-rw-r--r-- | gst/playback/gstplaybin2.c | 36 |
1 files changed, 19 insertions, 17 deletions
diff --git a/gst/playback/gstplaybin2.c b/gst/playback/gstplaybin2.c index f2a3af6a6..08ff9aa4e 100644 --- a/gst/playback/gstplaybin2.c +++ b/gst/playback/gstplaybin2.c @@ -2032,6 +2032,22 @@ gst_play_bin_suburidecodebin_seek_to_start (GstSourceGroup * group) gst_iterator_free (it); } +static void +source_combine_remove_pads (GstPlayBin * playbin, GstSourceCombine * combine) +{ + if (combine->sinkpad) { + GST_LOG_OBJECT (playbin, "unlinking from sink"); + gst_pad_unlink (combine->srcpad, combine->sinkpad); + + /* release back */ + GST_LOG_OBJECT (playbin, "release sink pad"); + gst_play_sink_release_pad (playbin->playsink, combine->sinkpad); + gst_object_unref (combine->sinkpad); + combine->sinkpad = NULL; + } + gst_object_unref (combine->srcpad); + combine->srcpad = NULL; +} static GstPadProbeReturn block_serialized_data_cb (GstPad * pad, GstPadProbeInfo * info, @@ -3353,8 +3369,7 @@ pad_removed_cb (GstElement * decodebin, GstPad * pad, GstSourceGroup * group) if ((combine = g_object_get_data (G_OBJECT (pad), "playbin.combine"))) { g_assert (combine->combiner == NULL); g_assert (combine->srcpad == pad); - gst_object_unref (pad); - combine->srcpad = NULL; + source_combine_remove_pads (playbin, combine); goto exit; } @@ -3405,8 +3420,7 @@ pad_removed_cb (GstElement * decodebin, GstPad * pad, GstSourceGroup * group) if (!combine->channels->len && combine->combiner) { GST_DEBUG_OBJECT (playbin, "all combiner sinkpads removed"); GST_DEBUG_OBJECT (playbin, "removing combiner %p", combine->combiner); - gst_object_unref (combine->srcpad); - combine->srcpad = NULL; + source_combine_remove_pads (playbin, combine); gst_element_set_state (combine->combiner, GST_STATE_NULL); gst_bin_remove (GST_BIN_CAST (playbin), combine->combiner); combine->combiner = NULL; @@ -5286,19 +5300,7 @@ deactivate_group (GstPlayBin * playbin, GstSourceGroup * group) GST_DEBUG_OBJECT (playbin, "unlinking combiner %s", combine->media_list[0]); if (combine->srcpad) { - if (combine->sinkpad) { - GST_LOG_OBJECT (playbin, "unlinking from sink"); - gst_pad_unlink (combine->srcpad, combine->sinkpad); - - /* release back */ - GST_LOG_OBJECT (playbin, "release sink pad"); - gst_play_sink_release_pad (playbin->playsink, combine->sinkpad); - gst_object_unref (combine->sinkpad); - combine->sinkpad = NULL; - } - - gst_object_unref (combine->srcpad); - combine->srcpad = NULL; + source_combine_remove_pads (playbin, combine); } if (combine->combiner) { |