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"
28 #include "gstthread.h"
29 #include "gstscheduler.h"
32 GstElementDetails gst_thread_details = {
35 "Container that creates/manages a thread",
37 "Erik Walthinsen <omega@cse.ogi.edu>",
42 /* Thread signals and args */
61 static void gst_thread_class_init (GstThreadClass *klass);
62 static void gst_thread_init (GstThread *thread);
64 static void gst_thread_real_destroy (GObject *object);
66 static void gst_thread_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
67 static void gst_thread_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
69 static GstElementStateReturn gst_thread_change_state (GstElement *element);
71 #ifndef GST_DISABLE_LOADSAVE
72 static xmlNodePtr gst_thread_save_thyself (GstObject *object, xmlNodePtr parent);
73 static void gst_thread_restore_thyself (GstObject *object, xmlNodePtr self);
76 static void gst_thread_signal_thread (GstThread *thread, gboolean spinning);
78 static void* gst_thread_main_loop (void *arg);
80 static GstBinClass *parent_class = NULL;
81 //static guint gst_thread_signals[LAST_SIGNAL] = { 0 };
84 gst_thread_get_type(void) {
85 static GType thread_type = 0;
88 static const GTypeInfo thread_info = {
89 sizeof(GstThreadClass),
92 (GClassInitFunc)gst_thread_class_init,
97 (GInstanceInitFunc)gst_thread_init,
99 thread_type = g_type_register_static(GST_TYPE_BIN, "GstThread", &thread_info, 0);
105 gst_thread_class_init (GstThreadClass *klass)
107 GObjectClass *gobject_class;
108 GstObjectClass *gstobject_class;
109 GstElementClass *gstelement_class;
110 GstBinClass *gstbin_class;
112 gobject_class = (GObjectClass*)klass;
113 gstobject_class = (GstObjectClass*)klass;
114 gstelement_class = (GstElementClass*)klass;
115 gstbin_class = (GstBinClass*)klass;
117 parent_class = g_type_class_ref (GST_TYPE_BIN);
119 g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_CREATE_THREAD,
120 g_param_spec_boolean("create_thread", "Create Thread", "Whether to create a thread.",
121 TRUE,G_PARAM_READWRITE));
124 // gobject_class->destroy = gst_thread_real_destroy;
126 #ifndef GST_DISABLE_LOADSAVE
127 gstobject_class->save_thyself = gst_thread_save_thyself;
128 gstobject_class->restore_thyself = gst_thread_restore_thyself;
131 gstelement_class->change_state = gst_thread_change_state;
133 // gstbin_class->schedule = gst_thread_schedule_dummy;
135 gobject_class->set_property = gst_thread_set_property;
136 gobject_class->get_property = gst_thread_get_property;
141 gst_thread_init (GstThread *thread)
144 GST_DEBUG (GST_CAT_THREAD,"initializing thread\n");
146 // we're a manager by default
147 GST_FLAG_SET (thread, GST_BIN_FLAG_MANAGER);
149 // default is to create a thread
150 GST_FLAG_SET (thread, GST_THREAD_CREATE);
152 thread->lock = g_mutex_new();
153 thread->cond = g_cond_new();
155 GST_ELEMENT_SCHED(thread) = gst_schedule_new(GST_ELEMENT(thread));
156 GST_DEBUG(GST_CAT_THREAD, "thread's scheduler is %p\n",GST_ELEMENT_SCHED(thread));
158 thread->ppid = getpid();
160 // gst_element_set_manager(GST_ELEMENT(thread),GST_ELEMENT(thread));
164 gst_thread_real_destroy (GObject *object)
166 GstThread *thread = GST_THREAD (object);
168 GST_DEBUG (GST_CAT_REFCOUNTING,"destroy()\n");
170 g_mutex_free (thread->lock);
171 g_cond_free (thread->cond);
174 // if (G_OBJECT_CLASS (parent_class)->destroy)
175 // G_OBJECT_CLASS (parent_class)->destroy (object);
177 gst_object_destroy (GST_OBJECT (GST_ELEMENT_SCHED (thread)));
178 gst_object_unref (GST_OBJECT (GST_ELEMENT_SCHED (thread)));
182 gst_thread_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
184 /* it's not null if we got it, but it might not be ours */
185 g_return_if_fail (GST_IS_THREAD (object));
188 case ARG_CREATE_THREAD:
189 if (g_value_get_boolean(value)) {
190 GST_INFO (GST_CAT_THREAD,"turning ON the creation of the thread");
191 GST_FLAG_SET (object, GST_THREAD_CREATE);
192 // GST_DEBUG (GST_CAT_THREAD,"flags are 0x%08x\n", GST_FLAGS (object));
194 GST_INFO (GST_CAT_THREAD,"gstthread: turning OFF the creation of the thread");
195 GST_FLAG_UNSET (object, GST_THREAD_CREATE);
196 // GST_DEBUG (GST_CAT_THREAD,"gstthread: flags are 0x%08x\n", GST_FLAGS (object));
200 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
206 gst_thread_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
208 /* it's not null if we got it, but it might not be ours */
209 g_return_if_fail (GST_IS_THREAD (object));
212 case ARG_CREATE_THREAD:
213 g_value_set_boolean(value, GST_FLAG_IS_SET (object, GST_THREAD_CREATE));
216 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
224 * @name: the name of the thread
226 * Create a new thread with the given name.
228 * Returns: The new thread
231 gst_thread_new (const guchar *name)
233 return gst_elementfactory_make ("thread", name);
237 #define THR_INFO(format,args...) \
238 GST_INFO_ELEMENT(GST_CAT_THREAD, thread, "sync(" GST_DEBUG_THREAD_FORMAT "): " format , \
239 GST_DEBUG_THREAD_ARGS(thread->pid) , ## args )
240 #define THR_DEBUG(format,args...) \
241 GST_DEBUG_ELEMENT(GST_CAT_THREAD, thread, "sync(" GST_DEBUG_THREAD_FORMAT "): " format , \
242 GST_DEBUG_THREAD_ARGS(thread->pid) , ## args )
244 #define THR_INFO_MAIN(format,args...) \
245 GST_INFO_ELEMENT(GST_CAT_THREAD, thread, "sync-main(" GST_DEBUG_THREAD_FORMAT "): " format , \
246 GST_DEBUG_THREAD_ARGS(thread->ppid) , ## args )
247 #define THR_DEBUG_MAIN(format,args...) \
248 GST_DEBUG_ELEMENT(GST_CAT_THREAD, thread, "sync-main(" GST_DEBUG_THREAD_FORMAT "): " format , \
249 GST_DEBUG_THREAD_ARGS(thread->ppid) , ## args )
252 static GstElementStateReturn
253 gst_thread_change_state (GstElement *element)
256 gboolean stateset = GST_STATE_SUCCESS;
258 pthread_t self = pthread_self();
259 GstElement *peerelement;
261 g_return_val_if_fail (GST_IS_THREAD(element), FALSE);
262 // GST_DEBUG_ENTER("(\"%s\")",GST_ELEMENT_NAME(element));
264 thread = GST_THREAD (element);
265 // GST_DEBUG (GST_CAT_THREAD, "**** THREAD %ld changing THREAD %ld ****\n",self,thread->thread_id);
266 // GST_DEBUG (GST_CAT_THREAD, "**** current pid=%d\n",getpid());
268 transition = GST_STATE_TRANSITION (element);
270 THR_INFO("changing state from %s to %s",
271 gst_element_statename(GST_STATE (element)),
272 gst_element_statename(GST_STATE_PENDING (element)));
274 //GST_FLAG_UNSET (thread, GST_THREAD_STATE_SPINNING);
276 switch (transition) {
277 case GST_STATE_NULL_TO_READY:
278 // set the state to idle
279 GST_FLAG_UNSET (thread, GST_THREAD_STATE_SPINNING);
280 GST_FLAG_UNSET (thread, GST_THREAD_STATE_REAPING);
282 // create the thread if that's what we're supposed to do
283 if (GST_FLAG_IS_SET (thread, GST_THREAD_CREATE)) {
284 THR_DEBUG ("creating thread \"%s\"\n",
285 GST_ELEMENT_NAME (element));
287 g_mutex_lock (thread->lock);
290 pthread_create (&thread->thread_id, NULL,
291 gst_thread_main_loop, thread);
293 // wait for it to 'spin up'
294 THR_DEBUG("waiting for child thread spinup\n");
295 g_cond_wait(thread->cond,thread->lock);
296 THR_DEBUG("thread claims to be up\n");
297 g_mutex_unlock(thread->lock);
299 GST_INFO (GST_CAT_THREAD, "NOT creating thread \"%s\"",
300 GST_ELEMENT_NAME (GST_ELEMENT (element)));
302 // punt and change state on all the children
303 if (GST_ELEMENT_CLASS (parent_class)->change_state)
304 stateset = GST_ELEMENT_CLASS (parent_class)->change_state (element);
307 case GST_STATE_READY_TO_PAUSED:
308 THR_INFO("readying thread");
310 // check to see if the thread is somehow changing its own state.
311 // FIXME this is currently illegal, but must somehow be made legal at some point.
312 if (pthread_equal(self, thread->thread_id))
314 //FIXME this should not happen
315 g_assert(!pthread_equal(self, thread->thread_id));
316 GST_FLAG_SET(thread, GST_THREAD_STATE_SPINNING);
317 GST_DEBUG(GST_CAT_THREAD,"no sync(" GST_DEBUG_THREAD_FORMAT "): setting own thread's state to spinning\n",
318 GST_DEBUG_THREAD_ARGS(thread->pid));
322 g_mutex_lock(thread->lock);
323 gst_thread_signal_thread(thread,FALSE);
326 case GST_STATE_PAUSED_TO_PLAYING:
327 THR_INFO("starting thread");
329 // check to see if the thread is somehow changing its own state.
330 // FIXME this is currently illegal, but must somehow be made legal at some point.
331 if (pthread_equal(self, thread->thread_id))
333 //FIXME this should not happen
334 g_assert(!pthread_equal(self, thread->thread_id));
335 GST_FLAG_SET(thread, GST_THREAD_STATE_SPINNING);
336 GST_DEBUG(GST_CAT_THREAD,"no sync(" GST_DEBUG_THREAD_FORMAT "): setting own thread's state to spinning\n",
337 GST_DEBUG_THREAD_ARGS(thread->pid));
341 THR_DEBUG("telling thread to start spinning\n");
342 g_mutex_lock(thread->lock);
343 gst_thread_signal_thread(thread,TRUE);
346 case GST_STATE_PLAYING_TO_PAUSED:
347 THR_INFO("pausing thread");
349 // check to see if the thread is somehow changing its own state.
350 // FIXME this is currently illegal, but must somehow be made legal at some point.
351 if (pthread_equal(self, thread->thread_id))
353 //FIXME this should not happen
354 GST_DEBUG(GST_CAT_THREAD,"no sync(" GST_DEBUG_THREAD_FORMAT "): setting own thread's state to paused\n",
355 GST_DEBUG_THREAD_ARGS(thread->pid));
356 GST_FLAG_UNSET (thread, GST_THREAD_STATE_SPINNING);
357 g_assert(!pthread_equal(self, thread->thread_id));
361 GList *elements = (element->sched)->elements;
363 // the following code ensures that the bottom half of thread will run
364 // to perform each elements' change_state() (by calling gstbin.c::
366 // + the pending state was already set by gstelement.c::set_state()
367 // + find every queue we manage, and signal its empty and full conditions
369 g_mutex_lock(thread->lock);
371 GST_FLAG_UNSET (thread, GST_THREAD_STATE_SPINNING);
375 GstElement *e = GST_ELEMENT(elements->data);
377 THR_DEBUG(" element \"%s\"\n",GST_ELEMENT_NAME(e));
378 elements = g_list_next(elements);
381 //FIXME make this more efficient by only waking queues that are asleep
382 //FIXME and only waking the appropriate condition (depending on if it's
383 //FIXME on up- or down-stream side)
385 //FIXME also make this more efficient by keeping list of managed queues
386 THR_DEBUG("waking queue \"%s\"\n",GST_ELEMENT_NAME(e));
388 g_cond_signal((GST_QUEUE(e)->emptycond));
389 g_cond_signal((GST_QUEUE(e)->fullcond));
394 GList *pads = GST_ELEMENT_PADS(e);
397 GstPad *p = GST_PAD(pads->data);
398 pads = g_list_next(pads);
400 peerelement = GST_PAD_PARENT(GST_PAD_PEER(p));
401 if (!peerelement) continue; // deal with case where there's no peer
403 if (!GST_FLAG_IS_SET(peerelement,GST_ELEMENT_DECOUPLED)) {
404 GST_DEBUG(GST_CAT_THREAD,"peer element isn't DECOUPLED\n");
408 // FIXME this needs to go away eventually
409 if (!GST_IS_QUEUE(peerelement)) {
410 GST_DEBUG(GST_CAT_THREAD,"peer element isn't a Queue\n");
414 if (GST_ELEMENT_SCHED(peerelement) != GST_ELEMENT_SCHED(thread))
416 THR_DEBUG(" element \"%s\" has pad cross sched boundary\n",GST_ELEMENT_NAME(e));
417 GST_LOCK(peerelement);
418 g_cond_signal(GST_QUEUE(peerelement)->emptycond);
419 g_cond_signal(GST_QUEUE(peerelement)->fullcond);
420 GST_UNLOCK(peerelement);
425 THR_DEBUG("waiting for thread to stop spinning\n");
426 g_cond_wait (thread->cond, thread->lock);
427 THR_DEBUG("telling thread to pause\n");
428 gst_thread_signal_thread(thread,FALSE);
431 case GST_STATE_READY_TO_NULL:
432 THR_INFO("stopping thread");
434 GST_FLAG_SET (thread, GST_THREAD_STATE_REAPING);
436 // check to see if the thread is somehow changing its own state.
437 // FIXME this is currently illegal, but must somehow be made legal at some point.
438 if (pthread_equal(self, thread->thread_id))
440 //FIXME this should not happen
441 g_assert(!pthread_equal(self, thread->thread_id));
442 THR_DEBUG("setting own thread's state to NULL (paused)\n");
443 GST_FLAG_UNSET (thread, GST_THREAD_STATE_SPINNING);
447 THR_DEBUG("telling thread to pause (null) - and joining\n");
448 //MattH FIXME revisit
449 g_mutex_lock(thread->lock);
450 gst_thread_signal_thread(thread,FALSE);
451 pthread_join(thread->thread_id,NULL);
454 GST_FLAG_UNSET(thread,GST_THREAD_STATE_REAPING);
455 GST_FLAG_UNSET(thread,GST_THREAD_STATE_STARTED);
456 GST_FLAG_UNSET(thread,GST_THREAD_STATE_SPINNING);
457 GST_FLAG_UNSET(thread,GST_THREAD_STATE_ELEMENT_CHANGED);
460 case GST_STATE_PAUSED_TO_READY:
461 THR_INFO("stopping thread");
463 // check to see if the thread is somehow changing its own state.
464 // FIXME this is currently illegal, but must somehow be made legal at some point.
465 if (pthread_equal(self, thread->thread_id))
467 //FIXME this should not happen
468 g_assert(!pthread_equal(self, thread->thread_id));
469 GST_FLAG_SET(thread, GST_THREAD_STATE_SPINNING);
470 GST_DEBUG(GST_CAT_THREAD,"no sync(" GST_DEBUG_THREAD_FORMAT "): setting own thread's state to spinning\n",
471 GST_DEBUG_THREAD_ARGS(thread->pid));
475 THR_DEBUG("telling thread to stop spinning\n");
476 g_mutex_lock(thread->lock);
477 gst_thread_signal_thread(thread,FALSE);
482 GST_DEBUG_ELEMENT(GST_CAT_THREAD, element, "UNHANDLED STATE CHANGE! %x\n",transition);
489 static void gst_thread_update_state (GstThread *thread)
491 // check for state change
492 if (GST_STATE_PENDING(thread) != GST_STATE_VOID_PENDING) {
493 // punt and change state on all the children
494 if (GST_ELEMENT_CLASS (parent_class)->change_state)
495 GST_ELEMENT_CLASS (parent_class)->change_state (GST_ELEMENT(thread));
500 * gst_thread_main_loop:
501 * @arg: the thread to start
503 * The main loop of the thread. The thread will iterate
504 * while the state is GST_THREAD_STATE_SPINNING
507 gst_thread_main_loop (void *arg)
509 GstThread *thread = GST_THREAD (arg);
512 thread->pid = getpid();
513 THR_INFO_MAIN("thread is running");
515 // first we need to change the state of all the children
516 if (GST_ELEMENT_CLASS (parent_class)->change_state)
517 stateset = GST_ELEMENT_CLASS (parent_class)->change_state (GST_ELEMENT(thread));
519 // construct the plan and signal back
520 /* DEPRACATED for INCSCHED1
521 THR_DEBUG_MAIN("creating plan for thread\n");
522 if (GST_BIN_CLASS (parent_class)->schedule)
523 GST_BIN_CLASS (parent_class)->schedule (GST_BIN (thread));
526 // THR_DEBUG_MAIN("indicating spinup\n");
527 g_mutex_lock (thread->lock);
528 g_cond_signal (thread->cond);
529 // don't unlock the mutex because we hold it into the top of the while loop
530 THR_DEBUG_MAIN("thread has indicated spinup to parent process\n");
532 /***** THREAD IS NOW IN READY STATE *****/
534 while (!GST_FLAG_IS_SET (thread, GST_THREAD_STATE_REAPING)) {
535 // NOTE we hold the thread lock at this point
536 // what we do depends on what state we're in
537 switch (GST_STATE(thread)) {
538 // NOTE: cannot be in NULL, we're not running in that state at all
539 case GST_STATE_READY:
540 // wait to be set to either the NULL or PAUSED states
541 THR_DEBUG_MAIN("thread in %s state, waiting for either %s or %s\n",
542 gst_element_statename(GST_STATE_READY),
543 gst_element_statename(GST_STATE_NULL),
544 gst_element_statename(GST_STATE_PAUSED));
545 g_cond_wait(thread->cond,thread->lock);
546 // been signaled, we need to state transition now and signal back
547 gst_thread_update_state(thread);
548 THR_DEBUG_MAIN("done with state transition, signaling back to parent process\n");
549 g_cond_signal(thread->cond);
550 // g_mutex_unlock(thread->lock);
551 // now we decide what to do next (FIXME can be collapsed to a continue)
552 if (GST_STATE(thread) == GST_STATE_NULL) {
553 // REAPING must be set, we can simply break this iteration
556 // PAUSED is the next state, we can wait for that next
560 case GST_STATE_PAUSED:
561 // wait to be set to either the READY or PLAYING states
562 THR_DEBUG_MAIN("thread in %s state, waiting for either %s or %s\n",
563 gst_element_statename(GST_STATE_PAUSED),
564 gst_element_statename(GST_STATE_READY),
565 gst_element_statename(GST_STATE_PLAYING));
566 g_cond_wait(thread->cond,thread->lock);
567 // been signaled, we need to state transition now and signal back
568 gst_thread_update_state(thread);
569 g_cond_signal(thread->cond);
570 // g_mutex_unlock(thread->lock);
571 // now we decide what to do next
572 if (GST_STATE(thread) == GST_STATE_READY) {
573 // READY is the next state, we can wait for that next
576 g_mutex_unlock(thread->lock);
577 // PLAYING is coming up, so we can now start spinning
578 while (GST_FLAG_IS_SET (thread, GST_THREAD_STATE_SPINNING)) {
579 if (!gst_bin_iterate (GST_BIN (thread))) {
580 // GST_FLAG_UNSET (thread, GST_THREAD_STATE_SPINNING);
581 // THR_DEBUG_MAIN("removed spinning state due to failed iteration!\n");
582 // FIXME FIXME FIXME this is ugly!
583 THR_DEBUG_MAIN("iteration failed, something very wrong, spinning to let parent sync\n");
584 while (GST_FLAG_IS_SET(thread, GST_THREAD_STATE_SPINNING)) ;
587 g_mutex_lock(thread->lock);
588 // once we're here, SPINNING has stopped, we should signal that we're done
589 THR_DEBUG_MAIN("SPINNING stopped, signaling back to parent process\n");
590 g_cond_signal (thread->cond);
591 // now we can wait for PAUSED
595 case GST_STATE_PLAYING:
596 // wait to be set to PAUSED
597 THR_DEBUG_MAIN("thread in %s state, waiting for %s\n",
598 gst_element_statename(GST_STATE_PLAYING),
599 gst_element_statename(GST_STATE_PAUSED));
600 g_cond_wait(thread->cond,thread->lock);
601 // been signaled, we need to state transition now and signal back
602 gst_thread_update_state(thread);
603 g_cond_signal(thread->cond);
604 // g_mutex_unlock(thread->lock);
605 // now we decide what to do next
606 // there's only PAUSED, we we just wait for it
611 // need to grab the lock so we're ready for the top of the loop
612 // g_mutex_lock(thread->lock);
616 while (!GST_FLAG_IS_SET (thread, GST_THREAD_STATE_REAPING)) {
617 // start out by waiting for a state change into spinning
618 THR_DEBUG_MAIN("waiting for signal from parent process (at top of while())\n");
619 g_cond_wait (thread->cond,thread->lock);
620 THR_DEBUG_MAIN("woken up with %s pending\n",gst_element_statename(GST_STATE(thread)));
621 // now is a good time to change the state of the children and the thread itself
622 gst_thread_update_state (thread);
623 THR_DEBUG_MAIN("done changing state, signaling back\n");
624 g_cond_signal (thread->cond);
625 g_mutex_unlock (thread->lock);
626 THR_DEBUG_MAIN("finished sycnronizing with main process\n");
628 while (GST_FLAG_IS_SET (thread, GST_THREAD_STATE_SPINNING)) {
629 if (!gst_bin_iterate (GST_BIN (thread))) {
630 GST_FLAG_UNSET (thread, GST_THREAD_STATE_SPINNING);
631 THR_DEBUG_MAIN("removed spinning state due to failed iteration!\n");
635 g_mutex_lock (thread->lock);
637 if (GST_STATE_PENDING(thread) == GST_STATE_PAUSED) {
638 // we've stopped spinning, because of PLAYING->PAUSED
639 THR_DEBUG_MAIN("SPINNING flag unset, signaling parent process we're stopped\n");
640 // we need to signal back that we've stopped spinning
641 g_cond_signal (thread->cond);
644 // THR_DEBUG_MAIN("signaling that the thread is out of the SPINNING loop\n");
645 // g_cond_signal (thread->cond);
646 // g_cond_wait (thread->cond, thread->lock);
647 // THR_DEBUG_MAIN("parent process has signaled at bottom of while\n");
648 // // now change the children's and thread's state
649 // gst_thread_update_state (thread);
650 // THR_DEBUG_MAIN("done changing state, signaling back to parent process\n");
651 // g_cond_signal (thread->cond);
652 // // don't release the mutex, we hold that into the top of the loop
653 // THR_DEBUG_MAIN("done syncing with parent process at bottom of while\n");
657 // since we don't unlock at the end of the while loop, do it here
658 g_mutex_unlock (thread->lock);
660 GST_INFO (GST_CAT_THREAD, "gstthread: thread \"%s\" is stopped",
661 GST_ELEMENT_NAME (thread));
665 // the set flag is to say whether it should set TRUE or FALSE
667 // WARNING: this has synchronization built in! if you remove or add any
668 // locks, waits, signals, or unlocks you need to be sure they match the
669 // code above (in gst_thread_main_loop()). basically, don't change anything.
671 gst_thread_signal_thread (GstThread *thread, gboolean spinning)
673 // set the spinning state
674 if (spinning) GST_FLAG_SET(thread,GST_THREAD_STATE_SPINNING);
675 else GST_FLAG_UNSET (thread, GST_THREAD_STATE_SPINNING);
677 THR_DEBUG("thread locked\n");
678 // g_mutex_lock(thread->lock);
681 // THR_DEBUG("waiting for spindown\n");
682 // g_cond_wait (thread->cond, thread->lock);
684 THR_DEBUG("signaling\n");
685 g_cond_signal (thread->cond);
686 THR_DEBUG("waiting for ack\n");
687 g_cond_wait (thread->cond,thread->lock);
688 THR_DEBUG("got ack\n");
690 THR_DEBUG("unlocking\n");
691 g_mutex_unlock(thread->lock);
692 THR_DEBUG("unlocked\n");
696 #ifndef GST_DISABLE_LOADSAVE
698 gst_thread_save_thyself (GstObject *object,
701 if (GST_OBJECT_CLASS (parent_class)->save_thyself)
702 GST_OBJECT_CLASS (parent_class)->save_thyself (object, self);
707 gst_thread_restore_thyself (GstObject *object,
710 GST_DEBUG (GST_CAT_THREAD,"gstthread: restore\n");
712 if (GST_OBJECT_CLASS (parent_class)->restore_thyself)
713 GST_OBJECT_CLASS (parent_class)->restore_thyself (object, self);
715 #endif // GST_DISABLE_LOADSAVE