2005-10-08 Wim Taymans <wim@fluendo.com>
+ * gst/gstbin.c: (is_eos), (update_degree), (gst_bin_change_state),
+ (gst_bin_dispose), (bin_bus_handler):
+ Fix typos, add comments.
+ Clear EOS list when going to PAUSED from any direction and do it
+ in a threadsafe way.
+ Get base time in a threadsafe way too.
+ Fix confusing debug in the change_state function.
+ Various other mall cleanups.
+
+ * gst/gstelement.c: (gst_element_post_message):
+ Fix very verbose bus posting code.
+
+ * gst/gstpipeline.c: (gst_pipeline_class_init),
+ (gst_pipeline_set_property), (gst_pipeline_get_property),
+ (gst_pipeline_change_state):
+ Small ARG_ -> PROP_ cleanup
+
+2005-10-08 Wim Taymans <wim@fluendo.com>
+
* gst/gstbin.c: (is_eos), (bin_bus_handler):
Do a less CPU demanding EOS check because we can.
gboolean linked = FALSE;
GST_LOCK (element);
- /* don't touch degree is element has no sourcepads */
+ /* don't touch degree if element has no sourcepads */
if (element->numsinkpads != 0) {
/* loop over all sinkpads, decrement degree for all connected
* elements in this bin */
if ((peer_element = gst_pad_get_parent_element (peer))) {
GST_LOCK (peer_element);
+ /* check that we don't go outside of this bin */
if (GST_OBJECT_CAST (peer_element)->parent ==
GST_OBJECT_CAST (bit->bin)) {
gint old_deg, new_deg;
}
}
if (!linked) {
- GST_DEBUG ("element %s not linked to anything", GST_ELEMENT_NAME (element));
+ GST_DEBUG ("element %s not linked on any sinkpads",
+ GST_ELEMENT_NAME (element));
}
GST_UNLOCK (element);
}
bin = GST_BIN_CAST (element);
- /* Clear eosed element list on READY-> PAUSED */
- if (transition == GST_STATE_CHANGE_READY_TO_PAUSED) {
+ /* Clear eosed element list on -> PAUSED */
+ if (transition == GST_STATE_CHANGE_READY_TO_PAUSED ||
+ transition == GST_STATE_CHANGE_PLAYING_TO_PAUSED) {
+ GST_LOCK (bin);
g_list_free (bin->eosed);
bin->eosed = NULL;
+ GST_UNLOCK (bin);
}
/* iterate in state change order */
restart:
/* take base time */
- base_time = element->base_time;
+ base_time = gst_element_get_base_time (element);
have_async = FALSE;
have_no_preroll = FALSE;
switch (gst_iterator_next (it, &data)) {
case GST_ITERATOR_OK:
{
- GstElement *element;
+ GstElement *child;
- element = GST_ELEMENT_CAST (data);
+ child = GST_ELEMENT_CAST (data);
/* set base time on element */
- gst_element_set_base_time (element, base_time);
+ gst_element_set_base_time (child, base_time);
/* set state now */
- ret = gst_bin_element_set_state (bin, element, pending);
+ ret = gst_bin_element_set_state (bin, child, pending);
switch (ret) {
case GST_STATE_CHANGE_SUCCESS:
- GST_CAT_DEBUG (GST_CAT_STATES,
+ GST_CAT_INFO_OBJECT (GST_CAT_STATES, element,
"child '%s' changed state to %d(%s) successfully",
- GST_ELEMENT_NAME (element), pending,
+ GST_ELEMENT_NAME (child), pending,
gst_element_state_get_name (pending));
break;
case GST_STATE_CHANGE_ASYNC:
GST_CAT_INFO_OBJECT (GST_CAT_STATES, element,
"child '%s' is changing state asynchronously",
- GST_ELEMENT_NAME (element));
+ GST_ELEMENT_NAME (child));
have_async = TRUE;
break;
case GST_STATE_CHANGE_FAILURE:
GST_CAT_INFO_OBJECT (GST_CAT_STATES, element,
"child '%s' failed to go to state %d(%s)",
- GST_ELEMENT_NAME (element),
+ GST_ELEMENT_NAME (child),
pending, gst_element_state_get_name (pending));
- gst_object_unref (element);
+ gst_object_unref (child);
goto done;
case GST_STATE_CHANGE_NO_PREROLL:
- GST_CAT_DEBUG (GST_CAT_STATES,
+ GST_CAT_INFO_OBJECT (GST_CAT_STATES, element,
"child '%s' changed state to %d(%s) successfully without preroll",
- GST_ELEMENT_NAME (element), pending,
+ GST_ELEMENT_NAME (child), pending,
gst_element_state_get_name (pending));
have_no_preroll = TRUE;
break;
g_assert_not_reached ();
break;
}
- gst_object_unref (element);
+ gst_object_unref (child);
break;
}
case GST_ITERATOR_RESYNC:
}
done:
+ gst_iterator_free (it);
+
GST_CAT_DEBUG_OBJECT (GST_CAT_STATES, element,
"done changing bin's state from %s to %s, now in %s, ret %d",
gst_element_state_get_name (old_state),
gst_element_state_get_name (pending),
gst_element_state_get_name (GST_STATE (element)), ret);
- gst_iterator_free (it);
-
return ret;
}
bin->child_bus = NULL;
while (bin->children) {
- gst_bin_remove (bin, GST_ELEMENT (bin->children->data));
+ gst_bin_remove (bin, GST_ELEMENT_CAST (bin->children->data));
}
if (G_UNLIKELY (bin->children != NULL)) {
g_critical ("could not remove elements from bin %s",
g_free (name);
/* collect all eos messages from the children */
- GST_LOCK (bin->child_bus);
+ GST_LOCK (bin);
bin->eosed = g_list_prepend (bin->eosed, src);
eos = is_eos (bin);
- GST_UNLOCK (bin->child_bus);
+ GST_UNLOCK (bin);
/* if we are completely EOS, we forward an EOS message */
if (eos) {
GST_DEBUG_OBJECT (bin, "all sinks posted EOS");
- gst_element_post_message (GST_ELEMENT (bin),
- gst_message_new_eos (GST_OBJECT (bin)));
+ gst_element_post_message (GST_ELEMENT_CAST (bin),
+ gst_message_new_eos (GST_OBJECT_CAST (bin)));
}
} else {
GST_DEBUG_OBJECT (bin, "got EOS message from (NULL), not processing");
default:
/* Send all other messages upward */
GST_DEBUG_OBJECT (bin, "posting message upward");
- gst_element_post_message (GST_ELEMENT (bin), message);
+ gst_element_post_message (GST_ELEMENT_CAST (bin), message);
break;
}
#define DEFAULT_PLAY_TIMEOUT (2*GST_SECOND)
enum
{
- ARG_0,
- ARG_DELAY,
- ARG_PLAY_TIMEOUT,
+ PROP_0,
+ PROP_DELAY,
+ PROP_PLAY_TIMEOUT,
/* FILL ME */
};
gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_pipeline_set_property);
gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_pipeline_get_property);
- g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DELAY,
+ g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_DELAY,
g_param_spec_uint64 ("delay", "Delay",
"Expected delay needed for elements "
"to spin up to PLAYING in nanoseconds", 0, G_MAXUINT64, DEFAULT_DELAY,
G_PARAM_READWRITE));
- g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_PLAY_TIMEOUT,
+ g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_PLAY_TIMEOUT,
g_param_spec_uint64 ("play-timeout", "Play Timeout",
"Max timeout for going to PLAYING in nanoseconds", 0, G_MAXUINT64,
DEFAULT_PLAY_TIMEOUT, G_PARAM_READWRITE));
GST_LOCK (pipeline);
switch (prop_id) {
- case ARG_DELAY:
+ case PROP_DELAY:
pipeline->delay = g_value_get_uint64 (value);
break;
- case ARG_PLAY_TIMEOUT:
+ case PROP_PLAY_TIMEOUT:
pipeline->play_timeout = g_value_get_uint64 (value);
break;
default:
GST_LOCK (pipeline);
switch (prop_id) {
- case ARG_DELAY:
+ case PROP_DELAY:
g_value_set_uint64 (value, pipeline->delay);
break;
- case ARG_PLAY_TIMEOUT:
+ case PROP_PLAY_TIMEOUT:
g_value_set_uint64 (value, pipeline->play_timeout);
break;
default: