mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-23 08:46:40 +00:00
gst/gstutils.c: Apparently people think it's better if this function doesn't try to set the state to whatever state w...
Original commit message from CVS: * gst/gstutils.c: (set_state_async_thread_func), (gst_element_set_state_async): Apparently people think it's better if this function doesn't try to set the state to whatever state was asked for on the first call to this function for any object. Seriously.
This commit is contained in:
parent
cf231073c2
commit
ab38914069
2 changed files with 38 additions and 17 deletions
|
@ -1,3 +1,11 @@
|
|||
2005-09-13 Thomas Vander Stichele <thomas at apestaart dot org>
|
||||
|
||||
* gst/gstutils.c: (set_state_async_thread_func),
|
||||
(gst_element_set_state_async):
|
||||
Apparently people think it's better if this function doesn't
|
||||
try to set the state to whatever state was asked for on the first
|
||||
call to this function for any object. Seriously.
|
||||
|
||||
2005-09-12 Thomas Vander Stichele <thomas at apestaart dot org>
|
||||
|
||||
* check/gst/gstpipeline.c: (GST_START_TEST):
|
||||
|
|
|
@ -1887,21 +1887,26 @@ gst_bin_watch_for_state_change (GstBin * bin)
|
|||
g_thread_pool_push (pool, gst_object_ref (bin), NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
set_state_async_thread_func (GstElement * element, gpointer statep)
|
||||
struct _GstAsyncThreadData
|
||||
{
|
||||
GstElement *element;
|
||||
GstState state;
|
||||
};
|
||||
|
||||
static void
|
||||
set_state_async_thread_func (struct _GstAsyncThreadData *data, gpointer unused)
|
||||
{
|
||||
GstState state = GPOINTER_TO_INT (statep);
|
||||
GstState current, pending;
|
||||
GstStateChangeReturn ret = GST_STATE_CHANGE_ASYNC;
|
||||
|
||||
GST_CAT_INFO_OBJECT (GST_CAT_STATES, element,
|
||||
GST_CAT_INFO_OBJECT (GST_CAT_STATES, data->element,
|
||||
"new thread ensuring state change to %s",
|
||||
gst_element_state_get_name (state));
|
||||
gst_element_state_get_name (data->state));
|
||||
|
||||
while (TRUE) {
|
||||
/* wait indefinitely */
|
||||
ret = gst_element_get_state (element, ¤t, &pending, NULL);
|
||||
GST_CAT_INFO_OBJECT (GST_CAT_STATES, element,
|
||||
ret = gst_element_get_state (data->element, ¤t, &pending, NULL);
|
||||
GST_CAT_INFO_OBJECT (GST_CAT_STATES, data->element,
|
||||
"get_state returned %d, current %s, pending %s", ret,
|
||||
gst_element_state_get_name (current),
|
||||
gst_element_state_get_name (pending));
|
||||
|
@ -1909,27 +1914,29 @@ set_state_async_thread_func (GstElement * element, gpointer statep)
|
|||
/* can only be SUCCESS or FAILURE */
|
||||
if (ret == GST_STATE_CHANGE_FAILURE) {
|
||||
/* we can only break, hopefully an error message was posted as well */
|
||||
GST_CAT_INFO_OBJECT (GST_CAT_STATES, element,
|
||||
GST_CAT_INFO_OBJECT (GST_CAT_STATES, data->element,
|
||||
"FAILURE during state change");
|
||||
break;
|
||||
} else if (ret == GST_STATE_CHANGE_SUCCESS) {
|
||||
if (current == state) {
|
||||
GST_CAT_INFO_OBJECT (GST_CAT_STATES, element,
|
||||
if (current == data->state) {
|
||||
GST_CAT_INFO_OBJECT (GST_CAT_STATES, data->element,
|
||||
"successfully reached final state");
|
||||
break;
|
||||
}
|
||||
GST_CAT_INFO_OBJECT (GST_CAT_STATES, element,
|
||||
"setting target state %s again", gst_element_state_get_name (state));
|
||||
gst_element_set_state (element, state);
|
||||
GST_CAT_INFO_OBJECT (GST_CAT_STATES, data->element,
|
||||
"setting target state %s again",
|
||||
gst_element_state_get_name (data->state));
|
||||
gst_element_set_state (data->element, data->state);
|
||||
} else {
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
}
|
||||
|
||||
GST_CAT_INFO_OBJECT (GST_CAT_STATES, element,
|
||||
GST_CAT_INFO_OBJECT (GST_CAT_STATES, data->element,
|
||||
"thread done waiting on state change");
|
||||
|
||||
gst_object_unref (element);
|
||||
gst_object_unref (data->element);
|
||||
g_free (data);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1952,6 +1959,7 @@ GstStateChangeReturn
|
|||
gst_element_set_state_async (GstElement * element, GstState state)
|
||||
{
|
||||
GstStateChangeReturn ret;
|
||||
struct _GstAsyncThreadData *data;
|
||||
|
||||
ret = gst_element_set_state (element, state);
|
||||
if (ret == GST_STATE_CHANGE_ASYNC) {
|
||||
|
@ -1964,10 +1972,15 @@ gst_element_set_state_async (GstElement * element, GstState state)
|
|||
g_static_mutex_lock (&mutex);
|
||||
if (pool == NULL)
|
||||
pool = g_thread_pool_new ((GFunc) set_state_async_thread_func,
|
||||
GINT_TO_POINTER (state), -1, FALSE, NULL);
|
||||
NULL, -1, FALSE, NULL);
|
||||
g_static_mutex_unlock (&mutex);
|
||||
|
||||
g_thread_pool_push (pool, gst_object_ref (element), NULL);
|
||||
data = g_new0 (struct _GstAsyncThreadData, 1);
|
||||
|
||||
gst_object_ref (element);
|
||||
data->element = element;
|
||||
data->state = state;
|
||||
g_thread_pool_push (pool, data, NULL);
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
|
Loading…
Reference in a new issue