gst/gstthread.c: Lock the iteration and the state change so that automatic negotiatio...
authorWim Taymans <wim.taymans@gmail.com>
Wed, 6 Oct 2004 09:42:27 +0000 (09:42 +0000)
committerWim Taymans <wim.taymans@gmail.com>
Wed, 6 Oct 2004 09:42:27 +0000 (09:42 +0000)
Original commit message from CVS:
* gst/gstthread.c: (gst_thread_init), (gst_thread_change_state),
(gst_thread_main_loop):
Lock the iteration and the state change so that automatic
negotiation and fixation does not happen at the same time
as the in stream negotiation.

ChangeLog
gst/gstthread.c
gst/gstthread.h

index 922617e..114127a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2004-10-06  Wim Taymans  <wim at fluendo dot com>
+
+       * gst/gstthread.c: (gst_thread_init), (gst_thread_change_state),
+       (gst_thread_main_loop):
+       Lock the iteration and the state change so that automatic
+       negotiation and fixation does not happen at the same time
+       as the in stream negotiation.
+
 2004-10-05  Thomas Vander Stichele  <thomas at apestaart dot org>
 
        * configure.ac:
index 2a538de..3c6379d 100644 (file)
@@ -206,6 +206,7 @@ gst_thread_init (GTypeInstance * instance, gpointer g_class)
 
   thread->lock = g_mutex_new ();
   thread->cond = g_cond_new ();
+  thread->iterate_lock = g_mutex_new ();
 
   thread->thread_id = (GThread *) NULL; /* set in NULL -> READY */
   thread->priority = G_THREAD_PRIORITY_NORMAL;
@@ -552,11 +553,13 @@ gst_thread_change_state (GstElement * element)
   GST_LOG_OBJECT (thread, "unlocking lock");
   g_mutex_unlock (thread->lock);
 
+  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 {
     ret = GST_STATE_SUCCESS;
   }
+  g_mutex_unlock (thread->iterate_lock);
 
   return ret;
 
@@ -664,7 +667,9 @@ gst_thread_main_loop (void *arg)
         gboolean status;
 
         g_mutex_unlock (thread->lock);
+        g_mutex_lock (thread->iterate_lock);
         status = gst_bin_iterate (GST_BIN (thread));
+        g_mutex_unlock (thread->iterate_lock);
         g_mutex_lock (thread->lock);
 
         if (!status) {
index ce1eb90..806923d 100644 (file)
@@ -61,7 +61,9 @@ struct _GstThread {
   GMutex       *lock;                  /* thread lock/condititon pairs */
   GCond        *cond;                  /* used to control the thread */
 
-  gpointer _gst_reserved[GST_PADDING];
+  GMutex       *iterate_lock;          /* lock iteration in state change  */
+
+  gpointer _gst_reserved[GST_PADDING-1];
 };
 
 struct _GstThreadClass {