From 031d31727489b76109eef3fedaf219469cd281d8 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 6 Oct 2004 09:42:27 +0000 Subject: [PATCH] gst/gstthread.c: Lock the iteration and the state change so that automatic negotiation and fixation does not happen a... 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 | 8 ++++++++ gst/gstthread.c | 5 +++++ gst/gstthread.h | 4 +++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 922617e..114127a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2004-10-06 Wim Taymans + + * 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 * configure.ac: diff --git a/gst/gstthread.c b/gst/gstthread.c index 2a538de..3c6379d 100644 --- a/gst/gstthread.c +++ b/gst/gstthread.c @@ -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) { diff --git a/gst/gstthread.h b/gst/gstthread.h index ce1eb90..806923d 100644 --- a/gst/gstthread.h +++ b/gst/gstthread.h @@ -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 { -- 2.7.4