Swapped PAUSED and PLAYING states, reworked thread interlocking.

Original commit message from CVS:
Swapped PAUSED and PLAYING states, reworked thread interlocking.
States are now: NULL <-> READY <-> PAUSED <-> PLAYING.

Had do update dv1394src, gst_arts, and xmmsinput, please test these out!

Cleaned up DEBUG output in several places to by much much less verbose
but still just as useful (denser).
This commit is contained in:
Erik Walthinsen 2001-05-25 17:35:47 +00:00
parent 4167e70050
commit 91afe9cd73
8 changed files with 187 additions and 90 deletions

View file

@ -354,7 +354,7 @@ gst_bin_change_state (GstElement *element)
GstElement *child;
GstElementStateReturn ret;
GST_DEBUG_ENTER("(\"%s\")",GST_ELEMENT_NAME (element));
// GST_DEBUG_ENTER("(\"%s\")",GST_ELEMENT_NAME (element));
g_return_val_if_fail (GST_IS_BIN (element), GST_STATE_FAILURE);
@ -364,7 +364,7 @@ gst_bin_change_state (GstElement *element)
// gst_element_statename (GST_STATE (element)), GST_STATE_PENDING (element),
// gst_element_statename (GST_STATE_PENDING (element)));
GST_INFO_ELEMENT (GST_CAT_STATES, element, "changing bin's state from %s to %s",
GST_INFO_ELEMENT (GST_CAT_STATES, element, "changing childrens' state from %s to %s",
gst_element_statename (GST_STATE (element)),
gst_element_statename (GST_STATE_PENDING (element)));
@ -396,7 +396,7 @@ gst_bin_change_state (GstElement *element)
children = bin->children;
while (children) {
child = GST_ELEMENT (children->data);
GST_DEBUG (GST_CAT_STATES,"setting state on '%s'\n",GST_ELEMENT_NAME (child));
// GST_DEBUG (GST_CAT_STATES,"setting state on '%s'\n",GST_ELEMENT_NAME (child));
switch (gst_element_set_state (child, GST_STATE_PENDING (element))) {
case GST_STATE_FAILURE:
GST_STATE_PENDING (element) = GST_STATE_NONE_PENDING;
@ -426,7 +426,7 @@ static GstElementStateReturn
gst_bin_change_state_norecurse (GstBin *bin)
{
if (GST_ELEMENT_CLASS (parent_class)->change_state) {
GST_DEBUG(GST_CAT_STATES, "setting bin's own state\n");
GST_DEBUG_ELEMENT (GST_CAT_STATES, bin, "setting bin's own state\n");
return GST_ELEMENT_CLASS (parent_class)->change_state (GST_ELEMENT (bin));
} else
return GST_STATE_FAILURE;

View file

@ -779,8 +779,9 @@ gst_element_set_state (GstElement *element, GstElementState state)
g_return_val_if_fail (GST_IS_ELEMENT (element), GST_STATE_FAILURE);
g_return_val_if_fail (element->sched != NULL, GST_STATE_FAILURE);
GST_DEBUG (GST_CAT_STATES,"setting element '%s' to state %s\n",GST_ELEMENT_NAME (element),
gst_element_statename(state));
GST_DEBUG_ELEMENT (GST_CAT_STATES,element, "setting state from %s to %s\n",
gst_element_statename(GST_STATE(element)),
gst_element_statename(state));
/* start with the current state */
curpending = GST_STATE(element);
@ -794,8 +795,9 @@ gst_element_set_state (GstElement *element, GstElementState state)
/* set the pending state variable */
// FIXME: should probably check to see that we don't already have one
GST_STATE_PENDING (element) = curpending;
GST_DEBUG (GST_CAT_STATES,"intermediate: setting element '%s' to state %s\n",
GST_ELEMENT_NAME (element),gst_element_statename(curpending));
if (curpending != state)
GST_DEBUG_ELEMENT (GST_CAT_STATES,element,"intermediate: setting state to %s\n",
gst_element_statename(curpending));
/* call the state change function so it can set the state */
oclass = GST_ELEMENT_CLASS (GTK_OBJECT (element)->klass);
@ -805,7 +807,7 @@ gst_element_set_state (GstElement *element, GstElementState state)
/* if that outright didn't work, we need to bail right away */
/* NOTE: this will bail on ASYNC as well! */
if (return_val == GST_STATE_FAILURE) {
GST_DEBUG (GST_CAT_STATES,"have failed change_state return from '%s'\n",GST_ELEMENT_NAME (element));
GST_DEBUG_ELEMENT (GST_CAT_STATES,element,"have failed change_state return\n");
return return_val;
}
}
@ -852,19 +854,20 @@ gst_element_change_state (GstElement *element)
g_return_val_if_fail (element != NULL, GST_STATE_FAILURE);
g_return_val_if_fail (GST_IS_ELEMENT (element), GST_STATE_FAILURE);
GST_DEBUG (GST_CAT_STATES, "default handler sets '%s' state to %s\n",
GST_ELEMENT_NAME (element), gst_element_statename(GST_STATE_PENDING(element)));
// GST_DEBUG_ELEMENT (GST_CAT_STATES, element, "default handler sets state to %s\n",
// gst_element_statename(GST_STATE_PENDING(element)));
if ((GST_STATE_TRANSITION(element) == GST_STATE_READY_TO_PLAYING) ||
(GST_STATE_TRANSITION(element) == GST_STATE_PAUSED_TO_PLAYING)) {
if (GST_STATE_TRANSITION(element) == GST_STATE_PAUSED_TO_PLAYING) {
g_return_val_if_fail(GST_ELEMENT_SCHED(element), GST_STATE_FAILURE);
if (GST_ELEMENT_PARENT(element))
fprintf(stderr,"PAUSED->PLAYING: element \"%s\" has parent \"%s\" and sched %p\n",
GST_ELEMENT_NAME(element),GST_ELEMENT_NAME(GST_ELEMENT_PARENT(element)),GST_ELEMENT_SCHED(element));
GST_SCHEDULE_ENABLE_ELEMENT (element->sched,element);
}
else if ((GST_STATE_TRANSITION(element) == GST_STATE_PLAYING_TO_READY) ||
(GST_STATE_TRANSITION(element) == GST_STATE_PLAYING_TO_PAUSED)) {
else if (GST_STATE_TRANSITION(element) == GST_STATE_PLAYING_TO_PAUSED) {
if (GST_ELEMENT_PARENT(element))
fprintf(stderr,"PLAYING->PAUSED: element \"%s\" has parent \"%s\" and sched %p\n",
GST_ELEMENT_NAME(element),GST_ELEMENT_NAME(GST_ELEMENT_PARENT(element)),GST_ELEMENT_SCHED(element));
GST_SCHEDULE_DISABLE_ELEMENT (element->sched,element);
}

View file

@ -46,8 +46,8 @@ typedef enum {
GST_STATE_NONE_PENDING = 0,
GST_STATE_NULL = (1 << 0),
GST_STATE_READY = (1 << 1),
GST_STATE_PLAYING = (1 << 2),
GST_STATE_PAUSED = (1 << 3),
GST_STATE_PAUSED = (1 << 2),
GST_STATE_PLAYING = (1 << 3),
} GstElementState;
typedef enum {
@ -65,10 +65,10 @@ typedef enum {
// Note: using 8 bit shift mostly "just because", it leaves us enough room to grow <g>
#define GST_STATE_TRANSITION(obj) ((GST_STATE(obj)<<8) | GST_STATE_PENDING(obj))
#define GST_STATE_NULL_TO_READY ((GST_STATE_NULL<<8) | GST_STATE_READY)
#define GST_STATE_READY_TO_PLAYING ((GST_STATE_READY<<8) | GST_STATE_PLAYING)
#define GST_STATE_PLAYING_TO_PAUSED ((GST_STATE_PLAYING<<8) | GST_STATE_PAUSED)
#define GST_STATE_READY_TO_PAUSED ((GST_STATE_READY<<8) | GST_STATE_PAUSED)
#define GST_STATE_PAUSED_TO_PLAYING ((GST_STATE_PAUSED<<8) | GST_STATE_PLAYING)
#define GST_STATE_PLAYING_TO_READY ((GST_STATE_PLAYING<<8) | GST_STATE_READY)
#define GST_STATE_PLAYING_TO_PAUSED ((GST_STATE_PLAYING<<8) | GST_STATE_PAUSED)
#define GST_STATE_PAUSED_TO_READY ((GST_STATE_PAUSED<<8) | GST_STATE_READY)
#define GST_STATE_READY_TO_NULL ((GST_STATE_READY<<8) | GST_STATE_NULL)
#define GST_TYPE_ELEMENT \

View file

@ -158,7 +158,11 @@ gst_default_debug_handler (gint category, gboolean incore, gchar *file, gchar *f
// if (category != GST_CAT_GST_INIT)
location = g_strdup_printf("%s:%d%s:",function,line,debug_string);
if (element && GST_IS_ELEMENT (element))
#ifdef GST_DEBUG_COLOR
elementname = g_strdup_printf (" \033[04m[%s]\033[00m", GST_OBJECT_NAME (element));
#else
elementname = g_strdup_printf (" [%s]", GST_OBJECT_NAME (element));
#endif
#ifdef GST_DEBUG_COLOR
fprintf(stderr,"DEBUG(\033[00;%dm%5d\033[00m:\033[00;%dm%2d\033[00m)\033["

View file

@ -445,8 +445,6 @@ gst_queue_change_state (GstElement *element)
// can't call this queue's _get (or whatever)
GST_LOCK (queue);
GST_DEBUG (GST_CAT_STATES,"state pending %d\n", GST_STATE_PENDING (element));
/* if going down into NULL state, clear out buffers*/
if (GST_STATE_PENDING (element) == GST_STATE_READY) {
/* otherwise (READY or higher) we need to open the file */

View file

@ -1348,7 +1348,7 @@ GST_DEBUG(GST_CAT_SCHEDULING,"there are %d elements in this chain\n",chain->num_
GST_INFO (GST_CAT_DATAFLOW,"NO ENTRY INTO CHAIN!");
}
} else {
GST_INFO (GST_CAT_DATAFLOW,"no entry into chain!");
GST_INFO (GST_CAT_DATAFLOW,"NO ENABLED ELEMENTS IN CHAIN!!");
}
/*

View file

@ -229,17 +229,17 @@ gst_thread_new (const guchar *name)
#define THR_INFO(format,args...) \
GST_INFO(GST_CAT_THREAD, "sync(" GST_DEBUG_THREAD_FORMAT "): " format , \
GST_INFO_ELEMENT(GST_CAT_THREAD, thread, "sync(" GST_DEBUG_THREAD_FORMAT "): " format , \
GST_DEBUG_THREAD_ARGS(thread->pid) , ## args )
#define THR_DEBUG(format,args...) \
GST_DEBUG(GST_CAT_THREAD, "sync(" GST_DEBUG_THREAD_FORMAT "): " format , \
GST_DEBUG_ELEMENT(GST_CAT_THREAD, thread, "sync(" GST_DEBUG_THREAD_FORMAT "): " format , \
GST_DEBUG_THREAD_ARGS(thread->pid) , ## args )
#define THR_INFO_MAIN(format,args...) \
GST_INFO(GST_CAT_THREAD, "sync-main(" GST_DEBUG_THREAD_FORMAT "): " format , \
GST_INFO_ELEMENT(GST_CAT_THREAD, thread, "sync-main(" GST_DEBUG_THREAD_FORMAT "): " format , \
GST_DEBUG_THREAD_ARGS(thread->ppid) , ## args )
#define THR_DEBUG_MAIN(format,args...) \
GST_DEBUG(GST_CAT_THREAD, "sync-main(" GST_DEBUG_THREAD_FORMAT "): " format , \
GST_DEBUG_ELEMENT(GST_CAT_THREAD, thread, "sync-main(" GST_DEBUG_THREAD_FORMAT "): " format , \
GST_DEBUG_THREAD_ARGS(thread->ppid) , ## args )
@ -261,8 +261,7 @@ gst_thread_change_state (GstElement *element)
transition = GST_STATE_TRANSITION (element);
THR_INFO("thread \"%s\" changing state from %s to %s",
GST_ELEMENT_NAME (GST_ELEMENT (element)),
THR_INFO("changing state from %s to %s",
gst_element_statename(GST_STATE (element)),
gst_element_statename(GST_STATE_PENDING (element)));
@ -270,17 +269,14 @@ gst_thread_change_state (GstElement *element)
switch (transition) {
case GST_STATE_NULL_TO_READY:
// we want to prepare our internal state for doing the iterations
GST_INFO (GST_CAT_THREAD, "preparing thread \"%s\" for iterations:",
GST_ELEMENT_NAME (GST_ELEMENT (element)));
// set the state to idle
GST_FLAG_UNSET (thread, GST_THREAD_STATE_SPINNING);
// create the thread if that's what we're supposed to do
GST_FLAG_UNSET (thread, GST_THREAD_STATE_REAPING);
// create the thread if that's what we're supposed to do
if (GST_FLAG_IS_SET (thread, GST_THREAD_CREATE)) {
GST_DEBUG (GST_CAT_THREAD, "creating thread \"%s\"\n",
GST_ELEMENT_NAME (GST_ELEMENT (element)));
THR_DEBUG ("creating thread \"%s\"\n",
GST_ELEMENT_NAME (element));
g_mutex_lock (thread->lock);
@ -294,7 +290,7 @@ gst_thread_change_state (GstElement *element)
THR_DEBUG("thread claims to be up\n");
g_mutex_unlock(thread->lock);
} else {
GST_INFO (GST_CAT_THREAD, "NOT starting thread \"%s\"",
GST_INFO (GST_CAT_THREAD, "NOT creating thread \"%s\"",
GST_ELEMENT_NAME (GST_ELEMENT (element)));
// punt and change state on all the children
@ -302,11 +298,30 @@ gst_thread_change_state (GstElement *element)
stateset = GST_ELEMENT_CLASS (parent_class)->change_state (element);
}
break;
case GST_STATE_PAUSED_TO_PLAYING:
case GST_STATE_READY_TO_PLAYING:
// if (!stateset) return FALSE;
THR_INFO("starting thread \"%s\"",GST_ELEMENT_NAME(element));
case GST_STATE_READY_TO_PAUSED:
THR_INFO("readying 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
{
g_mutex_lock(thread->lock);
gst_thread_signal_thread(thread,FALSE);
}
break;
case GST_STATE_PAUSED_TO_PLAYING:
THR_INFO("starting 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
@ -323,9 +338,10 @@ gst_thread_change_state (GstElement *element)
}
break;
case GST_STATE_PLAYING_TO_PAUSED:
THR_INFO("pausing thread \"%s\"",GST_ELEMENT_NAME(element));
THR_INFO("pausing 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
@ -343,7 +359,9 @@ gst_thread_change_state (GstElement *element)
// change_state()).
// + the pending state was already set by gstelement.c::set_state()
// + find every queue we manage, and signal its empty and full conditions
g_mutex_lock(thread->lock);
while (elements)
{
GstElement *e = GST_ELEMENT(elements->data);
@ -386,12 +404,8 @@ gst_thread_change_state (GstElement *element)
}
if (GST_ELEMENT_SCHED(peerelement) != GST_ELEMENT_SCHED(thread))
// GST_ELEMENT_SCHED(e) != GST_ELEMENT_SCHED(GST_ELEMENT(GST_PAD_PARENT(GST_PAD_PEER(p)))))
{
THR_DEBUG(" element \"%s\" has pad cross sched boundary\n",GST_ELEMENT_NAME(e));
// FIXME i assume this signals our own (current) thread so don't need to lock
// FIXME however, this *may* go to yet another thread for which we need locks
// FIXME i'm too tired to deal with this now
GST_LOCK(peerelement);
g_cond_signal(GST_QUEUE(peerelement)->emptycond);
g_cond_signal(GST_QUEUE(peerelement)->fullcond);
@ -400,31 +414,19 @@ gst_thread_change_state (GstElement *element)
}
}
}
THR_INFO("telling thread to pause");
gst_thread_signal_thread(thread,FALSE);
}
break;
case GST_STATE_PLAYING_TO_READY:
if (pthread_equal(self, thread->thread_id))
{
//FIXME this should not happen
g_assert(!pthread_equal(self, thread->thread_id));
GST_DEBUG(GST_CAT_THREAD,"no sync(" GST_DEBUG_THREAD_FORMAT "): setting own thread's state to ready (paused)\n",
GST_DEBUG_THREAD_ARGS(thread->pid));
GST_FLAG_UNSET (thread, GST_THREAD_STATE_SPINNING);
}
else
{
// FIXME FIXME we need to interrupt, or reorder the states!
THR_DEBUG("telling thread to pause (ready)\n");
g_mutex_lock(thread->lock);
THR_DEBUG("waiting for thread to stop spinning\n");
g_cond_wait (thread->cond, thread->lock);
THR_DEBUG("telling thread to pause\n");
gst_thread_signal_thread(thread,FALSE);
}
break;
case GST_STATE_READY_TO_NULL:
THR_INFO("stopping thread \"%s\"",GST_ELEMENT_NAME(element));
THR_INFO("stopping thread");
GST_FLAG_SET (thread, GST_THREAD_STATE_REAPING);
// 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
@ -481,35 +483,117 @@ gst_thread_main_loop (void *arg)
gint stateset;
thread->pid = getpid();
THR_INFO_MAIN("thread \"%s\" is running",GST_ELEMENT_NAME (GST_ELEMENT (thread)));
THR_INFO_MAIN("thread is running");
// first we need to change the state of all the children
THR_DEBUG_MAIN("thread started, setting children's state\n");
if (GST_ELEMENT_CLASS (parent_class)->change_state)
stateset = GST_ELEMENT_CLASS (parent_class)->change_state (GST_ELEMENT(thread));
// construct the plan and signal back
/* DEPRACATED for INCSCHED1
THR_DEBUG_MAIN("creating plan for thread\n");
if (GST_BIN_CLASS (parent_class)->schedule)
GST_BIN_CLASS (parent_class)->schedule (GST_BIN (thread));
*/
THR_DEBUG_MAIN("indicating spinup\n");
// THR_DEBUG_MAIN("indicating spinup\n");
g_mutex_lock (thread->lock);
g_cond_signal (thread->cond);
// don't unlock the mutex because we hold it into the top of the while loop
THR_DEBUG_MAIN("thread has indicated spinup to parent process\n");
/***** THREAD IS NOW IN READY STATE *****/
while (!GST_FLAG_IS_SET (thread, GST_THREAD_STATE_REAPING)) {
// NOTE we hold the thread lock at this point
// what we do depends on what state we're in
switch (GST_STATE(thread)) {
// NOTE: cannot be in NULL, we're not running in that state at all
case GST_STATE_READY:
// wait to be set to either the NULL or PAUSED states
THR_DEBUG_MAIN("thread in %s state, waiting for either %s or %s\n",
gst_element_statename(GST_STATE_READY),
gst_element_statename(GST_STATE_NULL),
gst_element_statename(GST_STATE_PAUSED));
g_cond_wait(thread->cond,thread->lock);
// been signaled, we need to state transition now and signal back
gst_thread_update_state(thread);
THR_DEBUG_MAIN("done with state transition, signaling back to parent process\n");
g_cond_signal(thread->cond);
// g_mutex_unlock(thread->lock);
// now we decide what to do next (FIXME can be collapsed to a continue)
if (GST_STATE(thread) == GST_STATE_NULL) {
// REAPING must be set, we can simply break this iteration
continue;
} else {
// PAUSED is the next state, we can wait for that next
continue;
}
break;
case GST_STATE_PAUSED:
// wait to be set to either the READY or PLAYING states
THR_DEBUG_MAIN("thread in %s state, waiting for either %s or %s\n",
gst_element_statename(GST_STATE_PAUSED),
gst_element_statename(GST_STATE_READY),
gst_element_statename(GST_STATE_PLAYING));
g_cond_wait(thread->cond,thread->lock);
// been signaled, we need to state transition now and signal back
gst_thread_update_state(thread);
g_cond_signal(thread->cond);
// g_mutex_unlock(thread->lock);
// now we decide what to do next
if (GST_STATE(thread) == GST_STATE_READY) {
// READY is the next state, we can wait for that next
continue;
} else {
g_mutex_unlock(thread->lock);
// PLAYING is coming up, so we can now start spinning
while (GST_FLAG_IS_SET (thread, GST_THREAD_STATE_SPINNING)) {
if (!gst_bin_iterate (GST_BIN (thread))) {
GST_FLAG_UNSET (thread, GST_THREAD_STATE_SPINNING);
THR_DEBUG_MAIN("removed spinning state due to failed iteration!\n");
}
}
g_mutex_lock(thread->lock);
// once we're here, SPINNING has stopped, we should signal that we're done
THR_DEBUG_MAIN("SPINNING stopped, signaling back to parent process\n");
g_cond_signal (thread->cond);
// now we can wait for PAUSED
continue;
}
break;
case GST_STATE_PLAYING:
// wait to be set to PAUSED
THR_DEBUG_MAIN("thread in %s state, waiting for %s\n",
gst_element_statename(GST_STATE_PLAYING),
gst_element_statename(GST_STATE_PAUSED));
g_cond_wait(thread->cond,thread->lock);
// been signaled, we need to state transition now and signal back
gst_thread_update_state(thread);
g_cond_signal(thread->cond);
// g_mutex_unlock(thread->lock);
// now we decide what to do next
// there's only PAUSED, we we just wait for it
continue;
break;
}
// need to grab the lock so we're ready for the top of the loop
// g_mutex_lock(thread->lock);
}
/*
while (!GST_FLAG_IS_SET (thread, GST_THREAD_STATE_REAPING)) {
// start out by waiting for a state change into spinning
THR_DEBUG_MAIN("waiting at top of while for signal from parent process\n");
THR_DEBUG_MAIN("waiting for signal from parent process (at top of while())\n");
g_cond_wait (thread->cond,thread->lock);
THR_DEBUG_MAIN("parent thread has signaled back at top of while\n");
THR_DEBUG_MAIN("woken up with %s pending\n",gst_element_statename(GST_STATE(thread)));
// now is a good time to change the state of the children and the thread itself
gst_thread_update_state (thread);
THR_DEBUG_MAIN("done changing state, signaling back to parent process\n");
THR_DEBUG_MAIN("done changing state, signaling back\n");
g_cond_signal (thread->cond);
g_mutex_unlock (thread->lock);
THR_DEBUG_MAIN("done syncing with parent process at top of while\n");
THR_DEBUG_MAIN("finished sycnronizing with main process\n");
while (GST_FLAG_IS_SET (thread, GST_THREAD_STATE_SPINNING)) {
if (!gst_bin_iterate (GST_BIN (thread))) {
@ -517,19 +601,28 @@ gst_thread_main_loop (void *arg)
THR_DEBUG_MAIN("removed spinning state due to failed iteration!\n");
}
}
THR_DEBUG_MAIN("waiting at bottom of while for signal from parent process\n");
g_mutex_lock (thread->lock);
THR_DEBUG_MAIN("signaling that the thread is out of the SPINNING loop\n");
g_cond_signal (thread->cond);
g_cond_wait (thread->cond, thread->lock);
THR_DEBUG_MAIN("parent process has signaled at bottom of while\n");
// now change the children's and thread's state
gst_thread_update_state (thread);
THR_DEBUG_MAIN("done changing state, signaling back to parent process\n");
g_cond_signal (thread->cond);
// don't release the mutex, we hold that into the top of the loop
THR_DEBUG_MAIN("done syncing with parent process at bottom of while\n");
if (GST_STATE_PENDING(thread) == GST_STATE_PAUSED) {
// we've stopped spinning, because of PLAYING->PAUSED
THR_DEBUG_MAIN("SPINNING flag unset, signaling parent process we're stopped\n");
// we need to signal back that we've stopped spinning
g_cond_signal (thread->cond);
}
// THR_DEBUG_MAIN("signaling that the thread is out of the SPINNING loop\n");
// g_cond_signal (thread->cond);
// g_cond_wait (thread->cond, thread->lock);
// THR_DEBUG_MAIN("parent process has signaled at bottom of while\n");
// // now change the children's and thread's state
// gst_thread_update_state (thread);
// THR_DEBUG_MAIN("done changing state, signaling back to parent process\n");
// g_cond_signal (thread->cond);
// // don't release the mutex, we hold that into the top of the loop
// THR_DEBUG_MAIN("done syncing with parent process at bottom of while\n");
}
*/
// since we don't unlock at the end of the while loop, do it here
g_mutex_unlock (thread->lock);
@ -554,14 +647,15 @@ gst_thread_signal_thread (GstThread *thread, gboolean spinning)
THR_DEBUG("thread locked\n");
// g_mutex_lock(thread->lock);
if (!spinning) {
THR_DEBUG("waiting for spindown\n");
g_cond_wait (thread->cond, thread->lock);
}
// if (!spinning) {
// THR_DEBUG("waiting for spindown\n");
// g_cond_wait (thread->cond, thread->lock);
// }
THR_DEBUG("signaling\n");
g_cond_signal (thread->cond);
THR_DEBUG("waiting for ack\n");
g_cond_wait (thread->cond,thread->lock);
THR_DEBUG("got ack\n");
THR_DEBUG("unlocking\n");
g_mutex_unlock(thread->lock);

View file

@ -445,8 +445,6 @@ gst_queue_change_state (GstElement *element)
// can't call this queue's _get (or whatever)
GST_LOCK (queue);
GST_DEBUG (GST_CAT_STATES,"state pending %d\n", GST_STATE_PENDING (element));
/* if going down into NULL state, clear out buffers*/
if (GST_STATE_PENDING (element) == GST_STATE_READY) {
/* otherwise (READY or higher) we need to open the file */