Store the element in the cothread private field.

Original commit message from CVS:
Store the element in the cothread private field.
If we remove the current entry in the cothread chain, make sure another
cothread is marked as COTHREAD_STOPPING.
This commit is contained in:
Wim Taymans 2002-02-23 13:42:51 +00:00
parent 929b4bd3d1
commit 7835b75f0a

View file

@ -578,6 +578,7 @@ gst_basic_scheduler_cothreaded_chain (GstBin * bin, GstSchedulerChain * chain)
if (wrapper_function != NULL) { if (wrapper_function != NULL) {
if (GST_ELEMENT_THREADSTATE (element) == NULL) { if (GST_ELEMENT_THREADSTATE (element) == NULL) {
GST_ELEMENT_THREADSTATE (element) = cothread_create (GST_BIN_THREADCONTEXT (bin)); GST_ELEMENT_THREADSTATE (element) = cothread_create (GST_BIN_THREADCONTEXT (bin));
cothread_set_private (GST_ELEMENT_THREADSTATE (element), element);
if (GST_ELEMENT_THREADSTATE (element) == NULL) { if (GST_ELEMENT_THREADSTATE (element) == NULL) {
gst_element_error (element, "could not create cothread for \"%s\"", gst_element_error (element, "could not create cothread for \"%s\"",
GST_ELEMENT_NAME (element), NULL); GST_ELEMENT_NAME (element), NULL);
@ -1004,6 +1005,19 @@ gst_basic_scheduler_remove_element (GstScheduler * sched, GstElement * element)
/* find what chain the element is in */ /* find what chain the element is in */
chain = gst_basic_scheduler_find_chain (bsched, element); chain = gst_basic_scheduler_find_chain (bsched, element);
if (GST_ELEMENT_IS_COTHREAD_STOPPING (element)) {
GstElement *entry = GST_ELEMENT (cothread_get_private (cothread_current ()));
if (entry == element) {
g_warning ("removing currently running element! %s", GST_ELEMENT_NAME (entry));
}
else if (entry) {
GST_INFO (GST_CAT_SCHEDULING, "moving stopping to element \"%s\"",
GST_ELEMENT_NAME (entry));
GST_FLAG_SET (entry, GST_ELEMENT_COTHREAD_STOPPING);
}
}
/* remove it from its chain */ /* remove it from its chain */
gst_basic_scheduler_chain_remove_element (chain, element); gst_basic_scheduler_chain_remove_element (chain, element);