mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-11 18:05:37 +00:00
gst/playback/: Set state to NULL before removing from bin. Fix refcounting.
Original commit message from CVS: * gst/playback/gstplaybasebin.c: (group_destroy), (gen_preroll_element), (remove_groups), (setup_source): * gst/playback/gstplaybin.c: (remove_sinks), (add_sink), (setup_sinks), (gst_play_bin_send_event), (gst_play_bin_change_state): Set state to NULL before removing from bin. Fix refcounting.
This commit is contained in:
parent
b0f967265a
commit
13331c4636
3 changed files with 30 additions and 3 deletions
|
@ -1,3 +1,12 @@
|
||||||
|
2005-10-04 Michael Smith <msmith@fluendo.com>
|
||||||
|
|
||||||
|
* gst/playback/gstplaybasebin.c: (group_destroy),
|
||||||
|
(gen_preroll_element), (remove_groups), (setup_source):
|
||||||
|
* gst/playback/gstplaybin.c: (remove_sinks), (add_sink),
|
||||||
|
(setup_sinks), (gst_play_bin_send_event),
|
||||||
|
(gst_play_bin_change_state):
|
||||||
|
Set state to NULL before removing from bin. Fix refcounting.
|
||||||
|
|
||||||
2005-10-04 Michael Smith <msmith@fluendo.com>
|
2005-10-04 Michael Smith <msmith@fluendo.com>
|
||||||
|
|
||||||
* gst/playback/gstplaybin.c: (gst_play_bin_send_event):
|
* gst/playback/gstplaybin.c: (gst_play_bin_send_event):
|
||||||
|
|
|
@ -312,6 +312,7 @@ group_destroy (GstPlayBaseGroup * group)
|
||||||
if (fakesrc != NULL) {
|
if (fakesrc != NULL) {
|
||||||
GST_LOG ("removing fakesrc from %s:%s",
|
GST_LOG ("removing fakesrc from %s:%s",
|
||||||
GST_PAD_NAME (pad), GST_ELEMENT_NAME (gst_pad_get_parent (pad)));
|
GST_PAD_NAME (pad), GST_ELEMENT_NAME (gst_pad_get_parent (pad)));
|
||||||
|
gst_element_set_state (fakesrc, GST_STATE_NULL);
|
||||||
gst_bin_remove (GST_BIN (play_base_bin), fakesrc);
|
gst_bin_remove (GST_BIN (play_base_bin), fakesrc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -320,10 +321,14 @@ group_destroy (GstPlayBaseGroup * group)
|
||||||
* from the thread */
|
* from the thread */
|
||||||
if (get_active_group (play_base_bin) == group) {
|
if (get_active_group (play_base_bin) == group) {
|
||||||
GST_LOG ("removing preroll element %s", GST_ELEMENT_NAME (element));
|
GST_LOG ("removing preroll element %s", GST_ELEMENT_NAME (element));
|
||||||
|
gst_element_set_state (element, GST_STATE_NULL);
|
||||||
|
gst_element_set_state (group->type[n].selector, GST_STATE_NULL);
|
||||||
gst_bin_remove (group->type[n].bin, element);
|
gst_bin_remove (group->type[n].bin, element);
|
||||||
gst_bin_remove (group->type[n].bin, group->type[n].selector);
|
gst_bin_remove (group->type[n].bin, group->type[n].selector);
|
||||||
} else {
|
} else {
|
||||||
/* else we can just unref it */
|
/* else we can just unref it */
|
||||||
|
gst_element_set_state (element, GST_STATE_NULL);
|
||||||
|
gst_element_set_state (group->type[n].selector, GST_STATE_NULL);
|
||||||
gst_object_unref (element);
|
gst_object_unref (element);
|
||||||
gst_object_unref (group->type[n].selector);
|
gst_object_unref (group->type[n].selector);
|
||||||
}
|
}
|
||||||
|
@ -620,10 +625,12 @@ gen_preroll_element (GstPlayBaseBin * play_base_bin,
|
||||||
gst_object_unref (preroll_pad);
|
gst_object_unref (preroll_pad);
|
||||||
|
|
||||||
/* add to group list */
|
/* add to group list */
|
||||||
/* FIXME refcount elements, after bin_add, object refs are invalid since
|
|
||||||
* it takes ownership. */
|
|
||||||
group->type[type - 1].selector = selector;
|
group->type[type - 1].selector = selector;
|
||||||
group->type[type - 1].preroll = preroll;
|
group->type[type - 1].preroll = preroll;
|
||||||
|
|
||||||
|
/* gst_bin_add takes ownership, so we need to take a ref beforehand */
|
||||||
|
gst_object_ref (preroll);
|
||||||
|
gst_object_ref (selector);
|
||||||
if (type == GST_STREAM_TYPE_TEXT && play_base_bin->subtitle) {
|
if (type == GST_STREAM_TYPE_TEXT && play_base_bin->subtitle) {
|
||||||
group->type[type - 1].bin = GST_BIN (play_base_bin->subtitle);
|
group->type[type - 1].bin = GST_BIN (play_base_bin->subtitle);
|
||||||
gst_bin_add (GST_BIN (play_base_bin->subtitle), selector);
|
gst_bin_add (GST_BIN (play_base_bin->subtitle), selector);
|
||||||
|
@ -641,6 +648,9 @@ gen_preroll_element (GstPlayBaseBin * play_base_bin,
|
||||||
gst_element_set_state (preroll,
|
gst_element_set_state (preroll,
|
||||||
GST_STATE (play_base_bin) == GST_STATE_PLAYING ?
|
GST_STATE (play_base_bin) == GST_STATE_PLAYING ?
|
||||||
GST_STATE_PLAYING : GST_STATE_PAUSED);
|
GST_STATE_PLAYING : GST_STATE_PAUSED);
|
||||||
|
|
||||||
|
gst_object_unref (preroll);
|
||||||
|
gst_object_unref (selector);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -661,6 +671,7 @@ remove_groups (GstPlayBaseBin * play_base_bin)
|
||||||
|
|
||||||
/* clear subs */
|
/* clear subs */
|
||||||
if (play_base_bin->subtitle) {
|
if (play_base_bin->subtitle) {
|
||||||
|
gst_element_set_state (play_base_bin->subtitle, GST_STATE_NULL);
|
||||||
gst_bin_remove (GST_BIN (play_base_bin), play_base_bin->subtitle);
|
gst_bin_remove (GST_BIN (play_base_bin), play_base_bin->subtitle);
|
||||||
play_base_bin->subtitle = NULL;
|
play_base_bin->subtitle = NULL;
|
||||||
}
|
}
|
||||||
|
@ -1142,6 +1153,7 @@ setup_source (GstPlayBaseBin * play_base_bin, gchar ** new_location)
|
||||||
/* remove the old decoder now, if any */
|
/* remove the old decoder now, if any */
|
||||||
if (play_base_bin->decoder) {
|
if (play_base_bin->decoder) {
|
||||||
GST_DEBUG_OBJECT (play_base_bin, "removing old decoder element");
|
GST_DEBUG_OBJECT (play_base_bin, "removing old decoder element");
|
||||||
|
gst_element_set_state (play_base_bin->decoder, GST_STATE_NULL);
|
||||||
gst_bin_remove (GST_BIN (play_base_bin), play_base_bin->decoder);
|
gst_bin_remove (GST_BIN (play_base_bin), play_base_bin->decoder);
|
||||||
play_base_bin->decoder = NULL;
|
play_base_bin->decoder = NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -653,6 +653,7 @@ remove_sinks (GstPlayBin * play_bin)
|
||||||
* there is no unwanted state change when the parent
|
* there is no unwanted state change when the parent
|
||||||
* is disposed */
|
* is disposed */
|
||||||
play_bin->sinks = g_list_remove (play_bin->sinks, element);
|
play_bin->sinks = g_list_remove (play_bin->sinks, element);
|
||||||
|
gst_element_set_state (element, GST_STATE_NULL);
|
||||||
gst_bin_remove (GST_BIN (parent), element);
|
gst_bin_remove (GST_BIN (parent), element);
|
||||||
gst_object_unref (parent);
|
gst_object_unref (parent);
|
||||||
}
|
}
|
||||||
|
@ -671,6 +672,7 @@ remove_sinks (GstPlayBin * play_bin)
|
||||||
parent = gst_element_get_parent (element);
|
parent = gst_element_get_parent (element);
|
||||||
if (parent != NULL) {
|
if (parent != NULL) {
|
||||||
play_bin->sinks = g_list_remove (play_bin->sinks, element);
|
play_bin->sinks = g_list_remove (play_bin->sinks, element);
|
||||||
|
gst_element_set_state (element, GST_STATE_NULL);
|
||||||
gst_bin_remove (GST_BIN (parent), element);
|
gst_bin_remove (GST_BIN (parent), element);
|
||||||
gst_object_unref (parent);
|
gst_object_unref (parent);
|
||||||
}
|
}
|
||||||
|
@ -701,6 +703,7 @@ remove_sinks (GstPlayBin * play_bin)
|
||||||
}
|
}
|
||||||
gst_object_unref (pad);
|
gst_object_unref (pad);
|
||||||
|
|
||||||
|
gst_element_set_state (element, GST_STATE_NULL);
|
||||||
gst_bin_remove (GST_BIN (play_bin), element);
|
gst_bin_remove (GST_BIN (play_bin), element);
|
||||||
}
|
}
|
||||||
g_list_free (play_bin->sinks);
|
g_list_free (play_bin->sinks);
|
||||||
|
@ -708,9 +711,9 @@ remove_sinks (GstPlayBin * play_bin)
|
||||||
|
|
||||||
/* FIXME: this is probably some refcounting problem */
|
/* FIXME: this is probably some refcounting problem */
|
||||||
if (play_bin->visualisation && GST_OBJECT_PARENT (play_bin->visualisation)) {
|
if (play_bin->visualisation && GST_OBJECT_PARENT (play_bin->visualisation)) {
|
||||||
|
gst_element_set_state (play_bin->visualisation, GST_STATE_NULL);
|
||||||
gst_bin_remove (GST_BIN (GST_OBJECT_PARENT (play_bin->visualisation)),
|
gst_bin_remove (GST_BIN (GST_OBJECT_PARENT (play_bin->visualisation)),
|
||||||
play_bin->visualisation);
|
play_bin->visualisation);
|
||||||
gst_element_set_state (play_bin->visualisation, GST_STATE_NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (play_bin->frame) {
|
if (play_bin->frame) {
|
||||||
|
@ -761,6 +764,7 @@ add_sink (GstPlayBin * play_bin, GstElement * sink, GstPad * srcpad)
|
||||||
g_warning ("could not link %s: %d", capsstr, res);
|
g_warning ("could not link %s: %d", capsstr, res);
|
||||||
g_free (capsstr);
|
g_free (capsstr);
|
||||||
|
|
||||||
|
gst_element_set_state (sink, GST_STATE_NULL);
|
||||||
gst_bin_remove (GST_BIN (play_bin), sink);
|
gst_bin_remove (GST_BIN (play_bin), sink);
|
||||||
} else {
|
} else {
|
||||||
/* we got the sink succesfully linked, now keep the sink
|
/* we got the sink succesfully linked, now keep the sink
|
||||||
|
@ -848,6 +852,7 @@ setup_sinks (GstPlayBaseBin * play_base_bin, GstPlayBaseGroup * group)
|
||||||
/* remove the sinks now, pipeline get_state will now wait for the
|
/* remove the sinks now, pipeline get_state will now wait for the
|
||||||
* sinks to preroll */
|
* sinks to preroll */
|
||||||
if (play_bin->fakesink) {
|
if (play_bin->fakesink) {
|
||||||
|
gst_element_set_state (play_bin->fakesink, GST_STATE_NULL);
|
||||||
gst_bin_remove (GST_BIN (play_bin), play_bin->fakesink);
|
gst_bin_remove (GST_BIN (play_bin), play_bin->fakesink);
|
||||||
play_bin->fakesink = NULL;
|
play_bin->fakesink = NULL;
|
||||||
}
|
}
|
||||||
|
@ -924,6 +929,7 @@ gst_play_bin_change_state (GstElement * element, GstStateChange transition)
|
||||||
remove_sinks (play_bin);
|
remove_sinks (play_bin);
|
||||||
}
|
}
|
||||||
if (play_bin->fakesink) {
|
if (play_bin->fakesink) {
|
||||||
|
gst_element_set_state (play_bin->fakesink, GST_STATE_NULL);
|
||||||
gst_bin_remove (GST_BIN (play_bin), play_bin->fakesink);
|
gst_bin_remove (GST_BIN (play_bin), play_bin->fakesink);
|
||||||
play_bin->fakesink = NULL;
|
play_bin->fakesink = NULL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue