2004-10-07 Wim Taymans <wim at fluendo dot com>
+ * gst/gstthread.c: (gst_thread_change_state),
+ (gst_thread_child_state_change):
+ Make sure no iteration happens while performing
+ the state change as it could mess up the internal
+ consistency of the thread state.
+
+2004-10-07 Wim Taymans <wim at fluendo dot com>
+
* gst/gstthread.c: (gst_thread_dispose), (gst_thread_sync),
(gst_thread_change_state), (gst_thread_child_state_change):
Do not try to grab the iterate lock in the state change method
gst_element_state_get_name (GST_STATE (element)),
gst_element_state_get_name (GST_STATE_PENDING (element)));
- transition = GST_STATE_TRANSITION (element);
-
thread = GST_THREAD (element);
/* boolean to check if we called the state change in the same thread as
gst_thread_sync (thread, is_self);
- /* FIXME: (or GStreamers ideas about "threading"): the element variables are
- commonly accessed by multiple threads at the same time (see bug #111146
- for an example) */
- if (transition != GST_STATE_TRANSITION (element)) {
- g_warning ("inconsistent state information, fix threading please");
- }
+ /* no iteration is allowed during this state change because an iteration
+ * can cause another state change conflicting with this one */
+ /* do not try to grab the lock if this method is called from the
+ * same thread as the iterate thread, the lock might be held and we
+ * might deadlock */
+ if (!is_self)
+ g_mutex_lock (thread->iterate_lock);
+
+ transition = GST_STATE_TRANSITION (element);
switch (transition) {
case GST_STATE_NULL_TO_READY:
GST_LOG_OBJECT (thread, "unlocking lock");
g_mutex_unlock (thread->lock);
- /* do not try to grab the lock if this method is called from the
- * same thread as the iterate thread, the lock might be held and we
- * might deadlock */
- if (!is_self)
- g_mutex_lock (thread->iterate_lock);
if (GST_ELEMENT_CLASS (parent_class)->change_state) {
ret = GST_ELEMENT_CLASS (parent_class)->change_state (GST_ELEMENT (thread));
} else {
g_mutex_unlock (thread->lock);
+ if (!is_self)
+ g_mutex_unlock (thread->iterate_lock);
+
return GST_STATE_FAILURE;
}