diff options
-rw-r--r-- | gst/elements/gstidentity.c | 6 | ||||
-rw-r--r-- | gst/gstbin.c | 5 | ||||
-rw-r--r-- | gst/gstscheduler.c | 25 | ||||
-rw-r--r-- | gst/gstthread.c | 6 | ||||
-rw-r--r-- | plugins/elements/gstidentity.c | 6 | ||||
-rw-r--r-- | tests/threadlock.c | 10 |
6 files changed, 37 insertions, 21 deletions
diff --git a/gst/elements/gstidentity.c b/gst/elements/gstidentity.c index 4e209a1ce..a9126b671 100644 --- a/gst/elements/gstidentity.c +++ b/gst/elements/gstidentity.c @@ -108,7 +108,8 @@ gst_identity_init (GstIdentity *identity) gst_element_add_pad (GST_ELEMENT (identity), identity->srcpad); identity->loop_based = FALSE; - identity->sleep_time = 10000; +// identity->sleep_time = 10000; + identity->sleep_time = 0; } static void @@ -125,7 +126,8 @@ gst_identity_chain (GstPad *pad, GstBuffer *buf) gst_pad_push (identity->srcpad, buf); - usleep (identity->sleep_time); + if (identity->sleep_time) + usleep (identity->sleep_time); } static void diff --git a/gst/gstbin.c b/gst/gstbin.c index 22cfcdea6..33f9846c4 100644 --- a/gst/gstbin.c +++ b/gst/gstbin.c @@ -273,6 +273,7 @@ gst_bin_add (GstBin *bin, // then check to see if the element's name is already taken in the bin g_return_if_fail (gst_object_check_uniqueness (bin->children, GST_ELEMENT_NAME(element)) == TRUE); + // set the element's parent and add the element to the bin's list of children gst_object_set_parent (GST_OBJECT (element), GST_OBJECT (bin)); bin->children = g_list_append (bin->children, element); bin->numchildren++; @@ -285,10 +286,6 @@ gst_bin_add (GstBin *bin, GST_INFO_ELEMENT (GST_CAT_PARENTAGE, bin, "added child \"%s\"", GST_ELEMENT_NAME (element)); - /* we know we have at least one child, we just added one... */ -// if (GST_STATE(element) < GST_STATE_READY) -// gst_bin_change_state_norecurse(bin,GST_STATE_READY); - gtk_signal_emit (GTK_OBJECT (bin), gst_bin_signals[OBJECT_ADDED], element); } diff --git a/gst/gstscheduler.c b/gst/gstscheduler.c index e425c15a9..efd2a9494 100644 --- a/gst/gstscheduler.c +++ b/gst/gstscheduler.c @@ -775,9 +775,6 @@ void gst_bin_schedule_func(GstBin *bin) { /*************** INCREMENTAL SCHEDULING CODE STARTS HERE ***************/ -//static GstSchedule realsched; -//static GstSchedule *sched = &realsched; - static void gst_schedule_class_init (GstScheduleClass *klass); static void gst_schedule_init (GstSchedule *schedule); @@ -898,6 +895,10 @@ gst_schedule_chain_add_element (GstScheduleChain *chain, GstElement *element) { GST_INFO (GST_CAT_SCHEDULING, "adding element \"%s\" to chain", GST_ELEMENT_NAME (element)); + // set the sched pointer for the element + element->sched = chain->sched; + + // add the element to the list of 'disabled' elements chain->disabled = g_list_prepend (chain->disabled, element); chain->num_elements++; } @@ -950,6 +951,9 @@ gst_schedule_chain_remove_element (GstScheduleChain *chain, GstElement *element) // if there are no more elements in the chain, destroy the chain if (chain->num_elements == 0) gst_schedule_chain_destroy(chain); + + // unset the sched pointer for the element + element->sched = NULL; } void @@ -1128,11 +1132,19 @@ gst_schedule_add_element (GstSchedule *sched, GstElement *element) g_return_if_fail (element != NULL); g_return_if_fail (GST_IS_ELEMENT(element)); + // if it's already in this schedule, don't bother doing anything + if (GST_ELEMENT_SCHED(element) == sched) return; + GST_INFO (GST_CAT_SCHEDULING, "adding element \"%s\" to schedule", GST_ELEMENT_NAME(element)); + // if the element already has a different scheduler, remove the element from it + if (GST_ELEMENT_SCHED(element)) { + gst_schedule_remove_element(GST_ELEMENT_SCHED(element),element); + } + // set the sched pointer in the element itself - gst_element_set_sched (element, sched); + GST_ELEMENT_SCHED(element) = sched; // only deal with elements after this point, not bins if (GST_IS_BIN (element)) return; @@ -1209,9 +1221,6 @@ gst_schedule_remove_element (GstSchedule *sched, GstElement *element) // find what chain the element is in chain = gst_schedule_find_chain(sched, element); - // disable the element, i.e. remove from chain's active list - gst_schedule_chain_disable_element (chain, element); - // remove it from its chain gst_schedule_chain_remove_element (chain, element); @@ -1220,7 +1229,7 @@ gst_schedule_remove_element (GstSchedule *sched, GstElement *element) sched->num_elements--; // unset the scheduler pointer in the element - gst_element_set_sched (element, NULL); + GST_ELEMENT_SCHED(element) = NULL; } } diff --git a/gst/gstthread.c b/gst/gstthread.c index a4090ffed..7d2c541ea 100644 --- a/gst/gstthread.c +++ b/gst/gstthread.c @@ -139,9 +139,9 @@ gst_thread_init (GstThread *thread) // default is to create a thread GST_FLAG_SET (thread, GST_THREAD_CREATE); - + thread->lock = g_mutex_new(); - + thread->cond = g_cond_new(); GST_ELEMENT_SCHED(thread) = gst_schedule_new(GST_ELEMENT(thread)); @@ -407,7 +407,7 @@ gst_thread_signal_thread (GstThread *thread, gboolean spinning) { // set the spinning state if (spinning) GST_FLAG_SET(thread,GST_THREAD_STATE_SPINNING); - else GST_FLAG_SET (thread, GST_THREAD_STATE_SPINNING); + else GST_FLAG_UNSET (thread, GST_THREAD_STATE_SPINNING); GST_DEBUG (GST_CAT_THREAD, "sync-main: locking\n"); g_mutex_lock(thread->lock); diff --git a/plugins/elements/gstidentity.c b/plugins/elements/gstidentity.c index 4e209a1ce..a9126b671 100644 --- a/plugins/elements/gstidentity.c +++ b/plugins/elements/gstidentity.c @@ -108,7 +108,8 @@ gst_identity_init (GstIdentity *identity) gst_element_add_pad (GST_ELEMENT (identity), identity->srcpad); identity->loop_based = FALSE; - identity->sleep_time = 10000; +// identity->sleep_time = 10000; + identity->sleep_time = 0; } static void @@ -125,7 +126,8 @@ gst_identity_chain (GstPad *pad, GstBuffer *buf) gst_pad_push (identity->srcpad, buf); - usleep (identity->sleep_time); + if (identity->sleep_time) + usleep (identity->sleep_time); } static void diff --git a/tests/threadlock.c b/tests/threadlock.c index f6a4e0538..83b62aa6b 100644 --- a/tests/threadlock.c +++ b/tests/threadlock.c @@ -28,18 +28,24 @@ int main(int argc,char *argv[]) { fprintf(stderr,"\nSWITCHING to READY:\n"); gst_element_set_state (thread, GST_STATE_READY); + fprintf(stderr,"\nPIPELINE sched:\n"); gst_schedule_show(GST_ELEMENT_SCHED(pipeline)); + fprintf(stderr,"\nTHREAD sched:\n"); gst_schedule_show(GST_ELEMENT_SCHED(thread)); -/* fprintf(stderr,"\nSWITCHING to PLAYING:\n"); gst_element_set_state (thread, GST_STATE_PLAYING); gst_schedule_show(GST_ELEMENT_SCHED(pipeline)); gst_schedule_show(GST_ELEMENT_SCHED(thread)); +fprintf(stderr,"sleeping...\n"); +sleep(1); +fprintf(stderr,"done sleeping...\n"); + fprintf(stderr,"\nSWITCHING to READY:\n"); gst_element_set_state (thread, GST_STATE_READY); gst_schedule_show(GST_ELEMENT_SCHED(pipeline)); gst_schedule_show(GST_ELEMENT_SCHED(thread)); -*/ + +sleep(1); } |