From 3526156fe77f1b476e883f71e92370ecca99b7d3 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Tue, 31 Jul 2001 20:57:58 +0000 Subject: [PATCH] Added a missing state change switch. Original commit message from CVS: Added a missing state change switch. Uncommented a big FIXME that was needed after all. Stop now works. --- gst/gstthread.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/gst/gstthread.c b/gst/gstthread.c index 8d297d0e6f5..97bd1f88f14 100644 --- a/gst/gstthread.c +++ b/gst/gstthread.c @@ -446,8 +446,8 @@ gst_thread_change_state (GstElement *element) { THR_DEBUG("telling thread to pause (null) - and joining\n"); //MattH FIXME revisit -// g_mutex_lock(thread->lock); -// gst_thread_signal_thread(thread,FALSE); + g_mutex_lock(thread->lock); + gst_thread_signal_thread(thread,FALSE); pthread_join(thread->thread_id,NULL); } @@ -456,9 +456,27 @@ gst_thread_change_state (GstElement *element) GST_FLAG_UNSET(thread,GST_THREAD_STATE_SPINNING); GST_FLAG_UNSET(thread,GST_THREAD_STATE_ELEMENT_CHANGED); - if (GST_ELEMENT_CLASS (parent_class)->change_state) - stateset = GST_ELEMENT_CLASS (parent_class)->change_state (GST_ELEMENT(thread)); + break; + case GST_STATE_PAUSED_TO_READY: + THR_INFO("stopping thread"); + // check to see if the thread is somehow changing its own state. + // FIXME this is currently illegal, but must somehow be made legal at some point. + if (pthread_equal(self, thread->thread_id)) + { + //FIXME this should not happen + g_assert(!pthread_equal(self, thread->thread_id)); + GST_FLAG_SET(thread, GST_THREAD_STATE_SPINNING); + GST_DEBUG(GST_CAT_THREAD,"no sync(" GST_DEBUG_THREAD_FORMAT "): setting own thread's state to spinning\n", + GST_DEBUG_THREAD_ARGS(thread->pid)); + } + else + { + THR_DEBUG("telling thread to stop spinning\n"); + g_mutex_lock(thread->lock); + gst_thread_signal_thread(thread,FALSE); + } + break; default: break;