From 31b478533ccd1cc49b72178ead2a4cf510add28c Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Fri, 9 Jul 2004 15:03:51 +0000 Subject: [PATCH] gst/: Since remove is virtual in GstBin we must not assume the elements GList to have anothing usefull. Original commit message from CVS: * gst/gstbin.c: (gst_bin_remove), (gst_bin_dispose): * gst/gstthread.c: (gst_thread_dispose), (gst_thread_catch), (gst_thread_main_loop): Since remove is virtual in GstBin we must not assume the elements GList to have anothing usefull. Add some more logging to GstThread and be a bit more paranoid when resetting the scheduler. Set the state of the bin to NULL before removing the children. --- ChangeLog | 11 +++++++++++ gst/gstbin.c | 4 +--- gst/gstthread.c | 9 ++++++++- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index f3fb423..9aaeefc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2004-07-09 Wim Taymans + + * gst/gstbin.c: (gst_bin_remove), (gst_bin_dispose): + * gst/gstthread.c: (gst_thread_dispose), (gst_thread_catch), + (gst_thread_main_loop): + Since remove is virtual in GstBin we must not assume the + elements GList to have anothing usefull. + Add some more logging to GstThread and be a bit more paranoid + when resetting the scheduler. + Set the state of the bin to NULL before removing the children. + 2004-07-09 Zaheer Abbas Merali * testsuite/threads/Makefile.am: diff --git a/gst/gstbin.c b/gst/gstbin.c index 27bbebc..7bf71ce 100644 --- a/gst/gstbin.c +++ b/gst/gstbin.c @@ -588,7 +588,6 @@ gst_bin_remove (GstBin * bin, GstElement * element) g_return_if_fail (GST_IS_BIN (bin)); g_return_if_fail (GST_IS_ELEMENT (element)); - g_return_if_fail (bin->children != NULL); bclass = GST_BIN_GET_CLASS (bin); @@ -833,8 +832,7 @@ gst_bin_dispose (GObject * object) GST_CAT_DEBUG_OBJECT (GST_CAT_REFCOUNTING, object, "dispose"); - if (gst_element_get_state (GST_ELEMENT (object)) == GST_STATE_PLAYING) - gst_element_set_state (GST_ELEMENT (object), GST_STATE_PAUSED); + gst_element_set_state (GST_ELEMENT (object), GST_STATE_NULL); while (bin->children) { gst_bin_remove (bin, GST_ELEMENT (bin->children->data)); diff --git a/gst/gstthread.c b/gst/gstthread.c index c4357a6..3252cfe 100644 --- a/gst/gstthread.c +++ b/gst/gstthread.c @@ -223,6 +223,8 @@ gst_thread_dispose (GObject * object) g_assert (GST_STATE (thread) == GST_STATE_NULL); + GST_CAT_DEBUG (GST_CAT_REFCOUNTING, "GstThread: dispose, freeing locks"); + g_mutex_free (thread->lock); g_cond_free (thread->cond); @@ -369,12 +371,14 @@ gst_thread_catch (GstThread * thread) if (thread == gst_thread_get_current ()) { /* we're trying to catch ourself */ if (!GST_FLAG_IS_SET (thread, GST_THREAD_MUTEX_LOCKED)) { + GST_DEBUG_OBJECT (thread, "catching itself, grabbing lock"); g_mutex_lock (thread->lock); GST_FLAG_SET (thread, GST_THREAD_MUTEX_LOCKED); } GST_DEBUG_OBJECT (thread, "catching itself"); GST_FLAG_UNSET (thread, GST_THREAD_STATE_SPINNING); } else { + GST_DEBUG_OBJECT (thread, "catching thread, grabbing lock"); /* another thread is trying to catch us */ g_mutex_lock (thread->lock); wait = !GST_FLAG_IS_SET (thread, GST_THREAD_STATE_SPINNING); @@ -555,6 +559,7 @@ gst_thread_main_loop (void *arg) { GstThread *thread = NULL; gboolean status; + GstScheduler *sched; thread = GST_THREAD (arg); g_mutex_lock (thread->lock); @@ -595,7 +600,9 @@ gst_thread_main_loop (void *arg) /* we need to destroy the scheduler here because it has mapped it's * stack into the threads stack space */ - gst_scheduler_reset (GST_ELEMENT_SCHED (thread)); + sched = GST_ELEMENT_SCHED (thread); + if (sched) + gst_scheduler_reset (sched); /* must do that before releasing the lock - we might get disposed before being done */ g_signal_emit (G_OBJECT (thread), gst_thread_signals[SHUTDOWN], 0); -- 2.7.4