2 * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
3 * 2000 Wim Taymans <wtay@chello.be>
5 * gstthread.c: Threaded container object
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
17 * You should have received a copy of the GNU Library General Public
18 * License along with this library; if not, write to the
19 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
25 /* #define GST_DEBUG_ENABLED */
26 #include "gst_private.h"
29 #include "gstthread.h"
30 #include "gstscheduler.h"
33 #define STACK_SIZE 0x200000
35 #define g_thread_equal(a,b) ((a) == (b))
37 GstElementDetails gst_thread_details = {
41 "Container that creates/manages a thread",
43 "Erik Walthinsen <omega@cse.ogi.edu>",
48 /* Thread signals and args */
69 static void gst_thread_class_init (GstThreadClass *klass);
70 static void gst_thread_init (GstThread *thread);
72 static void gst_thread_dispose (GObject *object);
74 static void gst_thread_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
75 static void gst_thread_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
78 GstElementStateReturn gst_thread_change_state (GstElement *element);
80 #ifndef GST_DISABLE_LOADSAVE
81 static xmlNodePtr gst_thread_save_thyself (GstObject *object,
83 static void gst_thread_restore_thyself (GstObject *object,
87 static void* gst_thread_main_loop (void *arg);
89 #define GST_TYPE_THREAD_SCHEDPOLICY (gst_thread_schedpolicy_get_type())
91 gst_thread_schedpolicy_get_type(void) {
92 static GType thread_schedpolicy_type = 0;
93 static GEnumValue thread_schedpolicy[] = {
94 {G_THREAD_PRIORITY_LOW, "LOW", "Low Priority Scheduling"},
95 {G_THREAD_PRIORITY_NORMAL, "NORMAL", "Normal Scheduling"},
96 {G_THREAD_PRIORITY_HIGH, "HIGH", "High Priority Scheduling"},
97 {G_THREAD_PRIORITY_URGENT, "URGENT", "Urgent Scheduling"},
100 if (!thread_schedpolicy_type) {
101 thread_schedpolicy_type = g_enum_register_static("GstThreadSchedPolicy", thread_schedpolicy);
103 return thread_schedpolicy_type;
106 static GstBinClass *parent_class = NULL;
107 static guint gst_thread_signals[LAST_SIGNAL] = { 0 };
110 gst_thread_get_type(void) {
111 static GType thread_type = 0;
114 static const GTypeInfo thread_info = {
115 sizeof (GstThreadClass), NULL, NULL,
116 (GClassInitFunc) gst_thread_class_init, NULL, NULL,
119 (GInstanceInitFunc) gst_thread_init,
122 thread_type = g_type_register_static (GST_TYPE_BIN, "GstThread",
129 gst_thread_class_init (GstThreadClass *klass)
131 GObjectClass *gobject_class;
132 GstObjectClass *gstobject_class;
133 GstElementClass *gstelement_class;
134 GstBinClass *gstbin_class;
136 gobject_class = (GObjectClass*)klass;
137 gstobject_class = (GstObjectClass*)klass;
138 gstelement_class = (GstElementClass*)klass;
139 gstbin_class = (GstBinClass*)klass;
141 parent_class = g_type_class_ref (GST_TYPE_BIN);
143 g_object_class_install_property(G_OBJECT_CLASS (klass), ARG_SCHEDPOLICY,
144 g_param_spec_enum("schedpolicy", "Scheduling Policy", "The scheduling policy of the thread",
145 GST_TYPE_THREAD_SCHEDPOLICY, G_THREAD_PRIORITY_NORMAL, G_PARAM_READWRITE));
146 g_object_class_install_property(G_OBJECT_CLASS (klass), ARG_PRIORITY,
147 g_param_spec_int("priority", "Scheduling Priority", "The scheduling priority of the thread",
148 0, 99, 0, G_PARAM_READWRITE));
150 gst_thread_signals[SHUTDOWN] =
151 g_signal_new ("shutdown", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
152 G_STRUCT_OFFSET (GstThreadClass, shutdown), NULL, NULL,
153 gst_marshal_VOID__VOID, G_TYPE_NONE, 0);
155 gobject_class->dispose = gst_thread_dispose;
157 #ifndef GST_DISABLE_LOADSAVE
158 gstobject_class->save_thyself = GST_DEBUG_FUNCPTR (gst_thread_save_thyself);
159 gstobject_class->restore_thyself = GST_DEBUG_FUNCPTR (gst_thread_restore_thyself);
162 gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_thread_change_state);
164 gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_thread_set_property);
165 gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_thread_get_property);
170 gst_thread_init (GstThread *thread)
172 GstScheduler *scheduler;
174 GST_DEBUG (GST_CAT_THREAD, "initializing thread");
176 /* threads are managing bins and iterate themselves */
177 /* CR1: the GstBin code checks these flags */
178 GST_FLAG_SET (thread, GST_BIN_FLAG_MANAGER);
179 GST_FLAG_SET (thread, GST_BIN_SELF_SCHEDULABLE);
181 scheduler = gst_scheduler_factory_make (NULL, GST_ELEMENT (thread));
183 thread->lock = g_mutex_new ();
184 thread->cond = g_cond_new ();
186 thread->ppid = getpid ();
187 thread->thread_id = (GThread *) NULL; /* set in NULL -> READLY */
188 thread->sched_policy = G_THREAD_PRIORITY_NORMAL;
189 thread->priority = 0;
190 thread->stack = NULL;
194 gst_thread_dispose (GObject *object)
196 GstThread *thread = GST_THREAD (object);
198 GST_DEBUG (GST_CAT_REFCOUNTING, "dispose");
200 g_mutex_lock (thread->lock);
201 if (GST_STATE (thread) != GST_STATE_NULL) {
202 GST_FLAG_UNSET (thread, GST_THREAD_STATE_SPINNING);
204 g_mutex_unlock (thread->lock);
206 gst_element_set_state (GST_ELEMENT (thread), GST_STATE_NULL);
208 g_mutex_free (thread->lock);
209 g_cond_free (thread->cond);
211 G_OBJECT_CLASS (parent_class)->dispose (object);
213 if (GST_ELEMENT_SCHED (thread)) {
214 gst_object_unref (GST_OBJECT (GST_ELEMENT_SCHED (thread)));
219 gst_thread_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
223 /* it's not null if we got it, but it might not be ours */
224 g_return_if_fail (GST_IS_THREAD (object));
226 thread = GST_THREAD (object);
229 case ARG_SCHEDPOLICY:
230 thread->sched_policy = g_value_get_enum (value);
233 thread->priority = g_value_get_int (value);
236 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
242 gst_thread_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
246 /* it's not null if we got it, but it might not be ours */
247 g_return_if_fail (GST_IS_THREAD (object));
249 thread = GST_THREAD (object);
252 case ARG_SCHEDPOLICY:
253 g_value_set_enum (value, thread->sched_policy);
256 g_value_set_int (value, thread->priority);
259 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
267 * @name: the name of the thread
269 * Create a new thread with the given name.
271 * Returns: The new thread
274 gst_thread_new (const gchar *name)
276 return gst_element_factory_make ("thread", name);
279 /* these two macros are used for debug/info from the state_change function */
281 #define THR_INFO(format,args...) \
282 GST_INFO_ELEMENT(GST_CAT_THREAD, thread, "sync(" GST_DEBUG_THREAD_FORMAT "): " format , \
283 GST_DEBUG_THREAD_ARGS(thread->pid) , ## args )
285 #define THR_DEBUG(format,args...) \
286 GST_DEBUG_ELEMENT(GST_CAT_THREAD, thread, "sync(" GST_DEBUG_THREAD_FORMAT "): " format , \
287 GST_DEBUG_THREAD_ARGS(thread->pid) , ## args )
289 /* these two macros are used for debug/info from the gst_thread_main_loop
293 #define THR_INFO_MAIN(format,args...) \
294 GST_INFO_ELEMENT(GST_CAT_THREAD, thread, "sync-main(" GST_DEBUG_THREAD_FORMAT "): " format , \
295 GST_DEBUG_THREAD_ARGS(thread->ppid) , ## args )
297 #define THR_DEBUG_MAIN(format,args...) \
298 GST_DEBUG_ELEMENT(GST_CAT_THREAD, thread, "sync-main(" GST_DEBUG_THREAD_FORMAT "): " format , \
299 GST_DEBUG_THREAD_ARGS(thread->ppid) , ## args )
301 static GstElementStateReturn
302 gst_thread_update_state (GstThread *thread)
304 GST_DEBUG_ELEMENT (GST_CAT_THREAD, thread, "updating state of thread");
305 /* check for state change */
306 if (GST_STATE_PENDING (thread) != GST_STATE_VOID_PENDING) {
307 /* punt and change state on all the children */
308 if (GST_ELEMENT_CLASS (parent_class)->change_state)
309 return GST_ELEMENT_CLASS (parent_class)->change_state (GST_ELEMENT (thread));
312 /* FIXME: in the case of no change_state function in the parent's class,
313 * shouldn't we actually change the thread's state ? */
314 g_warning ("thread's parent doesn't have change_state, returning success");
315 return GST_STATE_SUCCESS;
319 static GstElementStateReturn
320 gst_thread_change_state (GstElement *element)
323 gboolean stateset = GST_STATE_SUCCESS;
325 GThread *self = g_thread_self ();
326 GError *error = NULL;
328 g_return_val_if_fail (GST_IS_THREAD (element), GST_STATE_FAILURE);
329 g_return_val_if_fail (gst_has_threads (), GST_STATE_FAILURE);
331 thread = GST_THREAD (element);
333 transition = GST_STATE_TRANSITION (element);
335 THR_INFO ("changing state from %s to %s",
336 gst_element_state_get_name (GST_STATE (element)),
337 gst_element_state_get_name (GST_STATE_PENDING (element)));
339 if (g_thread_equal (self, thread->thread_id)) {
340 GST_DEBUG (GST_CAT_THREAD,
341 "no sync(" GST_DEBUG_THREAD_FORMAT "): "
342 "setting own thread's state to spinning",
343 GST_DEBUG_THREAD_ARGS (thread->pid));
344 return gst_thread_update_state (thread);
347 switch (transition) {
348 case GST_STATE_NULL_TO_READY:
349 /* set the state to idle */
350 GST_FLAG_UNSET (thread, GST_THREAD_STATE_SPINNING);
352 THR_DEBUG ("creating thread \"%s\"", GST_ELEMENT_NAME (element));
354 /* this bit of code handles creation of GThreads
355 * this is therefor tricky code
356 * compare it with the block of code that handles the destruction
357 * in GST_STATE_READY_TO_NULL below
359 g_mutex_lock (thread->lock);
361 /* create a new GThread
362 * use the specified attributes
363 * make it execute gst_thread_main_loop (thread)
365 GST_DEBUG (GST_CAT_THREAD, "going to g_thread_create_full...");
366 thread->thread_id = g_thread_create_full(gst_thread_main_loop,
367 thread, STACK_SIZE, TRUE, TRUE, G_THREAD_PRIORITY_NORMAL,
370 if (!thread->thread_id){
371 GST_DEBUG (GST_CAT_THREAD, "g_thread_create_full failed");
372 g_mutex_unlock (thread->lock);
373 GST_DEBUG (GST_CAT_THREAD, "could not create thread \"%s\"",
374 GST_ELEMENT_NAME (element));
376 return GST_STATE_FAILURE;
378 GST_DEBUG (GST_CAT_THREAD, "GThread created");
380 /* wait for it to 'spin up' */
381 THR_DEBUG ("waiting for child thread spinup");
382 g_cond_wait (thread->cond, thread->lock);
383 THR_DEBUG ("thread claims to be up");
384 g_mutex_unlock (thread->lock);
386 case GST_STATE_READY_TO_PAUSED:
387 THR_INFO ("readying thread");
388 g_mutex_lock (thread->lock);
389 THR_DEBUG ("signaling");
390 g_cond_signal (thread->cond);
391 THR_DEBUG ("waiting for ack");
392 g_cond_wait (thread->cond, thread->lock);
393 THR_DEBUG ("got ack");
394 g_mutex_unlock (thread->lock);
396 case GST_STATE_PAUSED_TO_PLAYING:
398 /* fixme: recurse into sub-bins */
399 const GList *elements = gst_bin_get_list (GST_BIN (thread));
401 gst_element_enable_threadsafe_properties ((GstElement*)elements->data);
402 elements = g_list_next (elements);
405 THR_DEBUG ("telling thread to start spinning");
406 g_mutex_lock (thread->lock);
407 THR_DEBUG ("signaling");
408 g_cond_signal (thread->cond);
409 THR_DEBUG ("waiting for ack");
410 g_cond_wait (thread->cond, thread->lock);
411 THR_DEBUG ("got ack");
412 g_mutex_unlock (thread->lock);
414 /* we're actually doing async notification, the state could
415 * have changed already (eg. EOS) here. commented out as
416 * it needs more thinking... */
417 /* stateset = GST_STATE_ASYNC; */
420 case GST_STATE_PLAYING_TO_PAUSED:
422 const GList *elements = (GList *) gst_bin_get_list (GST_BIN (thread));
424 THR_INFO ("pausing thread");
426 /* the following code ensures that the bottom half of thread will run
427 * to perform each elements' change_state() (by calling gstbin.c::
429 * + the pending state was already set by gstelement.c::set_state()
430 * + unlock all elements so the bottom half can start the state change.
432 g_mutex_lock (thread->lock);
434 GST_FLAG_UNSET (thread, GST_THREAD_STATE_SPINNING);
437 GstElement *element = GST_ELEMENT (elements->data);
442 THR_DEBUG (" waking element \"%s\"", GST_ELEMENT_NAME (element));
443 elements = g_list_next (elements);
445 if (!gst_element_release_locks (element)) {
446 g_warning ("element %s could not release locks", GST_ELEMENT_NAME (element));
449 pads = GST_ELEMENT_PADS (element);
452 GstRealPad *peer = NULL;
453 GstElement *peerelement;
455 if (GST_PAD_PEER (pads->data))
456 peer = GST_REAL_PAD (GST_PAD_PEER (pads->data));
458 pads = g_list_next (pads);
463 peerelement = GST_PAD_PARENT (peer);
465 continue; /* deal with case where there's no peer */
467 if (!GST_FLAG_IS_SET (peerelement, GST_ELEMENT_DECOUPLED)) {
468 GST_DEBUG (GST_CAT_THREAD, "peer element isn't DECOUPLED");
472 if (GST_ELEMENT_SCHED (peerelement) != GST_ELEMENT_SCHED (thread)) {
473 THR_DEBUG (" element \"%s\" has pad cross sched boundary", GST_ELEMENT_NAME (element));
474 THR_DEBUG (" waking element \"%s\"", GST_ELEMENT_NAME (peerelement));
475 if (!gst_element_release_locks (peerelement)) {
476 g_warning ("element %s could not release locks", GST_ELEMENT_NAME (peerelement));
482 THR_DEBUG ("telling thread to pause, signaling");
483 g_cond_signal (thread->cond);
484 THR_DEBUG ("waiting for ack");
485 g_cond_wait (thread->cond, thread->lock);
486 THR_DEBUG ("got ack");
487 g_mutex_unlock (thread->lock);
489 elements = gst_bin_get_list (GST_BIN (thread));
491 gst_element_disable_threadsafe_properties ((GstElement*)elements->data);
492 elements = g_list_next (elements);
496 case GST_STATE_READY_TO_NULL:
497 THR_DEBUG ("telling thread to pause (null) - and joining");
498 /* MattH FIXME revisit */
499 g_mutex_lock (thread->lock);
500 THR_DEBUG ("signaling");
501 g_cond_signal (thread->cond);
502 THR_DEBUG ("waiting for ack");
503 g_cond_wait (thread->cond, thread->lock);
504 THR_DEBUG ("got ack");
507 /* this block of code is very tricky
508 * basically, we try to clean up the whole thread and
509 * everything related to it in the right order without
510 * triggering segfaults
511 * compare this block to the block
514 GST_DEBUG (GST_CAT_THREAD, "joining GThread %p", thread->thread_id);
515 g_thread_join (thread->thread_id);
517 thread->thread_id = NULL;
518 thread->stack = NULL;
520 THR_DEBUG ("unlocking mutex");
521 g_mutex_unlock (thread->lock);
523 GST_FLAG_UNSET (thread, GST_THREAD_STATE_REAPING);
524 GST_FLAG_UNSET (thread, GST_THREAD_STATE_STARTED);
525 GST_FLAG_UNSET (thread, GST_THREAD_STATE_SPINNING);
528 case GST_STATE_PAUSED_TO_READY:
529 THR_DEBUG ("telling thread to stop spinning");
530 g_mutex_lock (thread->lock);
531 THR_DEBUG ("signaling");
532 g_cond_signal (thread->cond);
533 THR_DEBUG ("waiting for ack");
534 g_cond_wait (thread->cond, thread->lock);
535 THR_DEBUG ("got ack");
536 g_mutex_unlock (thread->lock);
540 GST_DEBUG_ELEMENT (GST_CAT_THREAD, element, "UNHANDLED STATE CHANGE! %x", transition);
548 * gst_thread_main_loop:
549 * @arg: the thread to start
551 * The main loop of the thread. The thread will iterate
552 * while the state is GST_THREAD_STATE_SPINNING.
555 gst_thread_main_loop (void *arg)
557 GstThread *thread = NULL;
560 gpointer stack_pointer;
563 GST_DEBUG (GST_CAT_THREAD, "gst_thread_main_loop started");
564 thread = GST_THREAD (arg);
565 g_mutex_lock (thread->lock);
567 /* set up the element's scheduler */
568 gst_scheduler_setup (GST_ELEMENT_SCHED (thread));
569 GST_FLAG_UNSET (thread, GST_THREAD_STATE_REAPING);
571 thread->pid = getpid();
572 THR_INFO_MAIN ("thread is running");
574 page_size = sysconf(_SC_PAGESIZE);
575 stack_pointer = (gpointer) &stack_pointer;
577 if(((gulong)stack_pointer & (page_size-1)) < (page_size>>1)){
578 /* stack grows up, I think */
579 /* FIXME this is probably not true for the main thread */
580 stack_offset = (gulong)stack_pointer & (page_size - 1);
582 /* stack grows down, I think */
583 stack_offset = STACK_SIZE - ((gulong)stack_pointer & (page_size - 1));
585 /* note the subtlety with pointer arithmetic */
586 thread->stack = stack_pointer - stack_offset;
587 thread->stack_size = STACK_SIZE;
589 /* first we need to change the state of all the children */
590 if (GST_ELEMENT_CLASS (parent_class)->change_state) {
591 stateset = GST_ELEMENT_CLASS (parent_class)->change_state (GST_ELEMENT(thread));
593 if (stateset != GST_STATE_SUCCESS) {
594 THR_DEBUG_MAIN ("state change of children failed");
598 THR_DEBUG_MAIN ("indicating spinup");
599 g_cond_signal (thread->cond);
600 /* don't unlock the mutex because we hold it into the top of the while loop */
601 THR_DEBUG_MAIN ("thread has indicated spinup to parent process");
603 /***** THREAD IS NOW IN READY STATE *****/
605 /* CR1: most of this code is handshaking */
606 /* do this while the thread lives */
607 while (!GST_FLAG_IS_SET (thread, GST_THREAD_STATE_REAPING)) {
608 /* NOTE we hold the thread lock at this point */
609 /* what we do depends on what state we're in */
610 switch (GST_STATE (thread)) {
611 /* NOTE: cannot be in NULL, we're not running in that state at all */
612 case GST_STATE_READY:
613 /* wait to be set to either the NULL or PAUSED states */
614 THR_DEBUG_MAIN ("thread in %s state, waiting for either %s or %s",
615 gst_element_state_get_name (GST_STATE_READY),
616 gst_element_state_get_name (GST_STATE_NULL),
617 gst_element_state_get_name (GST_STATE_PAUSED));
618 g_cond_wait (thread->cond, thread->lock);
620 /* this must have happened by a state change in the thread context */
621 if (GST_STATE_PENDING (thread) != GST_STATE_NULL &&
622 GST_STATE_PENDING (thread) != GST_STATE_PAUSED) {
623 g_cond_signal (thread->cond);
627 /* been signaled, we need to state transition now and signal back */
628 gst_thread_update_state (thread);
629 /* now we decide what to do next */
630 if (GST_STATE (thread) == GST_STATE_NULL) {
631 /* REAPING must be set, we can simply break this iteration */
632 THR_DEBUG_MAIN ("set GST_THREAD_STATE_REAPING");
633 GST_FLAG_SET (thread, GST_THREAD_STATE_REAPING);
635 THR_DEBUG_MAIN ("done with state transition, "
636 "signaling back to parent process");
637 g_cond_signal (thread->cond);
640 case GST_STATE_PAUSED:
641 /* wait to be set to either the READY or PLAYING states */
642 THR_DEBUG_MAIN ("thread in %s state, waiting for either %s or %s",
643 gst_element_state_get_name (GST_STATE_PAUSED),
644 gst_element_state_get_name (GST_STATE_READY),
645 gst_element_state_get_name (GST_STATE_PLAYING));
646 g_cond_wait (thread->cond, thread->lock);
648 /* this must have happened by a state change in the thread context */
649 if (GST_STATE_PENDING (thread) != GST_STATE_READY &&
650 GST_STATE_PENDING (thread) != GST_STATE_PLAYING) {
651 g_cond_signal (thread->cond);
655 /* been signaled, we need to state transition now and signal back */
656 gst_thread_update_state (thread);
658 /* now we decide what to do next */
659 if (GST_STATE (thread) != GST_STATE_PLAYING) {
660 /* either READY or the state change failed for some reason */
661 g_cond_signal (thread->cond);
665 GST_FLAG_SET (thread, GST_THREAD_STATE_SPINNING);
666 /* PLAYING is coming up, so we can now start spinning */
667 while (GST_FLAG_IS_SET (thread, GST_THREAD_STATE_SPINNING)) {
670 g_cond_signal (thread->cond);
671 g_mutex_unlock (thread->lock);
672 status = gst_bin_iterate (GST_BIN (thread));
673 g_mutex_lock (thread->lock);
674 /* g_cond_signal(thread->cond); */
676 if (!status || GST_STATE_PENDING (thread) != GST_STATE_VOID_PENDING)
677 GST_FLAG_UNSET (thread, GST_THREAD_STATE_SPINNING);
679 /* looks like we were stopped because of a statechange */
680 if (GST_STATE_PENDING (thread) != GST_STATE_VOID_PENDING) {
681 gst_thread_update_state (thread);
683 /* once we're here, SPINNING has stopped, we should signal that we're done */
684 THR_DEBUG_MAIN ("SPINNING stopped, signaling back to parent process");
685 g_cond_signal (thread->cond);
686 /* now we can wait for PAUSED */
689 case GST_STATE_PLAYING:
690 /* wait to be set to PAUSED */
691 THR_DEBUG_MAIN ("thread in %s state, waiting for %s",
692 gst_element_state_get_name (GST_STATE_PLAYING),
693 gst_element_state_get_name (GST_STATE_PAUSED));
694 g_cond_wait (thread->cond,thread->lock);
696 /* been signaled, we need to state transition now and signal back */
697 gst_thread_update_state (thread);
698 g_cond_signal (thread->cond);
699 /* now we decide what to do next */
700 /* there's only PAUSED, we we just wait for it */
703 THR_DEBUG_MAIN ("thread in %s state, preparing to die",
704 gst_element_state_get_name (GST_STATE_NULL));
705 GST_FLAG_SET (thread, GST_THREAD_STATE_REAPING);
708 g_assert_not_reached ();
713 /* THREAD HAS STOPPED RUNNING */
715 /* we need to destroy the scheduler here because it has mapped it's
716 * stack into the threads stack space */
717 gst_scheduler_reset (GST_ELEMENT_SCHED (thread));
719 /* since we don't unlock at the end of the while loop, do it here */
720 g_mutex_unlock (thread->lock);
722 GST_INFO (GST_CAT_THREAD, "gstthread: thread \"%s\" is stopped",
723 GST_ELEMENT_NAME (thread));
725 g_signal_emit (G_OBJECT (thread), gst_thread_signals[SHUTDOWN], 0);
730 #ifndef GST_DISABLE_LOADSAVE
732 gst_thread_save_thyself (GstObject *object,
735 if (GST_OBJECT_CLASS (parent_class)->save_thyself)
736 GST_OBJECT_CLASS (parent_class)->save_thyself (object, self);
741 gst_thread_restore_thyself (GstObject *object,
744 GST_DEBUG (GST_CAT_THREAD,"gstthread: restore");
746 if (GST_OBJECT_CLASS (parent_class)->restore_thyself)
747 GST_OBJECT_CLASS (parent_class)->restore_thyself (object, self);
749 #endif /* GST_DISABLE_LOADSAVE */