summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWim Taymans <wim.taymans@gmail.com>2004-10-06 09:42:27 +0000
committerWim Taymans <wim.taymans@gmail.com>2004-10-06 09:42:27 +0000
commit031d31727489b76109eef3fedaf219469cd281d8 (patch)
treef6a0e8da893bffc59b15b193878fc7dfeaf82766
parent7520601a63870cb52db81ee2e4cba74b77139836 (diff)
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.
-rw-r--r--ChangeLog8
-rw-r--r--gst/gstthread.c5
-rw-r--r--gst/gstthread.h4
3 files changed, 16 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 922617ef2a..114127a4a8 100644
--- 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:
diff --git a/gst/gstthread.c b/gst/gstthread.c
index 2a538de152..3c6379d3e9 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 ce1eb90e94..806923d684 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 {