+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>
* gst/playback/gstplaybin.c: (gst_play_bin_send_event):
if (fakesrc != NULL) {
GST_LOG ("removing fakesrc from %s:%s",
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);
}
}
* from the thread */
if (get_active_group (play_base_bin) == group) {
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, group->type[n].selector);
} else {
/* 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 (group->type[n].selector);
}
gst_object_unref (preroll_pad);
/* 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].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) {
group->type[type - 1].bin = GST_BIN (play_base_bin->subtitle);
gst_bin_add (GST_BIN (play_base_bin->subtitle), selector);
gst_element_set_state (preroll,
GST_STATE (play_base_bin) == GST_STATE_PLAYING ?
GST_STATE_PLAYING : GST_STATE_PAUSED);
+
+ gst_object_unref (preroll);
+ gst_object_unref (selector);
}
static void
/* clear subs */
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);
play_base_bin->subtitle = NULL;
}
/* remove the old decoder now, if any */
if (play_base_bin->decoder) {
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);
play_base_bin->decoder = NULL;
}
* there is no unwanted state change when the parent
* is disposed */
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_object_unref (parent);
}
parent = gst_element_get_parent (element);
if (parent != NULL) {
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_object_unref (parent);
}
}
gst_object_unref (pad);
+ gst_element_set_state (element, GST_STATE_NULL);
gst_bin_remove (GST_BIN (play_bin), element);
}
g_list_free (play_bin->sinks);
/* FIXME: this is probably some refcounting problem */
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)),
play_bin->visualisation);
- gst_element_set_state (play_bin->visualisation, GST_STATE_NULL);
}
if (play_bin->frame) {
g_warning ("could not link %s: %d", capsstr, res);
g_free (capsstr);
+ gst_element_set_state (sink, GST_STATE_NULL);
gst_bin_remove (GST_BIN (play_bin), sink);
} else {
/* we got the sink succesfully linked, now keep the sink
/* remove the sinks now, pipeline get_state will now wait for the
* sinks to preroll */
if (play_bin->fakesink) {
+ gst_element_set_state (play_bin->fakesink, GST_STATE_NULL);
gst_bin_remove (GST_BIN (play_bin), play_bin->fakesink);
play_bin->fakesink = NULL;
}
remove_sinks (play_bin);
}
if (play_bin->fakesink) {
+ gst_element_set_state (play_bin->fakesink, GST_STATE_NULL);
gst_bin_remove (GST_BIN (play_bin), play_bin->fakesink);
play_bin->fakesink = NULL;
}