Store the element in the cothread private field.
authorWim Taymans <wim.taymans@gmail.com>
Sat, 23 Feb 2002 13:42:51 +0000 (13:42 +0000)
committerWim Taymans <wim.taymans@gmail.com>
Sat, 23 Feb 2002 13:42:51 +0000 (13:42 +0000)
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.

gst/schedulers/gstbasicscheduler.c

index 00297bd..6ed625c 100644 (file)
@@ -578,6 +578,7 @@ gst_basic_scheduler_cothreaded_chain (GstBin * bin, GstSchedulerChain * chain)
     if (wrapper_function != NULL) {
       if (GST_ELEMENT_THREADSTATE (element) == NULL) {
        GST_ELEMENT_THREADSTATE (element) = cothread_create (GST_BIN_THREADCONTEXT (bin));
+       cothread_set_private (GST_ELEMENT_THREADSTATE (element), element);
        if (GST_ELEMENT_THREADSTATE (element) == NULL) {
           gst_element_error (element, "could not create cothread for \"%s\"", 
                          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 */
     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 */
     gst_basic_scheduler_chain_remove_element (chain, element);