- an element also has a failed state change if the scheduler setup failed.
authorWim Taymans <wim.taymans@gmail.com>
Tue, 19 Nov 2002 23:15:23 +0000 (23:15 +0000)
committerWim Taymans <wim.taymans@gmail.com>
Tue, 19 Nov 2002 23:15:23 +0000 (23:15 +0000)
Original commit message from CVS:
- an element also has a failed state change if the scheduler setup failed.
- set a thread to _STATE_NULL before destroying it.

gst/gstelement.c
gst/gstthread.c

index dedfa89..8569656 100644 (file)
@@ -2113,6 +2113,14 @@ gst_element_change_state (GstElement *element)
                      gst_element_state_get_name (old_state),
                      gst_element_state_get_name (GST_STATE (element)));
 
+  /* tell the scheduler if we have one */
+  if (element->sched) {
+    if (gst_scheduler_state_transition (element->sched, element, 
+                                       old_transition) != GST_STATE_SUCCESS) {
+      goto failure;
+    }
+  }
+
   g_signal_emit (G_OBJECT (element), gst_element_signals[STATE_CHANGE],
                 0, old_state, GST_STATE (element));
 
@@ -2122,20 +2130,11 @@ gst_element_change_state (GstElement *element)
                                GST_STATE (element), element);
   }
 
-
   /* signal the state change in case somebody is waiting for us */
   g_mutex_lock (element->state_mutex);
   g_cond_signal (element->state_cond);
   g_mutex_unlock (element->state_mutex);
 
-  /* tell the scheduler if we have one */
-  if (element->sched) {
-    if (gst_scheduler_state_transition (element->sched, element, 
-                                       old_transition) != GST_STATE_SUCCESS) {
-      goto failure;
-    }
-  }
-
   return GST_STATE_SUCCESS;
 
 failure:
index 4b13d97..c1e7480 100644 (file)
@@ -197,6 +197,14 @@ gst_thread_dispose (GObject *object)
 
   GST_DEBUG (GST_CAT_REFCOUNTING, "dispose");
 
+  g_mutex_lock (thread->lock);
+  if (GST_STATE (thread) != GST_STATE_NULL) {
+    GST_FLAG_UNSET (thread, GST_THREAD_STATE_SPINNING);
+  }
+  g_mutex_unlock (thread->lock);
+
+  gst_element_set_state (GST_ELEMENT (thread), GST_STATE_NULL);
+
   g_mutex_free (thread->lock);
   g_cond_free (thread->cond);
 
@@ -659,7 +667,7 @@ gst_thread_main_loop (void *arg)
               GST_FLAG_UNSET (thread, GST_THREAD_STATE_SPINNING);
           }
          /* looks like we were stopped because of a statechange */
-         if (GST_STATE_PENDING (thread)) {
+         if (GST_STATE_PENDING (thread) != GST_STATE_VOID_PENDING) {
             gst_thread_update_state (thread);
          }
           /* once we're here, SPINNING has stopped, we should signal that we're done */