From: Wim T. <wt...@us...> - 2002-02-23 13:43:03
|
CVS Root: /cvsroot/gstreamer Module: gstreamer Changes by: wtay Date: Sat Feb 23 2002 05:43:03 PST Log message: Store the element in the cothread private field. If we remove the current entry in the cothread chain, make sure another cothread is marked as COTHREAD_STOPPING. Modified files: gst/schedulers : gstbasicscheduler.c Links: http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/gst/schedulers/gstbasicscheduler.c.diff?r1=1.18&r2=1.19 ====Begin Diffs==== Index: gstbasicscheduler.c =================================================================== RCS file: /cvsroot/gstreamer/gstreamer/gst/schedulers/gstbasicscheduler.c,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- gstbasicscheduler.c 11 Feb 2002 01:38:55 -0000 1.18 +++ gstbasicscheduler.c 23 Feb 2002 13:42:51 -0000 1.19 @@ -578,6 +578,7 @@ if (wrapper_function != NULL) { if (GST_ELEMENT_THREADSTATE (element) == NULL) { GST_ELEMENT_THREADSTATE (element) = cothread_create (GST_BIN_THREADCONTEXT (bin)); + cothread_set_private (GST_ELEMENT_THREADSTATE (element), element); if (GST_ELEMENT_THREADSTATE (element) == NULL) { gst_element_error (element, "could not create cothread for \"%s\"", GST_ELEMENT_NAME (element), NULL); @@ -1004,6 +1005,19 @@ /* find what chain the element is in */ chain = gst_basic_scheduler_find_chain (bsched, element); + if (GST_ELEMENT_IS_COTHREAD_STOPPING (element)) { + GstElement *entry = GST_ELEMENT (cothread_get_private (cothread_current ())); + + if (entry == element) { + g_warning ("removing currently running element! %s", GST_ELEMENT_NAME (entry)); + } + else if (entry) { + GST_INFO (GST_CAT_SCHEDULING, "moving stopping to element \"%s\"", + GST_ELEMENT_NAME (entry)); + GST_FLAG_SET (entry, GST_ELEMENT_COTHREAD_STOPPING); + } + } + /* remove it from its chain */ gst_basic_scheduler_chain_remove_element (chain, element); |
From: Wim T. <wt...@us...> - 2002-05-09 15:16:02
|
CVS Root: /cvsroot/gstreamer Module: gstreamer Changes by: wtay Date: Thu May 09 2002 08:16:01 PDT Log message: Unconnected pad errors are detected elsewhere ERROR has higher priority than CHANGED. Modified files: gst/schedulers : gstbasicscheduler.c Links: http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/gst/schedulers/gstbasicscheduler.c.diff?r1=1.26&r2=1.27 ====Begin Diffs==== Index: gstbasicscheduler.c =================================================================== RCS file: /cvsroot/gstreamer/gstreamer/gst/schedulers/gstbasicscheduler.c,v retrieving revision 1.26 retrieving revision 1.27 diff -u -d -r1.26 -r1.27 --- gstbasicscheduler.c 8 May 2002 20:40:47 -0000 1.26 +++ gstbasicscheduler.c 9 May 2002 15:15:49 -0000 1.27 @@ -285,10 +285,12 @@ GST_DEBUG (GST_CAT_DATAFLOW, "calling chain function of element %s done", name); } } + /* else { gst_element_error (element, "NULL buffer detected. Is \"%s:%s\" connected?", name, GST_PAD_NAME (pad), NULL); } + */ } } } while (!GST_ELEMENT_IS_COTHREAD_STOPPING (element)); @@ -1265,16 +1267,16 @@ GST_ELEMENT_NAME (entry), entry); if (GST_ELEMENT_THREADSTATE (entry)) { do_cothread_switch (GST_ELEMENT_THREADSTATE (entry)); + state = GST_SCHEDULER_STATE (sched); /* if something changed, return - go on else */ - if (GST_FLAG_IS_SET(bsched, GST_BASIC_SCHEDULER_CHANGE)) + if (GST_FLAG_IS_SET(bsched, GST_BASIC_SCHEDULER_CHANGE) && + state != GST_SCHEDULER_STATE_ERROR) return GST_SCHEDULER_STATE_RUNNING; } else { GST_DEBUG (GST_CAT_DATAFLOW, "cothread switch not possible, element has no threadstate"); return GST_SCHEDULER_STATE_ERROR; } - - state = GST_SCHEDULER_STATE (sched); /* following is a check to see if the chain was interrupted due to a * top-half state_change(). (i.e., if there's a pending state.) |
From: Wim T. <wt...@us...> - 2002-05-29 15:09:50
|
CVS Root: /cvsroot/gstreamer Module: gstreamer Changes by: wtay Date: Wed May 29 2002 08:09:48 PDT Log message: Handle the case where the pad change mid-switch. Handle the case where the entry poin is removed from the scheduler. Modified files: gst/schedulers : gstbasicscheduler.c Links: http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/gst/schedulers/gstbasicscheduler.c.diff?r1=1.31&r2=1.32 ====Begin Diffs==== Index: gstbasicscheduler.c =================================================================== RCS file: /cvsroot/gstreamer/gstreamer/gst/schedulers/gstbasicscheduler.c,v retrieving revision 1.31 retrieving revision 1.32 diff -u -d -r1.31 -r1.32 --- gstbasicscheduler.c 27 May 2002 04:48:57 -0000 1.31 +++ gstbasicscheduler.c 29 May 2002 15:09:36 -0000 1.32 @@ -300,13 +300,13 @@ } } while (!GST_ELEMENT_IS_COTHREAD_STOPPING (element)); GST_FLAG_UNSET (element, GST_ELEMENT_COTHREAD_STOPPING); - gst_object_unref (GST_OBJECT (element)); /* this will return to cothread 0, so we need to unlock the current element */ if (element->post_run_func) element->post_run_func (element); GST_DEBUG_LEAVE ("(%d,'%s')", argc, name); + gst_object_unref (GST_OBJECT (element)); return 0; } @@ -381,6 +381,8 @@ GST_DEBUG (GST_CAT_DATAFLOW, "new pad in mid-switch!"); pad = (GstPad *) GST_RPAD_PEER (peer); } + parent = GST_PAD_PARENT (pad); + peer = GST_RPAD_PEER (pad); } if (loop_count == 0) { @@ -432,14 +434,15 @@ GstElement *parent; GstRealPad *peer; + GST_DEBUG_ENTER ("(%s:%s)", GST_DEBUG_PAD_NAME (pad)); + parent = GST_PAD_PARENT (pad); peer = GST_RPAD_PEER (pad); - GST_DEBUG_ENTER ("(%s:%s)", GST_DEBUG_PAD_NAME (pad)); - /* FIXME this should be bounded */ /* we will loop switching to the peer until it's filled up the bufferpen */ while (GST_RPAD_BUFPEN (pad) == NULL) { + GST_DEBUG (GST_CAT_DATAFLOW, "switching to \"%s\": %p to fill bufpen", GST_ELEMENT_NAME (parent), GST_ELEMENT_THREADSTATE (parent)); @@ -453,6 +456,8 @@ if (!pad) { gst_element_error (parent, "pad unconnected"); } + parent = GST_PAD_PARENT (pad); + peer = GST_RPAD_PEER (pad); } } GST_DEBUG (GST_CAT_DATAFLOW, "done switching"); @@ -962,6 +967,13 @@ GST_INFO (GST_CAT_SCHEDULING, "removing element \"%s\" from scheduler", GST_ELEMENT_NAME (element)); + /* if we are removing the currently scheduled element */ + if (bsched->current == element) { + GST_FLAG_SET(element, GST_ELEMENT_COTHREAD_STOPPING); + if (element->post_run_func) + element->post_run_func (element); + bsched->current = NULL; + } /* find what chain the element is in */ chain = gst_basic_scheduler_find_chain (bsched, element); @@ -974,7 +986,6 @@ /* unset the scheduler pointer in the element */ GST_ELEMENT_SCHED (element) = NULL; - } } @@ -1265,8 +1276,15 @@ entry->pre_run_func (entry); bsched->current = entry; + do_cothread_switch (GST_ELEMENT_THREADSTATE (entry)); + /* + if (bsched->current && bsched->current->post_run_func) { + bsched->current->post_run_func (bsched->current); + } + */ + state = GST_SCHEDULER_STATE (sched); /* if something changed, return - go on else */ if (GST_FLAG_IS_SET(bsched, GST_BASIC_SCHEDULER_CHANGE) && |
From: Wim T. <wt...@us...> - 2002-06-02 11:21:52
|
CVS Root: /cvsroot/gstreamer Module: gstreamer Changes by: wtay Date: Sun Jun 02 2002 04:21:47 PDT Log message: This is needed after all.. Modified files: gst/schedulers : gstbasicscheduler.c Links: http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/gst/schedulers/gstbasicscheduler.c.diff?r1=1.33&r2=1.34 ====Begin Diffs==== Index: gstbasicscheduler.c =================================================================== RCS file: /cvsroot/gstreamer/gstreamer/gst/schedulers/gstbasicscheduler.c,v retrieving revision 1.33 retrieving revision 1.34 diff -u -d -r1.33 -r1.34 --- gstbasicscheduler.c 29 May 2002 15:33:46 -0000 1.33 +++ gstbasicscheduler.c 2 Jun 2002 11:21:35 -0000 1.34 @@ -1276,11 +1276,9 @@ do_cothread_switch (GST_ELEMENT_THREADSTATE (entry)); - /* if (bsched->current && bsched->current->post_run_func) { bsched->current->post_run_func (bsched->current); } - */ state = GST_SCHEDULER_STATE (sched); /* if something changed, return - go on else */ |
From: Wim T. <wt...@us...> - 2002-06-02 17:44:33
|
CVS Root: /cvsroot/gstreamer Module: gstreamer Changes by: wtay Date: Sun Jun 02 2002 10:44:32 PDT Log message: Some sanity checking for when the element was removed from the pipeline. Modified files: gst/schedulers : gstbasicscheduler.c Links: http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/gst/schedulers/gstbasicscheduler.c.diff?r1=1.35&r2=1.36 ====Begin Diffs==== Index: gstbasicscheduler.c =================================================================== RCS file: /cvsroot/gstreamer/gstreamer/gst/schedulers/gstbasicscheduler.c,v retrieving revision 1.35 retrieving revision 1.36 diff -u -d -r1.35 -r1.36 --- gstbasicscheduler.c 2 Jun 2002 16:20:09 -0000 1.35 +++ gstbasicscheduler.c 2 Jun 2002 17:44:20 -0000 1.36 @@ -324,9 +324,12 @@ /* due to oddities in the cothreads code, when this function returns it will * switch to the main cothread. thus, we need to unlock the current element. */ - if (SCHED (element)->current->post_run_func) - SCHED (element)->current->post_run_func (SCHED (element)->current); - SCHED (element)->current = NULL; + if (SCHED (element)) { + if (SCHED (element)->current && SCHED (element)->current->post_run_func) { + SCHED (element)->current->post_run_func (SCHED (element)->current); + } + SCHED (element)->current = NULL; + } GST_DEBUG_LEAVE ("(%d,'%s')", argc, name); gst_object_unref (GST_OBJECT (element)); |
From: Wim T. <wt...@us...> - 2002-06-04 21:03:48
|
CVS Root: /cvsroot/gstreamer Module: gstreamer Changes by: wtay Date: Tue Jun 04 2002 14:03:48 PDT Log message: Some cleanups, refactor some code, make sure the decoupled peer element has the right handlers Modified files: gst/schedulers : gstbasicscheduler.c Links: http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/gst/schedulers/gstbasicscheduler.c.diff?r1=1.36&r2=1.37 ====Begin Diffs==== Index: gstbasicscheduler.c =================================================================== RCS file: /cvsroot/gstreamer/gstreamer/gst/schedulers/gstbasicscheduler.c,v retrieving revision 1.36 retrieving revision 1.37 diff -u -d -r1.36 -r1.37 --- gstbasicscheduler.c 2 Jun 2002 17:44:20 -0000 1.36 +++ gstbasicscheduler.c 4 Jun 2002 21:03:35 -0000 1.37 @@ -559,19 +559,42 @@ continue; peerpad = GST_PAD_PEER (pad); + if (peerpad) { + GstElement *peerelement = GST_ELEMENT_CAST (GST_PAD_PARENT (peerpad)); + gboolean different_sched = (peerelement->sched != GST_SCHEDULER (chain->sched)); + gboolean peer_decoupled = GST_FLAG_IS_SET (peerelement, GST_ELEMENT_DECOUPLED); - /* if the element is DECOUPLED or outside the manager, we have to chain */ - if ((wrapper_function == NULL) || - (peerpad && (GST_ELEMENT_CAST (GST_PAD_PARENT (peerpad))->sched != GST_SCHEDULER (chain->sched)))) { + GST_DEBUG (GST_CAT_SCHEDULING, "inspecting pad %s:%s", GST_DEBUG_PAD_NAME (peerpad)); - if (!decoupled && GST_RPAD_PEER (pad) && - !GST_FLAG_IS_SET (GST_PAD_PARENT (peerpad), GST_ELEMENT_DECOUPLED)) { - /* whoa non decoupled with different schedulers */ - gst_element_error (element, "element \"%s\" is not decoupled but has pads in different schedulers", + /* we don't need to check this for decoupled elements */ + if (!decoupled) { + /* if the peer element is in another schedule, it's not decoupled and we are not decoupled + * either, we have an error */ + if (different_sched && !peer_decoupled) + { + gst_element_error (element, "element \"%s\" is not decoupled but has pads in different schedulers", GST_ELEMENT_NAME (element), NULL); - return FALSE; + return FALSE; + } + /* ok, the peer is in a different scheduler and is decoupled, we need to set the + * handlers so we can talk with it */ + else if (different_sched) { + if (GST_RPAD_DIRECTION (peerpad) == GST_PAD_SINK) { + GST_DEBUG (GST_CAT_SCHEDULING, "copying chain function into push proxy for peer %s:%s", + GST_DEBUG_PAD_NAME (peerpad)); + GST_RPAD_CHAINHANDLER (peerpad) = GST_RPAD_CHAINFUNC (peerpad); + } + else { + GST_DEBUG (GST_CAT_SCHEDULING, "copying get function into pull proxy for peer %s:%s", + GST_DEBUG_PAD_NAME (peerpad)); + GST_RPAD_GETHANDLER (peerpad) = GST_RPAD_GETFUNC (peerpad); + } + } } - + } + + /* if the element is DECOUPLED or outside the manager, we have to chain */ + if (decoupled) { /* set the chain proxies */ if (GST_RPAD_DIRECTION (pad) == GST_PAD_SINK) { GST_DEBUG (GST_CAT_SCHEDULING, "copying chain function into push proxy for %s:%s", @@ -583,11 +606,10 @@ GST_DEBUG_PAD_NAME (pad)); GST_RPAD_GETHANDLER (pad) = GST_RPAD_GETFUNC (pad); } - } /* otherwise we really are a cothread */ else { - if (gst_pad_get_direction (pad) == GST_PAD_SINK) { + if (GST_RPAD_DIRECTION (pad) == GST_PAD_SINK) { GST_DEBUG (GST_CAT_SCHEDULING, "setting cothreaded push proxy for sinkpad %s:%s", GST_DEBUG_PAD_NAME (pad)); GST_RPAD_CHAINHANDLER (pad) = GST_DEBUG_FUNCPTR (gst_basic_scheduler_chainhandler_proxy); |
From: Wim T. <wt...@us...> - 2002-06-04 23:00:49
|
CVS Root: /cvsroot/gstreamer Module: gstreamer Changes by: wtay Date: Tue Jun 04 2002 16:00:49 PDT Log message: Some sanity checking emit a warning when interrupting a queue bacause we do it wrongly Modified files: gst/schedulers : gstbasicscheduler.c Links: http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/gst/schedulers/gstbasicscheduler.c.diff?r1=1.37&r2=1.38 ====Begin Diffs==== Index: gstbasicscheduler.c =================================================================== RCS file: /cvsroot/gstreamer/gstreamer/gst/schedulers/gstbasicscheduler.c,v retrieving revision 1.37 retrieving revision 1.38 diff -u -d -r1.37 -r1.38 --- gstbasicscheduler.c 4 Jun 2002 21:03:35 -0000 1.37 +++ gstbasicscheduler.c 4 Jun 2002 23:00:36 -0000 1.38 @@ -131,7 +131,7 @@ #define do_element_switch(element) G_STMT_START{ \ GstElement *from = SCHED (element)->current; \ - if (from->post_run_func) \ + if (from && from->post_run_func) \ from->post_run_func (from); \ SCHED (element)->current = element; \ if (element->pre_run_func) \ @@ -141,7 +141,7 @@ #define do_switch_to_main(sched) G_STMT_START{ \ GstElement *current = ((GstBasicScheduler*)sched)->current; \ - if (current->post_run_func) \ + if (current && current->post_run_func) \ current->post_run_func (current); \ SCHED (current)->current = NULL; \ do_cothread_switch \ @@ -1114,8 +1114,12 @@ static gboolean gst_basic_scheduler_interrupt (GstScheduler *sched, GstElement *element) { - GST_FLAG_SET (element, GST_ELEMENT_COTHREAD_STOPPING); + if (GST_FLAG_IS_SET (element, GST_ELEMENT_DECOUPLED)) { + g_warning ("interrupt decoupled element"); + } + + GST_FLAG_SET (element, GST_ELEMENT_COTHREAD_STOPPING); do_switch_to_main (sched); return FALSE; |
From: Wim T. <wt...@us...> - 2002-06-05 18:11:08
|
CVS Root: /cvsroot/gstreamer Module: gstreamer Changes by: wtay Date: Wed Jun 05 2002 11:11:07 PDT Log message: Set the right scheduler on the pads of decoupled elements. Modified files: gst/schedulers : gstbasicscheduler.c Links: http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/gst/schedulers/gstbasicscheduler.c.diff?r1=1.38&r2=1.39 ====Begin Diffs==== Index: gstbasicscheduler.c =================================================================== RCS file: /cvsroot/gstreamer/gstreamer/gst/schedulers/gstbasicscheduler.c,v retrieving revision 1.38 retrieving revision 1.39 diff -u -d -r1.38 -r1.39 --- gstbasicscheduler.c 4 Jun 2002 23:00:36 -0000 1.38 +++ gstbasicscheduler.c 5 Jun 2002 18:10:55 -0000 1.39 @@ -589,6 +589,7 @@ GST_DEBUG_PAD_NAME (peerpad)); GST_RPAD_GETHANDLER (peerpad) = GST_RPAD_GETFUNC (peerpad); } + gst_pad_set_scheduler (peerpad, GST_SCHEDULER (chain->sched)); } } } @@ -1114,10 +1115,6 @@ static gboolean gst_basic_scheduler_interrupt (GstScheduler *sched, GstElement *element) { - - if (GST_FLAG_IS_SET (element, GST_ELEMENT_DECOUPLED)) { - g_warning ("interrupt decoupled element"); - } GST_FLAG_SET (element, GST_ELEMENT_COTHREAD_STOPPING); do_switch_to_main (sched); |
From: Wim T. <wt...@us...> - 2002-06-16 17:34:27
|
CVS Root: /cvsroot/gstreamer Module: gstreamer Changes by: wtay Date: Sun Jun 16 2002 10:34:26 PDT Log message: Use setfunc to set the cothread function instead of _reset Modified files: gst/schedulers : cothreads_compat.h gstbasicscheduler.c gstfastscheduler.c Links: http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/gst/schedulers/cothreads_compat.h.diff?r1=1.1&r2=1.2 http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/gst/schedulers/gstbasicscheduler.c.diff?r1=1.39&r2=1.40 http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/gst/schedulers/gstfastscheduler.c.diff?r1=1.6&r2=1.7 ====Begin Diffs==== Index: cothreads_compat.h =================================================================== RCS file: /cvsroot/gstreamer/gstreamer/gst/schedulers/cothreads_compat.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- cothreads_compat.h 6 May 2002 19:23:37 -0000 1.1 +++ cothreads_compat.h 16 Jun 2002 17:34:14 -0000 1.2 @@ -50,7 +50,7 @@ }\ }G_STMT_END -#define do_cothread_reset(cothread, context, func, argc, argv) \ +#define do_cothread_setfunc(cothread, context, func, argc, argv) \ cothread_setfunc ((cothread), (func), (argc), (argv)) #define do_cothread_destroy(cothread) cothread_free(cothread) @@ -110,8 +110,8 @@ new_thread = cothread_create ((func), 0, (void**) (argv), (context)); \ }G_STMT_END -#define do_cothread_reset(cothread, context, func, argc, argv) \ - cothread_reset ((cothread), (func), (argc), (void **) (argv), (context)) +#define do_cothread_setfunc(cothread, context, func, argc, argv) \ + cothread_setfunc ((cothread), (func), (argc), (void **) (argv), (context)) #define do_cothread_destroy(cothread) cothread_destroy(cothread) Index: gstbasicscheduler.c =================================================================== RCS file: /cvsroot/gstreamer/gstreamer/gst/schedulers/gstbasicscheduler.c,v retrieving revision 1.39 retrieving revision 1.40 diff -u -d -r1.39 -r1.40 --- gstbasicscheduler.c 5 Jun 2002 18:10:55 -0000 1.39 +++ gstbasicscheduler.c 16 Jun 2002 17:34:14 -0000 1.40 @@ -637,8 +637,9 @@ GST_ELEMENT_THREADSTATE (element), GST_ELEMENT_NAME (element)); } else { - do_cothread_reset (GST_ELEMENT_THREADSTATE (element), chain->sched->context, - wrapper_function, 0, (char **) element); + /* set the cothread wrapper function */ + do_cothread_setfunc (GST_ELEMENT_THREADSTATE (element), chain->sched->context, + wrapper_function, 0, (char **) element); GST_DEBUG (GST_CAT_SCHEDULING, "set wrapper function for '%s' to &%s", GST_ELEMENT_NAME (element), GST_DEBUG_FUNCPTR_NAME (wrapper_function)); } Index: gstfastscheduler.c =================================================================== RCS file: /cvsroot/gstreamer/gstreamer/gst/schedulers/gstfastscheduler.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- gstfastscheduler.c 25 May 2002 15:36:59 -0000 1.6 +++ gstfastscheduler.c 16 Jun 2002 17:34:14 -0000 1.7 @@ -308,7 +308,7 @@ GST_ELEMENT_NAME (element), GST_DEBUG_FUNCPTR_NAME (wrapper_function)); } } else { - do_cothread_reset (GST_ELEMENT_THREADSTATE (element), sched->context, wrapper_function, 0, (char **) element); + do_cothread_setfunc (GST_ELEMENT_THREADSTATE (element), sched->context, wrapper_function, 0, (char **) element); GST_DEBUG (GST_CAT_SCHEDULING, "set wrapper function for '%s' to &%s\n", GST_ELEMENT_NAME (element), GST_DEBUG_FUNCPTR_NAME (wrapper_function)); } |
From: Wim T. <wt...@us...> - 2002-06-16 19:33:28
|
CVS Root: /cvsroot/gstreamer Module: gstreamer Changes by: wtay Date: Sun Jun 16 2002 12:33:27 PDT Log message: Fixed the fast scheduler by proxying event to the event handler when the element is not event aware. Modified files: gst/schedulers : gstfastscheduler.c Links: http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/gst/schedulers/gstfastscheduler.c.diff?r1=1.7&r2=1.8 ====Begin Diffs==== Index: gstfastscheduler.c =================================================================== RCS file: /cvsroot/gstreamer/gstreamer/gst/schedulers/gstfastscheduler.c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- gstfastscheduler.c 16 Jun 2002 17:34:14 -0000 1.7 +++ gstfastscheduler.c 16 Jun 2002 19:33:15 -0000 1.8 @@ -226,10 +226,10 @@ GST_DEBUG_ENTER ("(%d,'%s')", argc, name); do { - GST_DEBUG (GST_CAT_DATAFLOW, "calling loopfunc %s for element %s\n", + GST_DEBUG (GST_CAT_DATAFLOW, "calling loopfunc %s for element %s", GST_DEBUG_FUNCPTR_NAME (element->loopfunc), name); (element->loopfunc) (element); - GST_DEBUG (GST_CAT_DATAFLOW, "element %s ended loop function\n", name); + GST_DEBUG (GST_CAT_DATAFLOW, "element %s ended loop function", name); } while (!GST_ELEMENT_IS_COTHREAD_STOPPING (element)); GST_FLAG_UNSET (element, GST_ELEMENT_COTHREAD_STOPPING); @@ -290,7 +290,7 @@ GList *pads; GstFastScheduler *sched; - GST_DEBUG (GST_CAT_SCHEDULING, "element is using COTHREADS\n"); + GST_DEBUG (GST_CAT_SCHEDULING, "element is using COTHREADS"); sched = (GstFastScheduler *) GST_ELEMENT_SCHED (bin); g_assert (GST_IS_FAST_SCHEDULER (sched)); @@ -303,13 +303,13 @@ gst_element_error (element, "could not create cothread for \"%s\"", GST_ELEMENT_NAME (element), NULL); return FALSE; - GST_DEBUG (GST_CAT_SCHEDULING, "created cothread %p for '%s' with wrapper function &%s\n", + GST_DEBUG (GST_CAT_SCHEDULING, "created cothread %p for '%s' with wrapper function &%s", GST_ELEMENT_THREADSTATE (element), GST_ELEMENT_NAME (element), GST_DEBUG_FUNCPTR_NAME (wrapper_function)); } } else { do_cothread_setfunc (GST_ELEMENT_THREADSTATE (element), sched->context, wrapper_function, 0, (char **) element); - GST_DEBUG (GST_CAT_SCHEDULING, "set wrapper function for '%s' to &%s\n", + GST_DEBUG (GST_CAT_SCHEDULING, "set wrapper function for '%s' to &%s", GST_ELEMENT_NAME (element), GST_DEBUG_FUNCPTR_NAME (wrapper_function)); } @@ -320,11 +320,11 @@ pads = g_list_next (pads); if (GST_PAD_DIRECTION (pad) == GST_PAD_SRC) { - GST_DEBUG (GST_CAT_SCHEDULING, "setting gethandler to getfunc_proxy for %s:%s\n", GST_DEBUG_PAD_NAME (pad)); + GST_DEBUG (GST_CAT_SCHEDULING, "setting gethandler to getfunc_proxy for %s:%s", GST_DEBUG_PAD_NAME (pad)); GST_RPAD_GETHANDLER (pad) = gst_fast_scheduler_getfunc_proxy; } else { - GST_DEBUG (GST_CAT_SCHEDULING, "setting chainhandler to chainfunc_proxy for %s:%s\n", GST_DEBUG_PAD_NAME (pad)); + GST_DEBUG (GST_CAT_SCHEDULING, "setting chainhandler to chainfunc_proxy for %s:%s", GST_DEBUG_PAD_NAME (pad)); GST_RPAD_CHAINHANDLER (pad) = gst_fast_scheduler_chainfunc_proxy; } } @@ -332,12 +332,22 @@ return TRUE; } +static void +gst_fast_scheduler_event_proxy (GstPad *pad, GstBuffer *buf) +{ + if (GST_IS_EVENT (buf)) + GST_RPAD_EVENTFUNC (pad) (pad, GST_EVENT (buf)); + else + GST_RPAD_CHAINFUNC (pad) (pad, buf); +} + + static gboolean gst_fast_scheduler_chained_element (GstBin *bin, GstElement *element) { GList *pads; GstPad *pad; - GST_DEBUG (GST_CAT_SCHEDULING,"chain entered\n"); + GST_DEBUG (GST_CAT_SCHEDULING,"chain entered"); /* walk through all the pads */ pads = gst_element_get_pad_list (element); @@ -348,10 +358,13 @@ continue; if (GST_RPAD_DIRECTION (pad) == GST_PAD_SINK) { - GST_DEBUG (GST_CAT_SCHEDULING,"copying chain function into chain handler for %s:%s\n",GST_DEBUG_PAD_NAME (pad)); - GST_RPAD_CHAINHANDLER (pad) = GST_RPAD_CHAINFUNC (pad); + GST_DEBUG (GST_CAT_SCHEDULING,"copying chain function into chain handler for %s:%s",GST_DEBUG_PAD_NAME (pad)); + if (!GST_FLAG_IS_SET (element, GST_ELEMENT_EVENT_AWARE)) + GST_RPAD_CHAINHANDLER (pad) = gst_fast_scheduler_event_proxy; + else + GST_RPAD_CHAINHANDLER (pad) = GST_RPAD_CHAINFUNC (pad); } else { - GST_DEBUG (GST_CAT_SCHEDULING,"copying get function into get handler for %s:%s\n",GST_DEBUG_PAD_NAME (pad)); + GST_DEBUG (GST_CAT_SCHEDULING,"copying get function into get handler for %s:%s",GST_DEBUG_PAD_NAME (pad)); if (!GST_RPAD_GETFUNC (pad)) GST_RPAD_GETHANDLER (pad) = gst_fast_scheduler_getfunc_proxy; else @@ -597,21 +610,21 @@ /* add the element to the chain */ gst_fast_scheduler_chain_add_element (chain, element); - GST_DEBUG (GST_CAT_SCHEDULING, "recursing on element \"%s\"\n", GST_ELEMENT_NAME (element)); + GST_DEBUG (GST_CAT_SCHEDULING, "recursing on element \"%s\"", GST_ELEMENT_NAME (element)); /* now go through all the pads and see which peers can be added */ pads = element->pads; while (pads) { pad = GST_PAD (pads->data); pads = g_list_next (pads); - GST_DEBUG (GST_CAT_SCHEDULING, "have pad %s:%s, checking for valid peer\n", + GST_DEBUG (GST_CAT_SCHEDULING, "have pad %s:%s, checking for valid peer", GST_DEBUG_PAD_NAME (pad)); /* if the peer exists and could be in the same chain */ if (GST_PAD_PEER (pad)) { - GST_DEBUG (GST_CAT_SCHEDULING, "has peer %s:%s\n", GST_DEBUG_PAD_NAME (GST_PAD_PEER (pad))); + GST_DEBUG (GST_CAT_SCHEDULING, "has peer %s:%s", GST_DEBUG_PAD_NAME (GST_PAD_PEER (pad))); peerelement = GST_PAD_PARENT (GST_PAD_PEER (pad)); if (GST_ELEMENT_SCHED (GST_PAD_PARENT (pad)) == GST_ELEMENT_SCHED (peerelement)) { - GST_DEBUG (GST_CAT_SCHEDULING, "peer \"%s\" is valid for same chain\n", + GST_DEBUG (GST_CAT_SCHEDULING, "peer \"%s\" is valid for same chain", GST_ELEMENT_NAME (peerelement)); /* if it's not already in a chain, add it to this one */ if (gst_fast_scheduler_find_chain (chain->sched, peerelement) == NULL) { @@ -632,7 +645,7 @@ /* first create thread context */ if (fast->context == NULL) { - GST_DEBUG (GST_CAT_SCHEDULING, "initializing cothread context\n"); + GST_DEBUG (GST_CAT_SCHEDULING, "initializing cothread context"); fast->context = do_cothread_context_init (); } } @@ -846,7 +859,7 @@ GST_INFO (GST_CAT_SCHEDULING, "have pad connected callback on %s:%s to %s:%s", GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (sinkpad)); - GST_DEBUG (GST_CAT_SCHEDULING, "srcpad sched is %p, sinkpad sched is %p\n", + GST_DEBUG (GST_CAT_SCHEDULING, "srcpad sched is %p, sinkpad sched is %p", GST_ELEMENT_SCHED (srcelement), GST_ELEMENT_SCHED (sinkelement)); if (GST_ELEMENT_SCHED (srcelement) == GST_ELEMENT_SCHED (sinkelement)) { @@ -927,7 +940,7 @@ chains = bsched->chains; if (chains == NULL) { - GST_DEBUG (GST_CAT_DATAFLOW, "no chains!\n"); + GST_DEBUG (GST_CAT_DATAFLOW, "no chains!"); state = GST_SCHEDULER_STATE_STOPPED; @@ -954,27 +967,27 @@ /* we just pick the first cothreaded element */ GstElement *entry = GST_ELEMENT (chain->cothreaded_elements->data); - GST_DEBUG (GST_CAT_DATAFLOW, "starting iteration via cothreads\n"); + GST_DEBUG (GST_CAT_DATAFLOW, "starting iteration via cothreads"); GST_FLAG_SET (entry, GST_ELEMENT_COTHREAD_STOPPING); - GST_DEBUG (GST_CAT_DATAFLOW, "set COTHREAD_STOPPING flag on \"%s\"(@%p)\n", + GST_DEBUG (GST_CAT_DATAFLOW, "set COTHREAD_STOPPING flag on \"%s\"(@%p)", GST_ELEMENT_NAME (entry), entry); if (GST_ELEMENT_THREADSTATE (entry)) { do_cothread_switch (GST_ELEMENT_THREADSTATE (entry)); } else { - GST_DEBUG (GST_CAT_DATAFLOW, "cothread switch not possible, element has no threadstate\n"); + GST_DEBUG (GST_CAT_DATAFLOW, "cothread switch not possible, element has no threadstate"); - GST_DEBUG (GST_CAT_DATAFLOW, "leaving (%s)\n", GST_ELEMENT_NAME (bin)); + GST_DEBUG (GST_CAT_DATAFLOW, "leaving (%s)", GST_ELEMENT_NAME (bin)); state = GST_SCHEDULER_STATE_ERROR; goto exit; } - GST_DEBUG (GST_CAT_SCHEDULING, "loopfunc of element %s ended\n", GST_ELEMENT_NAME (entry)); + GST_DEBUG (GST_CAT_SCHEDULING, "loopfunc of element %s ended", GST_ELEMENT_NAME (entry)); scheduled++; } @@ -983,7 +996,7 @@ if (entry) { GList *pads = gst_element_get_pad_list (entry); - GST_DEBUG (GST_CAT_DATAFLOW, "starting chained iteration\n"); + GST_DEBUG (GST_CAT_DATAFLOW, "starting chained iteration"); while (pads) { GstPad *pad = GST_PAD_CAST (pads->data); @@ -1019,7 +1032,7 @@ } } - GST_DEBUG (GST_CAT_DATAFLOW, "leaving (%s)\n", GST_ELEMENT_NAME (bin)); + GST_DEBUG (GST_CAT_DATAFLOW, "leaving (%s)", GST_ELEMENT_NAME (bin)); if (scheduled == 0) { GST_INFO (GST_CAT_DATAFLOW, "nothing was scheduled, return STOPPED"); @@ -1031,7 +1044,7 @@ } exit: - GST_DEBUG (GST_CAT_DATAFLOW, "leaving (%s) %d\n", GST_ELEMENT_NAME (bin), state); + GST_DEBUG (GST_CAT_DATAFLOW, "leaving (%s) %d", GST_ELEMENT_NAME (bin), state); return state; } @@ -1046,7 +1059,7 @@ GstFastScheduler *bsched = GST_FAST_SCHEDULER (sched); if (sched == NULL) { - g_print ("scheduler doesn't exist for this element\n"); + g_print ("scheduler doesn't exist for this element"); return; } |
From: Wim T. <wt...@us...> - 2002-06-16 19:48:51
|
CVS Root: /cvsroot/gstreamer Module: gstreamer Changes by: wtay Date: Sun Jun 16 2002 12:48:50 PDT Log message: Better add the check instead of crashing Modified files: gst/schedulers : gstfastscheduler.c Links: http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/gst/schedulers/gstfastscheduler.c.diff?r1=1.8&r2=1.9 ====Begin Diffs==== Index: gstfastscheduler.c =================================================================== RCS file: /cvsroot/gstreamer/gstreamer/gst/schedulers/gstfastscheduler.c,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- gstfastscheduler.c 16 Jun 2002 19:33:15 -0000 1.8 +++ gstfastscheduler.c 16 Jun 2002 19:48:38 -0000 1.9 @@ -955,8 +955,7 @@ continue; } - /* if (chain->num_cothreaded > 1) { */ - if (FALSE) { + if (chain->num_cothreaded > 1) { g_warning ("this scheduler can only deal with 1 cothreaded element in a chain"); state = GST_SCHEDULER_STATE_ERROR; |
From: Wim T. <wt...@us...> - 2002-06-16 22:36:24
|
CVS Root: /cvsroot/gstreamer Module: gstreamer Changes by: wtay Date: Sun Jun 16 2002 15:36:23 PDT Log message: Added more debugging info Modified files: gst/schedulers : gstbasicscheduler.c Links: http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/gst/schedulers/gstbasicscheduler.c.diff?r1=1.41&r2=1.42 ====Begin Diffs==== Index: gstbasicscheduler.c =================================================================== RCS file: /cvsroot/gstreamer/gstreamer/gst/schedulers/gstbasicscheduler.c,v retrieving revision 1.41 retrieving revision 1.42 diff -u -d -r1.41 -r1.42 --- gstbasicscheduler.c 16 Jun 2002 21:20:07 -0000 1.41 +++ gstbasicscheduler.c 16 Jun 2002 22:36:10 -0000 1.42 @@ -632,6 +632,8 @@ /* need to set up the cothread now */ if (wrapper_function != NULL) { if (GST_ELEMENT_THREADSTATE (element) == NULL) { + GST_DEBUG (GST_CAT_SCHEDULING, "about to create a cothread, wrapper function for '%s' is &%s", + GST_ELEMENT_NAME (element), GST_DEBUG_FUNCPTR_NAME (wrapper_function)); do_cothread_create (GST_ELEMENT_THREADSTATE (element), chain->sched->context, wrapper_function, 0, (char **) element); if (GST_ELEMENT_THREADSTATE (element) == NULL) { @@ -644,6 +646,8 @@ GST_ELEMENT_NAME (element)); } else { /* set the cothread wrapper function */ + GST_DEBUG (GST_CAT_SCHEDULING, "about to set the wrapper function for '%s' to &%s", + GST_ELEMENT_NAME (element), GST_DEBUG_FUNCPTR_NAME (wrapper_function)); do_cothread_setfunc (GST_ELEMENT_THREADSTATE (element), chain->sched->context, wrapper_function, 0, (char **) element); GST_DEBUG (GST_CAT_SCHEDULING, "set wrapper function for '%s' to &%s", |
From: Wim T. <wt...@us...> - 2002-06-21 08:00:30
|
CVS Root: /cvsroot/gstreamer Module: gstreamer Changes by: wtay Date: Fri Jun 21 2002 01:00:28 PDT Log message: Pass some required params to cothreads_init Modified files: gst/schedulers : cothreads_compat.h Links: http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/gst/schedulers/cothreads_compat.h.diff?r1=1.3&r2=1.4 ====Begin Diffs==== Index: cothreads_compat.h =================================================================== RCS file: /cvsroot/gstreamer/gstreamer/gst/schedulers/cothreads_compat.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- cothreads_compat.h 19 Jun 2002 18:13:28 -0000 1.3 +++ cothreads_compat.h 21 Jun 2002 08:00:13 -0000 1.4 @@ -90,7 +90,7 @@ */ #define do_cothreads_init(x) G_STMT_START{ \ if (!cothreads_initialized()) \ - cothreads_init(x); \ + cothreads_init(0x0200000, 32); \ }G_STMT_END #define do_cothreads_stackquery(stack,size) \ |
From: Wim T. <wt...@us...> - 2002-06-23 12:22:05
|
CVS Root: /cvsroot/gstreamer Module: gstreamer Changes by: wtay Date: Sun Jun 23 2002 05:22:02 PDT Log message: Unlock an element even if it was a loop based one Modified files: gst/schedulers : gstbasicscheduler.c Links: http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/gst/schedulers/gstbasicscheduler.c.diff?r1=1.44&r2=1.45 ====Begin Diffs==== Index: gstbasicscheduler.c =================================================================== RCS file: /cvsroot/gstreamer/gstreamer/gst/schedulers/gstbasicscheduler.c,v retrieving revision 1.44 retrieving revision 1.45 diff -u -d -r1.44 -r1.45 --- gstbasicscheduler.c 23 Jun 2002 04:31:45 -0000 1.44 +++ gstbasicscheduler.c 23 Jun 2002 12:21:50 -0000 1.45 @@ -161,6 +161,8 @@ entry->pre_run_func (entry); \ SCHED (entry)->current = entry; \ do_cothread_switch (GST_ELEMENT_THREADSTATE (entry)); \ + if (entry->post_run_func) \ + entry->post_run_func (entry); \ }G_STMT_END static GType |
From: Wim T. <wt...@us...> - 2002-06-23 12:42:15
|
CVS Root: /cvsroot/gstreamer Module: gstreamer Changes by: wtay Date: Sun Jun 23 2002 05:42:14 PDT Log message: Or not.. Modified files: gst/schedulers : gstbasicscheduler.c Links: http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/gst/schedulers/gstbasicscheduler.c.diff?r1=1.45&r2=1.46 ====Begin Diffs==== Index: gstbasicscheduler.c =================================================================== RCS file: /cvsroot/gstreamer/gstreamer/gst/schedulers/gstbasicscheduler.c,v retrieving revision 1.45 retrieving revision 1.46 diff -u -d -r1.45 -r1.46 --- gstbasicscheduler.c 23 Jun 2002 12:21:50 -0000 1.45 +++ gstbasicscheduler.c 23 Jun 2002 12:42:01 -0000 1.46 @@ -161,8 +161,6 @@ entry->pre_run_func (entry); \ SCHED (entry)->current = entry; \ do_cothread_switch (GST_ELEMENT_THREADSTATE (entry)); \ - if (entry->post_run_func) \ - entry->post_run_func (entry); \ }G_STMT_END static GType |
From: Wim T. <wt...@us...> - 2002-06-23 12:50:25
|
CVS Root: /cvsroot/gstreamer Module: gstreamer Changes by: wtay Date: Sun Jun 23 2002 05:50:24 PDT Log message: This makes more sense and solves the locking problem when a loop based element is selected as the entry point. Modified files: gst/schedulers : gstbasicscheduler.c Links: http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/gst/schedulers/gstbasicscheduler.c.diff?r1=1.46&r2=1.47 ====Begin Diffs==== Index: gstbasicscheduler.c =================================================================== RCS file: /cvsroot/gstreamer/gstreamer/gst/schedulers/gstbasicscheduler.c,v retrieving revision 1.46 retrieving revision 1.47 diff -u -d -r1.46 -r1.47 --- gstbasicscheduler.c 23 Jun 2002 12:42:01 -0000 1.46 +++ gstbasicscheduler.c 23 Jun 2002 12:50:12 -0000 1.47 @@ -272,6 +272,7 @@ GST_DEBUG_ENTER ("(%d,'%s')", argc, name); + gst_object_ref (GST_OBJECT (element)); do { GST_DEBUG (GST_CAT_DATAFLOW, "calling loopfunc %s for element %s", GST_DEBUG_FUNCPTR_NAME (element->loopfunc), name); @@ -281,7 +282,17 @@ } while (!GST_ELEMENT_IS_COTHREAD_STOPPING (element)); GST_FLAG_UNSET (element, GST_ELEMENT_COTHREAD_STOPPING); + /* due to oddities in the cothreads code, when this function returns it will + * switch to the main cothread. thus, we need to unlock the current element. */ + if (SCHED (element)) { + if (SCHED (element)->current && SCHED (element)->current->post_run_func) { + SCHED (element)->current->post_run_func (SCHED (element)->current); + } + SCHED (element)->current = NULL; + } + GST_DEBUG_LEAVE ("(%d,'%s')", argc, name); + gst_object_unref (GST_OBJECT (element)); return 0; } |
From: Wim T. <wt...@us...> - 2002-07-02 18:42:14
|
CVS Root: /cvsroot/gstreamer Module: gstreamer Changes by: wtay Date: Tue Jul 02 2002 11:42:13 PDT Log message: Set the scheduler to NULL in all cases. Modified files: gst/schedulers : gstbasicscheduler.c Links: http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/gst/schedulers/gstbasicscheduler.c.diff?r1=1.48&r2=1.49 ====Begin Diffs==== Index: gstbasicscheduler.c =================================================================== RCS file: /cvsroot/gstreamer/gstreamer/gst/schedulers/gstbasicscheduler.c,v retrieving revision 1.48 retrieving revision 1.49 diff -u -d -r1.48 -r1.49 --- gstbasicscheduler.c 27 Jun 2002 23:55:27 -0000 1.48 +++ gstbasicscheduler.c 2 Jul 2002 18:42:00 -0000 1.49 @@ -330,8 +330,8 @@ gst_pad_send_event (pad, GST_EVENT (buf)); } else { - GST_DEBUG (GST_CAT_DATAFLOW, "calling chain function of %s:%s", name, - GST_PAD_NAME (pad)); + GST_DEBUG (GST_CAT_DATAFLOW, "calling chain function of %s:%s %p", name, + GST_PAD_NAME (pad), buf); GST_RPAD_CHAINFUNC (realpad) (pad, buf); GST_DEBUG (GST_CAT_DATAFLOW, "calling chain function of element %s done", name); } @@ -381,8 +381,8 @@ g_return_val_if_fail (GST_RPAD_GETFUNC (realpad) != NULL, 0); buf = GST_RPAD_GETFUNC (realpad) (GST_PAD_CAST (realpad)); if (buf) { - GST_DEBUG (GST_CAT_DATAFLOW, "calling gst_pad_push on pad %s:%s", - GST_DEBUG_PAD_NAME (realpad)); + GST_DEBUG (GST_CAT_DATAFLOW, "calling gst_pad_push on pad %s:%s %p", + GST_DEBUG_PAD_NAME (realpad), buf); gst_pad_push (GST_PAD_CAST (realpad), buf); } } @@ -443,8 +443,8 @@ /* now fill the bufferpen and switch so it can be consumed */ GST_RPAD_BUFPEN (GST_RPAD_PEER (pad)) = buf; - GST_DEBUG (GST_CAT_DATAFLOW, "switching to %p", - GST_ELEMENT_THREADSTATE (GST_PAD_PARENT (pad))); + GST_DEBUG (GST_CAT_DATAFLOW, "switching to %p to consume buffer %p", + GST_ELEMENT_THREADSTATE (GST_PAD_PARENT (pad)), buf); do_element_switch (parent); @@ -1000,15 +1000,16 @@ GST_ERROR (element, "grave error"); return; } - + /* set the sched pointer in the element itself */ GST_ELEMENT_SCHED (element) = sched; - + /* only deal with elements after this point, not bins */ /* exception is made for Bin's that are schedulable, like the autoplugger */ if (GST_IS_BIN (element) && !GST_FLAG_IS_SET (element, GST_BIN_SELF_SCHEDULABLE)) return; + /* first add it to the list of elements that are to be scheduled */ bsched->elements = g_list_prepend (bsched->elements, element); bsched->num_elements++; @@ -1070,8 +1071,8 @@ bsched->num_elements--; /* unset the scheduler pointer in the element */ - GST_ELEMENT_SCHED (element) = NULL; } + GST_ELEMENT_SCHED (element) = NULL; } static GstElementStateReturn |
From: Wim T. <wt...@us...> - 2002-07-24 21:09:59
|
CVS Root: /cvsroot/gstreamer Module: gstreamer Changes by: wtay Date: Wed Jul 24 2002 14:09:58 PDT Log message: Don't try to pull on disabled pads in the scheduler Modified files: gst/schedulers : gstbasicscheduler.c Links: http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/gst/schedulers/gstbasicscheduler.c.diff?r1=1.49&r2=1.50 ====Begin Diffs==== Index: gstbasicscheduler.c =================================================================== RCS file: /cvsroot/gstreamer/gstreamer/gst/schedulers/gstbasicscheduler.c,v retrieving revision 1.49 retrieving revision 1.50 diff -u -d -r1.49 -r1.50 --- gstbasicscheduler.c 2 Jul 2002 18:42:00 -0000 1.49 +++ gstbasicscheduler.c 24 Jul 2002 21:09:46 -0000 1.50 @@ -320,7 +320,7 @@ realpad = GST_REAL_PAD_CAST (pad); - if (GST_RPAD_DIRECTION (realpad) == GST_PAD_SINK) { + if (GST_RPAD_DIRECTION (realpad) == GST_PAD_SINK && GST_PAD_IS_USABLE (realpad)) { GstBuffer *buf; GST_DEBUG (GST_CAT_DATAFLOW, "pulling data from %s:%s", name, GST_PAD_NAME (pad)); @@ -376,7 +376,7 @@ realpad = GST_REAL_PAD_CAST (pads->data); pads = g_list_next (pads); - if (GST_RPAD_DIRECTION (realpad) == GST_PAD_SRC) { + if (GST_RPAD_DIRECTION (realpad) == GST_PAD_SRC && GST_PAD_IS_USABLE (realpad)) { GST_DEBUG (GST_CAT_DATAFLOW, "calling _getfunc for %s:%s", GST_DEBUG_PAD_NAME (realpad)); g_return_val_if_fail (GST_RPAD_GETFUNC (realpad) != NULL, 0); buf = GST_RPAD_GETFUNC (realpad) (GST_PAD_CAST (realpad)); |
From: Wim T. <wt...@us...> - 2002-09-08 17:58:15
|
CVS Root: /cvsroot/gstreamer Module: gstreamer Changes by: wtay Date: Sun Sep 08 2002 10:58:12 PDT Log message: A new scheduler that tries to minimize the number of cothreads, still needs a lot of work. Added files: gst/schedulers : gstoptimalscheduler.c Links: http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/gst/schedulers/gstoptimalscheduler.c?rev=1.1&content-type=text/vnd.viewcvs-markup ====Begin Diffs==== --- NEW FILE: gstoptimalscheduler.c --- /* GStreamer * Copyright (C) 1999,2000 Erik Walthinsen <om...@cs...> * 2000 Wim Taymans <wt...@ch...> * * gstscheduler.c: Default scheduling code for most cases * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, [...993 lines suppressed...] if (osched->state == GST_OPT_SCHEDULER_STATE_ERROR) { state = GST_SCHEDULER_STATE_ERROR; } else { if (scheduled) state = GST_SCHEDULER_STATE (sched); else state = GST_SCHEDULER_STATE_STOPPED; } return state; } static void gst_opt_scheduler_show (GstScheduler *sched) { //GstOptScheduler *osched = GST_OPT_SCHEDULER_CAST (sched); } |
From: Wim T. <wt...@us...> - 2002-09-08 22:42:44
|
CVS Root: /cvsroot/gstreamer Module: gstreamer Changes by: wtay Date: Sun Sep 08 2002 15:42:42 PDT Log message: Added comments Added _show Special cased wrapper functions to minimize checks at runtime Modified files: gst/schedulers : gstoptimalscheduler.c Links: http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/gst/schedulers/gstoptimalscheduler.c.diff?r1=1.1&r2=1.2 ====Begin Diffs==== Index: gstoptimalscheduler.c =================================================================== RCS file: /cvsroot/gstreamer/gstreamer/gst/schedulers/gstoptimalscheduler.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- gstoptimalscheduler.c 8 Sep 2002 17:58:00 -0000 1.1 +++ gstoptimalscheduler.c 8 Sep 2002 22:42:29 -0000 1.2 @@ -65,8 +65,8 @@ cothread_context *context; gboolean use_cothreads; - GList *elements; - GList *chains; + GSList *elements; + GSList *chains; }; struct _GstOptSchedulerClass { @@ -92,7 +92,7 @@ GstOptSchedulerChainFlags flags; - GList *groups; /* the groups in this chain */ + GSList *groups; /* the groups in this chain */ gint num_groups; gint num_enabled; }; @@ -126,7 +126,7 @@ GstOptSchedulerGroupFlags flags; /* flags for this group */ GstOptSchedulerGroupType type; /* flags for this group */ - GList *elements; /* elements of this group */ + GSList *elements; /* elements of this group */ gint num_elements; gint num_enabled; GstElement *entry; /* the group's entry point */ @@ -312,9 +312,9 @@ g_assert (chain->sched == osched); - osched->chains = g_list_remove (osched->chains, chain); + osched->chains = g_slist_remove (osched->chains, chain); - g_list_free (chain->groups); + g_slist_free (chain->groups); g_free (chain); } @@ -325,7 +325,7 @@ g_assert (group->chain == NULL); - chain->groups = g_list_prepend (chain->groups, group); + chain->groups = g_slist_prepend (chain->groups, group); group->chain = chain; chain->num_groups++; } @@ -338,7 +338,7 @@ chain = g_new0 (GstOptSchedulerChain, 1); chain->sched = osched; - osched->chains = g_list_prepend (osched->chains, chain); + osched->chains = g_slist_prepend (osched->chains, chain); GST_INFO (GST_CAT_SCHEDULING, "new chain %p", chain); @@ -352,7 +352,7 @@ g_assert (group->chain == chain); - chain->groups = g_list_remove (chain->groups, group); + chain->groups = g_slist_remove (chain->groups, group); chain->num_groups--; group->chain = NULL; @@ -361,7 +361,7 @@ static void merge_chains (GstOptSchedulerChain *chain1, GstOptSchedulerChain *chain2) { - GList *walk; + GSList *walk; GST_INFO (GST_CAT_SCHEDULING, "mergin chain %p and %p", chain1, chain2); @@ -374,7 +374,7 @@ group->chain = NULL; add_to_chain (chain1, group); - walk = g_list_next (walk); + walk = g_slist_next (walk); } delete_chain (chain2->sched, chain2); } @@ -414,7 +414,7 @@ g_assert (GST_ELEMENT_SCHED_GROUP (element) == NULL); - group->elements = g_list_prepend (group->elements, element); + group->elements = g_slist_prepend (group->elements, element); group->num_elements++; GST_ELEMENT_SCHED_GROUP (element) = group; @@ -462,14 +462,14 @@ if (group->flags & GST_OPT_SCHEDULER_GROUP_SCHEDULABLE) destroy_group_scheduler (group); - g_list_free (group->elements); + g_slist_free (group->elements); g_free (group); } static void merge_groups (GstOptSchedulerGroup *group1, GstOptSchedulerGroup *group2) { - GList *walk; + GSList *walk; GstOptSchedulerChain *chain1; GstOptSchedulerChain *chain2; @@ -481,7 +481,7 @@ walk = group2->elements; while (walk) { add_to_group (group1, (GstElement *)walk->data); - walk = g_list_next (walk); + walk = g_slist_next (walk); } chain1 = group1->chain; @@ -499,7 +499,7 @@ { GST_INFO (GST_CAT_SCHEDULING, "removing element \"%s\" to group %p", GST_ELEMENT_NAME (element), group); - group->elements = g_list_remove (group->elements, element); + group->elements = g_slist_remove (group->elements, element); group->num_elements--; GST_ELEMENT_SCHED_GROUP (element) = NULL; @@ -540,28 +540,29 @@ return 1; } else { - if (!(group->flags & GST_OPT_SCHEDULER_GROUP_RUNNING)) - return group->schedulefunc (group->argc, group->argv); - else - return 0; + /* in the no cothread case, we cannot schedule already running groups */ + if (!(group->flags & GST_OPT_SCHEDULER_GROUP_RUNNING)) { + group->schedulefunc (group->argc, group->argv); + return 1; + } } + return 0; } static void schedule_chain (GstOptSchedulerChain *chain) { - GList *groups = chain->groups; + GSList *groups = chain->groups; while (groups) { GstOptSchedulerGroup *group = (GstOptSchedulerGroup *) groups->data; - groups = g_list_next (groups); + groups = g_slist_next (groups); if (!GST_OPT_SCHEDULER_GROUP_IS_DISABLED (group)) { GST_INFO (GST_CAT_SCHEDULING, "scheduling group %p in chain %p", group, chain); schedule_group (group); - break; } } @@ -609,57 +610,68 @@ } static int -wrapper_function (int argc, char *argv[]) +get_wrapper (int argc, char *argv[]) { GstOptSchedulerGroup *group = (GstOptSchedulerGroup *) argv; + const GList *pads = gst_element_get_pad_list (group->entry); - GST_INFO (GST_CAT_SCHEDULING, "wrapper function of group %p", group); + GST_INFO (GST_CAT_SCHEDULING, "get wrapper of group %p", group); group->flags |= GST_OPT_SCHEDULER_GROUP_RUNNING; - switch (group->type) { - case GST_OPT_SCHEDULER_GROUP_GET: - { - const GList *pads = gst_element_get_pad_list (group->entry); - GstBuffer *buffer; + while (pads) { + GstBuffer *buffer; + GstPad *pad = GST_PAD_CAST (pads->data); + pads = g_list_next (pads); - while (pads) { - GstPad *pad = GST_PAD_CAST (pads->data); - pads = g_list_next (pads); + /* skip sinks and ghostpads */ + if (!GST_PAD_IS_SRC (pad) || !GST_IS_REAL_PAD (pad)) + continue; - /* skip sinks and ghostpads */ - if (!GST_PAD_IS_SRC (pad) || !GST_IS_REAL_PAD (pad)) - continue; + GST_INFO (GST_CAT_SCHEDULING, "doing get and push on pad \"%s:%s\" in group %p", + GST_DEBUG_PAD_NAME (pad), group); - GST_INFO (GST_CAT_SCHEDULING, "doing get and push on pad \"%s:%s\" in group %p", - GST_DEBUG_PAD_NAME (pad), group); + buffer = GST_RPAD_GETFUNC (pad) (pad); + if (buffer) + gst_pad_push (pad, buffer); + } - buffer = GST_RPAD_GETFUNC (pad) (pad); - if (buffer) - gst_pad_push (pad, buffer); - } - break; - } - case GST_OPT_SCHEDULER_GROUP_LOOP: - { - GstElement *entry = group->entry; + group->flags &= ~GST_OPT_SCHEDULER_GROUP_RUNNING; - GST_INFO (GST_CAT_SCHEDULING, "calling loopfunc of element %s in group %p", - GST_ELEMENT_NAME (entry), group); + return 0; +} - entry->loopfunc (entry); - break; - } - default: - g_warning ("(internal error) unkown group type %d, disabling\n", group->type); - chain_group_set_enabled (group->chain, group, FALSE); - group->chain->sched->state = GST_OPT_SCHEDULER_STATE_ERROR; - break; - } +static int +loop_wrapper (int argc, char *argv[]) +{ + GstOptSchedulerGroup *group = (GstOptSchedulerGroup *) argv; + GstElement *entry = group->entry; + + GST_INFO (GST_CAT_SCHEDULING, "loop wrapper of group %p", group); + + group->flags |= GST_OPT_SCHEDULER_GROUP_RUNNING; + + GST_INFO (GST_CAT_SCHEDULING, "calling loopfunc of element %s in group %p", + GST_ELEMENT_NAME (entry), group); + + entry->loopfunc (entry); group->flags &= ~GST_OPT_SCHEDULER_GROUP_RUNNING; return 0; + +} + +static int +unkown_wrapper (int argc, char *argv[]) +{ + GstOptSchedulerGroup *group = (GstOptSchedulerGroup *) argv; + + g_warning ("(internal error) unkown group type %d, disabling\n", group->type); + chain_group_set_enabled (group->chain, group, FALSE); + group->chain->sched->state = GST_OPT_SCHEDULER_STATE_ERROR; + + return 0; } static void @@ -671,6 +683,13 @@ group = GST_ELEMENT_SCHED_GROUP (GST_PAD_PARENT (sinkpad)); + if (GST_RPAD_BUFPEN (GST_RPAD_PEER (sinkpad))) { + g_warning ("scheduling error, bufpen not empty, disabling group %p", group); + chain_group_set_enabled (group->chain, group, FALSE); + group->chain->sched->state = GST_OPT_SCHEDULER_STATE_ERROR; + return; + } + GST_RPAD_BUFPEN (GST_RPAD_PEER (sinkpad)) = buffer; while (GST_RPAD_BUFPEN (GST_RPAD_PEER (sinkpad))) { @@ -693,7 +712,12 @@ group = GST_ELEMENT_SCHED_GROUP (GST_PAD_PARENT (srcpad)); - schedule_group (group); + if (!schedule_group (group)) { + g_warning ("deadlock detected, disabling group %p", group); + chain_group_set_enabled (group->chain, group, FALSE); + group->chain->sched->state = GST_OPT_SCHEDULER_STATE_ERROR; + return NULL; + } buffer = GST_RPAD_BUFPEN (srcpad); } @@ -712,22 +736,35 @@ else { GST_RPAD_CHAINFUNC (sinkpad) (sinkpad, buffer); } - } static void setup_group_scheduler (GstOptScheduler *osched, GstOptSchedulerGroup *group) { + GroupScheduleFunction wrapper; + + wrapper = unkown_wrapper; + + if (group->type == GST_OPT_SCHEDULER_GROUP_GET) + wrapper = get_wrapper; + else if (group->type == GST_OPT_SCHEDULER_GROUP_LOOP) + wrapper = loop_wrapper; + if (osched->use_cothreads) { - do_cothread_create (group->cothread, osched->context, - wrapper_function, 0, (char **) group); + if (!(group->flags & GST_OPT_SCHEDULER_GROUP_SCHEDULABLE)) { + do_cothread_create (group->cothread, osched->context, + wrapper, 0, (char **) group); + } + else { + do_cothread_setfunc (group->cothread, osched->context, + wrapper, 0, (char **) group); + } } else { - group->schedulefunc = wrapper_function; + group->schedulefunc = wrapper; group->argc = 0; group->argv = (char **) group; } - group->flags |= GST_OPT_SCHEDULER_GROUP_SCHEDULABLE; } @@ -766,9 +803,7 @@ switch (transition) { case GST_STATE_PAUSED_TO_PLAYING: - if (!(group->flags & GST_OPT_SCHEDULER_GROUP_SCHEDULABLE)) { - setup_group_scheduler (osched, group); - } + setup_group_scheduler (osched, group); group_element_set_enabled (group, element, TRUE); break; case GST_STATE_PLAYING_TO_PAUSED: @@ -812,6 +847,15 @@ //GstOptScheduler *osched = GST_OPT_SCHEDULER_CAST (sched); } +/* + * the idea is to put the two elements into the same group. + * - When no element is inside a group, we create a new group and add + * the elements to it. + * - When one of the elements has a group, add the other element to + * that group + * - if both of the elements have a group, we merge the groups, which + * will also merge the chains. + */ static GstOptSchedulerGroup* group_elements (GstOptScheduler *osched, GstElement *element1, GstElement *element2) { @@ -825,6 +869,8 @@ if (ctx2) group2 = ctx2->group; + /* none of the elements is added to a group, create a new group + * and chain to add the elements to */ if (!group1 && !group2) { GstOptSchedulerChain *chain; @@ -835,16 +881,23 @@ group = create_group (chain, element1); add_to_group (group, element2); } + /* the first element has a group */ else if (group1) { GST_INFO (GST_CAT_SCHEDULING, "adding \"%s\" to \"%s\"'s group", GST_ELEMENT_NAME (element2), GST_ELEMENT_NAME (element1)); + + /* the second element also has a group, merge */ if (group2) merge_groups (group1, group2); + /* the second element has no group, add it to the group + * of the first element */ else add_to_group (group1, element2); group = group1; } + /* element1 has no group, element2 does. Add element1 to the + * group of element2 */ else { GST_INFO (GST_CAT_SCHEDULING, "adding \"%s\" to \"%s\"'s group", GST_ELEMENT_NAME (element1), GST_ELEMENT_NAME (element2)); @@ -877,6 +930,8 @@ element1 = GST_PAD_PARENT (srcpad); element2 = GST_PAD_PARENT (sinkpad); + /* first we need to figure out whar type of connection we're dealing + * with */ if (element1->loopfunc && element2->loopfunc) type = GST_OPT_LOOP_TO_LOOP; else { @@ -898,6 +953,7 @@ } } + /* for each connection type, perform specific actions */ switch (type) { case GST_OPT_GET_TO_CHAIN: { @@ -905,14 +961,19 @@ GST_INFO (GST_CAT_SCHEDULING, "get to chain based connection"); + /* setup get/chain handlers */ GST_RPAD_GETHANDLER (srcpad) = GST_RPAD_GETFUNC (srcpad); if (GST_ELEMENT_IS_EVENT_AWARE (element2)) GST_RPAD_CHAINHANDLER (sinkpad) = GST_RPAD_CHAINFUNC (sinkpad); else GST_RPAD_CHAINHANDLER (sinkpad) = gst_opt_scheduler_chain_wrapper; + /* the two elements should be put into the same group, + * this also means that they are in the same chain automatically */ group = group_elements (osched, element1, element2); + /* if there is not yet an entry in the group, select the source + * element as the entry point */ if (!group->entry) { group->entry = element1; group->type = GST_OPT_SCHEDULER_GROUP_GET; @@ -931,12 +992,21 @@ else GST_RPAD_CHAINHANDLER (sinkpad) = gst_opt_scheduler_chain_wrapper; + /* the two elements should be put into the same group, + * this also means that they are in the same chain automatically, + * in case of a loop-based element1, there will be a group for element1 and + * element2 will be added to it. */ group_elements (osched, element1, element2); break; case GST_OPT_GET_TO_LOOP: GST_INFO (GST_CAT_SCHEDULING, "get to loop based connection"); GST_RPAD_GETHANDLER (srcpad) = GST_RPAD_GETFUNC (srcpad); + + /* the two elements should be put into the same group, + * this also means that they are in the same chain automatically, + * element2 is loop-based so it already has a group where element1 + * will be added to */ group_elements (osched, element1, element2); break; case GST_OPT_CHAIN_TO_LOOP: @@ -951,11 +1021,17 @@ group1 = GST_ELEMENT_SCHED_GROUP (element1); group2 = GST_ELEMENT_SCHED_GROUP (element2); + /* group2 is guaranteed to exist as it contains a loop-based element. + * group1 only exists if element1 is connected to some other element */ if (!group1) { + /* create a new group for element1 as it cannot be merged into another group + * here. we create the group in the same chain as the loop-based element. */ GST_INFO (GST_CAT_SCHEDULING, "creating new group for element %s", GST_ELEMENT_NAME (element1)); group1 = create_group (group2->chain, element1); } else { + /* both elements are already in a group, make sure they are added to + * the same chain */ merge_chains (group1->chain, group2->chain); } break; @@ -995,7 +1071,7 @@ { GstSchedulerState state; GstOptScheduler *osched = GST_OPT_SCHEDULER_CAST (sched); - GList *chains; + GSList *chains; gboolean scheduled = FALSE; osched->state = GST_OPT_SCHEDULER_STATE_RUNNING; @@ -1003,7 +1079,7 @@ chains = osched->chains; while (chains) { GstOptSchedulerChain *chain = (GstOptSchedulerChain *) chains->data; - chains = g_list_next (chains); + chains = g_slist_next (chains); if (!GST_OPT_SCHEDULER_CHAIN_IS_DISABLED (chain)) { schedule_chain (chain); @@ -1028,5 +1104,33 @@ static void gst_opt_scheduler_show (GstScheduler *sched) { - //GstOptScheduler *osched = GST_OPT_SCHEDULER_CAST (sched); + GstOptScheduler *osched = GST_OPT_SCHEDULER_CAST (sched); + GSList *chains; + + chains = osched->chains; + while (chains) { + GstOptSchedulerChain *chain = (GstOptSchedulerChain *) chains->data; + GSList *groups = chain->groups; + chains = g_slist_next (chains); + + g_print ("+- chain %p: %d groups, %d enabled, flags %d\n", chain, chain->num_groups, chain->num_enabled, chain->flags); + + while (groups) { + GstOptSchedulerGroup *group = (GstOptSchedulerGroup *) groups->data; + GSList *elements = group->elements; + groups = g_slist_next (groups); + + g_print (" +- group %p: %d elements, %d enabled, flags %d, entry %s, %s\n", + group, group->num_elements, group->num_enabled, group->flags, + (group->entry ? GST_ELEMENT_NAME (group->entry): "(none)"), + (group->type == GST_OPT_SCHEDULER_GROUP_GET ? "get-based" : "loop-based") ); + + while (elements) { + GstElement *element = (GstElement *) elements->data; + elements = g_slist_next (elements); + + g_print (" +- element %s\n", GST_ELEMENT_NAME (element)); + } + } + } } |
From: Wim T. <wt...@us...> - 2002-09-12 19:22:18
|
CVS Root: /cvsroot/gstreamer Module: gstreamer Changes by: wtay Date: Thu Sep 12 2002 12:22:16 PDT Log message: More updates to the non-cothread scheduler Modified files: gst/schedulers : gstoptimalscheduler.c Links: http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/gst/schedulers/gstoptimalscheduler.c.diff?r1=1.2&r2=1.3 ====Begin Diffs==== Index: gstoptimalscheduler.c =================================================================== RCS file: /cvsroot/gstreamer/gstreamer/gst/schedulers/gstoptimalscheduler.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- gstoptimalscheduler.c 8 Sep 2002 22:42:29 -0000 1.2 +++ gstoptimalscheduler.c 12 Sep 2002 19:22:03 -0000 1.3 @@ -28,6 +28,7 @@ #define GST_ELEMENT_SCHED_CONTEXT(elem) ((GstOptSchedulerCtx*) (GST_ELEMENT_CAST (elem)->sched_private)) #define GST_ELEMENT_SCHED_GROUP(elem) (GST_ELEMENT_SCHED_CONTEXT (elem)->group) +#define GST_PAD_BUFLIST(pad) ((GList*) (GST_REAL_PAD_CAST(pad)->sched_private)) #define GST_ELEMENT_COTHREAD_STOPPING GST_ELEMENT_SCHEDULER_PRIVATE1 #define GST_ELEMENT_IS_COTHREAD_STOPPING(element) GST_FLAG_IS_SET((element), GST_ELEMENT_COTHREAD_STOPPING) @@ -58,15 +59,19 @@ } GstOptSchedulerState; struct _GstOptScheduler { - GstScheduler parent; + GstScheduler parent; - GstOptSchedulerState state; + GstOptSchedulerState state; - cothread_context *context; - gboolean use_cothreads; + cothread_context *context; + gboolean use_cothreads; + gint iterations; - GSList *elements; - GSList *chains; + GSList *elements; + GSList *chains; + + GList *runqueue; + gint recursion; }; struct _GstOptSchedulerClass { @@ -154,10 +159,22 @@ gint element_type; }; +enum +{ + ARG_0, + ARG_USE_COTHREADS, + ARG_ITERATIONS, +}; + static void gst_opt_scheduler_class_init (GstOptSchedulerClass *klass); static void gst_opt_scheduler_init (GstOptScheduler *scheduler); +static void gst_opt_scheduler_set_property (GObject *object, guint prop_id, + const GValue *value, GParamSpec *pspec); +static void gst_opt_scheduler_get_property (GObject *object, guint prop_id, + GValue *value, GParamSpec *pspec); + static void gst_opt_scheduler_dispose (GObject *object); static void gst_opt_scheduler_setup (GstScheduler *sched); @@ -218,8 +235,17 @@ parent_class = g_type_class_ref (GST_TYPE_SCHEDULER); + gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_opt_scheduler_set_property); + gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_opt_scheduler_get_property); gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_opt_scheduler_dispose); + g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_USE_COTHREADS, + g_param_spec_boolean ("use_cothreads", "Use cothreads", "Should this scheduler use cothreads", + TRUE, G_PARAM_READWRITE)); + g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_USE_COTHREADS, + g_param_spec_int ("iterations", "Iterations", "Number of groups to schedule in one iteration (-1 == until EOS/error)", + -1, G_MAXINT, 1, G_PARAM_READWRITE)); + gstscheduler_class->setup = GST_DEBUG_FUNCPTR (gst_opt_scheduler_setup); gstscheduler_class->reset = GST_DEBUG_FUNCPTR (gst_opt_scheduler_reset); gstscheduler_class->add_element = GST_DEBUG_FUNCPTR (gst_opt_scheduler_add_element); @@ -242,8 +268,9 @@ gst_opt_scheduler_init (GstOptScheduler *scheduler) { scheduler->elements = NULL; - scheduler->use_cothreads = FALSE; + //scheduler->use_cothreads = FALSE; scheduler->use_cothreads = TRUE; + scheduler->iterations = 1; } static void @@ -279,31 +306,6 @@ plugin_init }; -/* - * Entry points for this scheduler. - */ -static void -gst_opt_scheduler_setup (GstScheduler *sched) -{ - GstOptScheduler *osched = GST_OPT_SCHEDULER_CAST (sched); - - /* first create thread context */ - if (osched->context == NULL && osched->use_cothreads) { - GST_DEBUG (GST_CAT_SCHEDULING, "initializing cothread context"); - osched->context = do_cothread_context_init (); - } -} - -static void -gst_opt_scheduler_reset (GstScheduler *sched) -{ - GstOptScheduler *osched = GST_OPT_SCHEDULER_CAST (sched); - - if (osched->context && osched->use_cothreads) { - do_cothread_context_destroy (osched->context); - osched->context = NULL; - } -} static void delete_chain (GstOptScheduler *osched, GstOptSchedulerChain *chain) @@ -506,6 +508,9 @@ } */ +/* this function enables/disables an element, it will set/clear a flag on the element + * and tells the chain that the group is enabled if all elements inside the group are + * enabled */ static void group_element_set_enabled (GstOptSchedulerGroup *group, GstElement *element, gboolean enabled) { @@ -531,86 +536,91 @@ } } -static int +/* a group is scheduled by doing a cothread switch to it or + * by calling the schedule function. In the non-cothread case + * we cannot run already running groups so we return FALSE here + * to indicate this to the caller */ +static gboolean schedule_group (GstOptSchedulerGroup *group) { if (group->chain->sched->use_cothreads) { if (group->cothread) do_cothread_switch (group->cothread); - return 1; + return TRUE; } else { - /* in the no cothread case, we cannot schedule already running groups */ - if (!(group->flags & GST_OPT_SCHEDULER_GROUP_RUNNING)) { - group->schedulefunc (group->argc, group->argv); - return 1; - } + group->schedulefunc (group->argc, group->argv); + return TRUE; } - return 0; + return FALSE; } -static void -schedule_chain (GstOptSchedulerChain *chain) +static void +gst_opt_scheduler_schedule_run_queue (GstOptScheduler *osched) { - GSList *groups = chain->groups; + GST_INFO (GST_CAT_SCHEDULING, "entering scheduler run queue recursion %d", osched->recursion); - while (groups) { - GstOptSchedulerGroup *group = (GstOptSchedulerGroup *) groups->data; - groups = g_slist_next (groups); + osched->recursion++; - if (!GST_OPT_SCHEDULER_GROUP_IS_DISABLED (group)) { - GST_INFO (GST_CAT_SCHEDULING, "scheduling group %p in chain %p", - group, chain); + while (osched->runqueue) { + GstOptSchedulerGroup *group; + + group = (GstOptSchedulerGroup *) osched->runqueue->data; + osched->runqueue = g_list_remove (osched->runqueue, group); - schedule_group (group); - break; - } - } -} + GST_INFO (GST_CAT_SCHEDULING, "scheduling %p", group); -static void -gst_opt_scheduler_add_element (GstScheduler *sched, GstElement *element) -{ - GstOptScheduler *osched = GST_OPT_SCHEDULER_CAST (sched); - GstOptSchedulerCtx *ctx; + schedule_group (group); - GST_INFO (GST_CAT_SCHEDULING, "adding element \"%s\" to scheduler", GST_ELEMENT_NAME (element)); + GST_INFO (GST_CAT_SCHEDULING, "done scheduling %p", group); + } - if (GST_ELEMENT_IS_DECOUPLED (element)) - return; + GST_INFO (GST_CAT_SCHEDULING, "run queue length after scheduling %d", g_list_length (osched->runqueue)); - ctx = g_new0 (GstOptSchedulerCtx, 1); - GST_ELEMENT_SCHED_CONTEXT (element) = ctx; + osched->recursion--; +} - if (element->loopfunc) { - GstOptSchedulerGroup *group; - GstOptSchedulerChain *chain; +/* a chain is scheduled by picking the first active group and scheduling it */ +static void +schedule_chain (GstOptSchedulerChain *chain) +{ + GSList *groups = chain->groups; - chain = create_chain (osched); + while (groups) { + GstOptSchedulerGroup *group = (GstOptSchedulerGroup *) groups->data; - group = create_group (chain, element); - group->entry = element; - group->type = GST_OPT_SCHEDULER_GROUP_LOOP; + groups = g_slist_next (groups); - GST_INFO (GST_CAT_SCHEDULING, "added element \"%s\" as loop based entry", GST_ELEMENT_NAME (element)); - } -} + if (!GST_OPT_SCHEDULER_GROUP_IS_DISABLED (group)) { + GstOptScheduler *osched; -static void -gst_opt_scheduler_remove_element (GstScheduler *sched, GstElement *element) -{ - //GstOptScheduler *osched = GST_OPT_SCHEDULER_CAST (sched); + osched = chain->sched; - GST_INFO (GST_CAT_SCHEDULING, "removing element \"%s\" from scheduler", GST_ELEMENT_NAME (element)); + GST_INFO (GST_CAT_SCHEDULING, "scheduling group %p in chain %p", + group, chain); - g_free (GST_ELEMENT_SCHED_CONTEXT (element)); - GST_ELEMENT_SCHED_CONTEXT (element) = NULL; + if (osched->use_cothreads) { + schedule_group (group); + } + else { + osched->recursion = 0; + osched->runqueue = g_list_append (osched->runqueue, group); + gst_opt_scheduler_schedule_run_queue (osched); + } - g_warning ("remove implement me"); + GST_INFO (GST_CAT_SCHEDULING, "done scheduling group %p in chain %p", + group, chain); + break; + } + } } +/* a get-based group is scheduled by getting a buffer from the get based + * entry point and by pushing the buffer to the peer. + * We also set the running flag on this group for as long as this + * function is running. */ static int -get_wrapper (int argc, char *argv[]) +get_group_schedule_function (int argc, char *argv[]) { GstOptSchedulerGroup *group = (GstOptSchedulerGroup *) argv; const GList *pads = gst_element_get_pad_list (group->entry); @@ -641,8 +651,12 @@ return 0; } +/* a loop-based group is scheduled by calling the loop function + * on the entry point. + * We also set the running flag on this group for as long as this + * function is running. */ static int -loop_wrapper (int argc, char *argv[]) +loop_group_schedule_function (int argc, char *argv[]) { GstOptSchedulerGroup *group = (GstOptSchedulerGroup *) argv; GstElement *entry = group->entry; @@ -662,8 +676,9 @@ } +/* the function to schedule an unkown group, which just gives an error */ static int -unkown_wrapper (int argc, char *argv[]) +unkown_group_schedule_function (int argc, char *argv[]) { GstOptSchedulerGroup *group = (GstOptSchedulerGroup *) argv; @@ -674,59 +689,89 @@ return 0; } +/* this function is called when the first element of a chain-loop or a loop-loop + * connection performs a push to the loop element. We then schedule the + * group with the loop-based element until the bufpen is empty */ static void gst_opt_scheduler_loop_wrapper (GstPad *sinkpad, GstBuffer *buffer) { GstOptSchedulerGroup *group; + GstOptScheduler *osched; GST_INFO (GST_CAT_SCHEDULING, "loop wrapper, putting buffer in bufpen"); group = GST_ELEMENT_SCHED_GROUP (GST_PAD_PARENT (sinkpad)); + osched = group->chain->sched; - if (GST_RPAD_BUFPEN (GST_RPAD_PEER (sinkpad))) { - g_warning ("scheduling error, bufpen not empty, disabling group %p", group); - chain_group_set_enabled (group->chain, group, FALSE); - group->chain->sched->state = GST_OPT_SCHEDULER_STATE_ERROR; - return; - } - GST_RPAD_BUFPEN (GST_RPAD_PEER (sinkpad)) = buffer; - - while (GST_RPAD_BUFPEN (GST_RPAD_PEER (sinkpad))) { - if (!schedule_group (group)) - break; + if (osched->use_cothreads) { + if (GST_PAD_BUFLIST (GST_RPAD_PEER (sinkpad))) { + g_warning ("deadlock detected, disabling group %p", group); + chain_group_set_enabled (group->chain, group, FALSE); + group->chain->sched->state = GST_OPT_SCHEDULER_STATE_ERROR; + } + else { + GST_PAD_BUFLIST (GST_RPAD_PEER (sinkpad)) = g_list_append (GST_PAD_BUFLIST (GST_RPAD_PEER (sinkpad)), buffer); + schedule_group (group); + } } + else if (!(group->flags & GST_OPT_SCHEDULER_GROUP_RUNNING)) { + GST_PAD_BUFLIST (GST_RPAD_PEER (sinkpad)) = g_list_append (GST_PAD_BUFLIST (GST_RPAD_PEER (sinkpad)), buffer); + osched->runqueue = g_list_append (osched->runqueue, group); + } + + GST_INFO (GST_CAT_SCHEDULING, "after loop wrapper buflist %d", + g_list_length (GST_PAD_BUFLIST (GST_RPAD_PEER (sinkpad)))); } +/* this function is called by a loop based element that performs a + * pull on a sinkpad. We schedule the peer group until the bufpen + * is filled with the buffer so that this function can return */ static GstBuffer* gst_opt_scheduler_get_wrapper (GstPad *srcpad) { - GstBuffer *buffer; + GstBuffer *buffer = NULL; GST_INFO (GST_CAT_SCHEDULING, "get wrapper, removing buffer from bufpen"); - buffer = GST_RPAD_BUFPEN (srcpad); + if (GST_PAD_BUFLIST (srcpad)) + buffer = GST_PAD_BUFLIST (srcpad)->data; while (!buffer) { GstOptSchedulerGroup *group; + GstOptScheduler *osched; group = GST_ELEMENT_SCHED_GROUP (GST_PAD_PARENT (srcpad)); + osched = group->chain->sched; - if (!schedule_group (group)) { + if (osched->use_cothreads) { + schedule_group (group); + } + else if (!(group->flags & GST_OPT_SCHEDULER_GROUP_RUNNING)) { + osched->runqueue = g_list_append (osched->runqueue, group); + gst_opt_scheduler_schedule_run_queue (osched); + } + else { g_warning ("deadlock detected, disabling group %p", group); chain_group_set_enabled (group->chain, group, FALSE); group->chain->sched->state = GST_OPT_SCHEDULER_STATE_ERROR; return NULL; } - buffer = GST_RPAD_BUFPEN (srcpad); + if (GST_PAD_BUFLIST (srcpad)) { + buffer = (GstBuffer *) GST_PAD_BUFLIST (srcpad)->data; + } } + GST_PAD_BUFLIST (srcpad) = g_list_remove (GST_PAD_BUFLIST (srcpad), buffer); - GST_RPAD_BUFPEN (srcpad) = NULL; + GST_INFO (GST_CAT_SCHEDULING, "get wrapper, returning buffer %d", + g_list_length (GST_PAD_BUFLIST (srcpad))); return buffer; } +/* this function is a chain wrapper for non-event-aware plugins, + * it'll simply dispatch the events to the (default) event handler */ static void gst_opt_scheduler_chain_wrapper (GstPad *sinkpad, GstBuffer *buffer) { @@ -738,17 +783,21 @@ } } +/* setup the scheduler context for a group. The right schedule function + * is selected based on the group type and cothreads are created if + * needed */ static void setup_group_scheduler (GstOptScheduler *osched, GstOptSchedulerGroup *group) { GroupScheduleFunction wrapper; - wrapper = unkown_wrapper; + wrapper = unkown_group_schedule_function; + /* figure out the wrapper function for this group */ if (group->type == GST_OPT_SCHEDULER_GROUP_GET) - wrapper = get_wrapper; + wrapper = get_group_schedule_function; else if (group->type == GST_OPT_SCHEDULER_GROUP_LOOP) - wrapper = loop_wrapper; + wrapper = loop_group_schedule_function; if (osched->use_cothreads) { if (!(group->flags & GST_OPT_SCHEDULER_GROUP_SCHEDULABLE)) { @@ -773,9 +822,11 @@ { GstOptScheduler *osched = GST_OPT_SCHEDULER_CAST (sched); GstOptSchedulerGroup *group; + GstElementStateReturn res = GST_STATE_SUCCESS; GST_INFO (GST_CAT_SCHEDULING, "element \"%s\" state change %d", GST_ELEMENT_NAME (element), transition); + /* we check the state of the managing pipeline here */ if (GST_IS_BIN (element)) { if (GST_SCHEDULER_PARENT (sched) == element) { GST_INFO (GST_CAT_SCHEDULING, "parent \"%s\" changed state", GST_ELEMENT_NAME (element)); @@ -793,58 +844,38 @@ GST_INFO (GST_CAT_SCHEDULING, "no interesting state change, doing nothing"); } } - return GST_STATE_SUCCESS; + return res; } + /* we don't care about decoupled elements after this */ if (GST_ELEMENT_IS_DECOUPLED (element)) return GST_STATE_SUCCESS; + /* get the group of the element */ group = GST_ELEMENT_SCHED_GROUP (element); switch (transition) { case GST_STATE_PAUSED_TO_PLAYING: - setup_group_scheduler (osched, group); - group_element_set_enabled (group, element, TRUE); + /* an element withut a group has to be an unconnected src, sink + * filter element */ + if (!group) + res = GST_STATE_FAILURE; + /* else construct the scheduling context of this group and enable it */ + else { + setup_group_scheduler (osched, group); + group_element_set_enabled (group, element, TRUE); + } break; case GST_STATE_PLAYING_TO_PAUSED: - group_element_set_enabled (group, element, FALSE); + /* if the element still has a group, we disable it */ + if (group) + group_element_set_enabled (group, element, FALSE); break; default: break; } - return GST_STATE_SUCCESS; -} - -static void -gst_opt_scheduler_lock_element (GstScheduler *sched, GstElement *element) -{ - //GstOptScheduler *osched = GST_OPT_SCHEDULER_CAST (sched); -} - -static void -gst_opt_scheduler_unlock_element (GstScheduler *sched, GstElement *element) -{ - //GstOptScheduler *osched = GST_OPT_SCHEDULER_CAST (sched); -} - -static void -gst_opt_scheduler_yield (GstScheduler *sched, GstElement *element) -{ - //GstOptScheduler *osched = GST_OPT_SCHEDULER_CAST (sched); -} - -static gboolean -gst_opt_scheduler_interrupt (GstScheduler *sched, GstElement *element) -{ - //GstOptScheduler *osched = GST_OPT_SCHEDULER_CAST (sched); - return TRUE; -} - -static void -gst_opt_scheduler_error (GstScheduler *sched, GstElement *element) -{ - //GstOptScheduler *osched = GST_OPT_SCHEDULER_CAST (sched); + return res; } /* @@ -917,6 +948,114 @@ GST_OPT_LOOP_TO_LOOP, } ConnectionType; +/* + * Entry points for this scheduler. + */ +static void +gst_opt_scheduler_setup (GstScheduler *sched) +{ + GstOptScheduler *osched = GST_OPT_SCHEDULER_CAST (sched); + + /* first create thread context */ + if (osched->context == NULL && osched->use_cothreads) { + GST_DEBUG (GST_CAT_SCHEDULING, "initializing cothread context"); + osched->context = do_cothread_context_init (); + } +} + +static void +gst_opt_scheduler_reset (GstScheduler *sched) +{ + GstOptScheduler *osched = GST_OPT_SCHEDULER_CAST (sched); + + if (osched->context && osched->use_cothreads) { + do_cothread_context_destroy (osched->context); + osched->context = NULL; + } +} +static void +gst_opt_scheduler_add_element (GstScheduler *sched, GstElement *element) +{ + GstOptScheduler *osched = GST_OPT_SCHEDULER_CAST (sched); + GstOptSchedulerCtx *ctx; + + GST_INFO (GST_CAT_SCHEDULING, "adding element \"%s\" to scheduler", GST_ELEMENT_NAME (element)); + + /* decoupled elements are not added to the scheduler lists */ + if (GST_ELEMENT_IS_DECOUPLED (element)) + return; + + ctx = g_new0 (GstOptSchedulerCtx, 1); + GST_ELEMENT_SCHED_CONTEXT (element) = ctx; + + /* loop based elements *always* end up in their own group. It can eventually + * be merged with another group when a connection is made */ + if (element->loopfunc) { + GstOptSchedulerGroup *group; + GstOptSchedulerChain *chain; + + chain = create_chain (osched); + + group = create_group (chain, element); + group->entry = element; + group->type = GST_OPT_SCHEDULER_GROUP_LOOP; + + GST_INFO (GST_CAT_SCHEDULING, "added element \"%s\" as loop based entry", GST_ELEMENT_NAME (element)); + } +} + +static void +gst_opt_scheduler_remove_element (GstScheduler *sched, GstElement *element) +{ + //GstOptScheduler *osched = GST_OPT_SCHEDULER_CAST (sched); + + GST_INFO (GST_CAT_SCHEDULING, "removing element \"%s\" from scheduler", GST_ELEMENT_NAME (element)); + + g_free (GST_ELEMENT_SCHED_CONTEXT (element)); + GST_ELEMENT_SCHED_CONTEXT (element) = NULL; + + g_warning ("remove implement me"); +} + +static void +gst_opt_scheduler_lock_element (GstScheduler *sched, GstElement *element) +{ + //GstOptScheduler *osched = GST_OPT_SCHEDULER_CAST (sched); + g_warning ("lock element, implement me"); +} + +static void +gst_opt_scheduler_unlock_element (GstScheduler *sched, GstElement *element) +{ + //GstOptScheduler *osched = GST_OPT_SCHEDULER_CAST (sched); + g_warning ("unlock element, implement me"); +} + +static void +gst_opt_scheduler_yield (GstScheduler *sched, GstElement *element) +{ + //GstOptScheduler *osched = GST_OPT_SCHEDULER_CAST (sched); +} + +static gboolean +gst_opt_scheduler_interrupt (GstScheduler *sched, GstElement *element) +{ + //GstOptScheduler *osched = GST_OPT_SCHEDULER_CAST (sched); + + g_warning ("interrupt element, implement me"); + + return TRUE; +} + +static void +gst_opt_scheduler_error (GstScheduler *sched, GstElement *element) +{ + GstOptScheduler *osched = GST_OPT_SCHEDULER_CAST (sched); + + osched->state = GST_OPT_SCHEDULER_STATE_ERROR; +} + +/* connect pads, merge groups and chains */ static void gst_opt_scheduler_pad_connect (GstScheduler *sched, GstPad *srcpad, GstPad *sinkpad) { @@ -1056,6 +1195,9 @@ gst_opt_scheduler_pad_select (GstScheduler *sched, GList *padlist) { //GstOptScheduler *osched = GST_OPT_SCHEDULER_CAST (sched); + + g_warning ("pad select, implement me"); + return NULL; } @@ -1066,35 +1208,51 @@ return gst_clock_wait (clock, time, jitter); } +/* a scheduler iteration is done by looping and scheduling the active chains */ static GstSchedulerState gst_opt_scheduler_iterate (GstScheduler *sched) { - GstSchedulerState state; + GstSchedulerState state = GST_SCHEDULER_STATE_STOPPED; GstOptScheduler *osched = GST_OPT_SCHEDULER_CAST (sched); - GSList *chains; - gboolean scheduled = FALSE; + gint iterations = osched->iterations; osched->state = GST_OPT_SCHEDULER_STATE_RUNNING; - chains = osched->chains; - while (chains) { - GstOptSchedulerChain *chain = (GstOptSchedulerChain *) chains->data; - chains = g_slist_next (chains); + while (iterations) { + gboolean scheduled = FALSE; + GSList *chains; - if (!GST_OPT_SCHEDULER_CHAIN_IS_DISABLED (chain)) { - schedule_chain (chain); - scheduled = TRUE; + /* we have to schedule each of the scheduler chains now */ + chains = osched->chains; + while (chains) { + GstOptSchedulerChain *chain = (GstOptSchedulerChain *) chains->data; + chains = g_slist_next (chains); + + /* if the chain is not disabled, schedule it */ + if (!GST_OPT_SCHEDULER_CHAIN_IS_DISABLED (chain)) { + schedule_chain (chain); + scheduled = TRUE; + } } - } - if (osched->state == GST_OPT_SCHEDULER_STATE_ERROR) { - state = GST_SCHEDULER_STATE_ERROR; - } - else { - if (scheduled) - state = GST_SCHEDULER_STATE (sched); - else - state = GST_SCHEDULER_STATE_STOPPED; + /* at this point it's possible that the scheduler state is + * in error, we then return an error */ + if (osched->state == GST_OPT_SCHEDULER_STATE_ERROR) { + state = GST_SCHEDULER_STATE_ERROR; + break; + } + else { + /* if chains were scheduled, return our current state */ + if (scheduled) + state = GST_SCHEDULER_STATE (sched); + /* if no chains were scheduled, we say we are stopped */ + else { + state = GST_SCHEDULER_STATE_STOPPED; + break; + } + } + if (iterations > 0) + iterations--; } return state; @@ -1134,3 +1292,50 @@ } } } + +static void +gst_opt_scheduler_get_property (GObject *object, guint prop_id, + GValue *value, GParamSpec *pspec) +{ + GstOptScheduler *osched; + + g_return_if_fail (GST_IS_OPT_SCHEDULER (object)); + + osched = GST_OPT_SCHEDULER_CAST (object); + + switch (prop_id) { + case ARG_USE_COTHREADS: + g_value_set_boolean (value, osched->use_cothreads); + break; + case ARG_ITERATIONS: + g_value_set_int (value, osched->iterations); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +gst_opt_scheduler_set_property (GObject *object, guint prop_id, + const GValue *value, GParamSpec *pspec) +{ + GstOptScheduler *osched; + + g_return_if_fail (GST_IS_OPT_SCHEDULER (object)); + + osched = GST_OPT_SCHEDULER_CAST (object); + + switch (prop_id) { + case ARG_USE_COTHREADS: + osched->use_cothreads = g_value_get_boolean (value); + break; + case ARG_ITERATIONS: + osched->iterations = g_value_get_int (value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + |
From: Wim T. <wt...@us...> - 2002-09-12 21:01:10
|
CVS Root: /cvsroot/gstreamer Module: gstreamer Changes by: wtay Date: Thu Sep 12 2002 14:01:09 PDT Log message: Added optimal scheduler to build and call it optomega Modified files: gst/schedulers : Makefile.am gstoptimalscheduler.c Links: http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/gst/schedulers/Makefile.am.diff?r1=1.21&r2=1.22 http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/gst/schedulers/gstoptimalscheduler.c.diff?r1=1.3&r2=1.4 ====Begin Diffs==== Index: Makefile.am =================================================================== RCS file: /cvsroot/gstreamer/gstreamer/gst/schedulers/Makefile.am,v retrieving revision 1.21 retrieving revision 1.22 diff -u -d -r1.21 -r1.22 --- Makefile.am 12 Sep 2002 19:23:41 -0000 1.21 +++ Makefile.am 12 Sep 2002 21:00:56 -0000 1.22 @@ -4,7 +4,8 @@ libgstbasicomegascheduler.la \ libgstbasicwingoscheduler.la \ libgstfastomegascheduler.la \ - libgstfastwingoscheduler.la + libgstfastwingoscheduler.la \ + libgstoptomegascheduler.la libgstbasicomegascheduler_la_SOURCES = gstbasicscheduler.c libgstbasicomegascheduler_la_CFLAGS = $(GST_CFLAGS) -D_COTHREADS_OMEGA @@ -33,6 +34,11 @@ libgstfastwingoscheduler_la_CFLAGS += -I$(top_srcdir)/libs/ext/cothreads libgstfastwingoscheduler_la_LIBADD = $(top_builddir)/libs/ext/cothreads/cothreads/libcothreads-gthreads.la libgstfastwingoscheduler_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) + +libgstoptomegascheduler_la_SOURCES = gstoptimalscheduler.c +libgstoptomegascheduler_la_CFLAGS = $(GST_CFLAGS) -D_COTHREADS_OMEGA +libgstoptomegascheduler_la_LIBADD = ../libcothreads.la +libgstoptomegascheduler_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) ## this is a REALLY evil hack ## but we need to keep it as long as we have libs/gst and libs/ext Index: gstoptimalscheduler.c =================================================================== RCS file: /cvsroot/gstreamer/gstreamer/gst/schedulers/gstoptimalscheduler.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- gstoptimalscheduler.c 12 Sep 2002 19:22:03 -0000 1.3 +++ gstoptimalscheduler.c 12 Sep 2002 21:00:57 -0000 1.4 @@ -286,8 +286,8 @@ gst_plugin_set_longname (plugin, "An optimal scheduler"); - factory = gst_scheduler_factory_new ("optimal", - "An optimal scheduler", + factory = gst_scheduler_factory_new ("opt"COTHREADS_NAME, + "An optimal scheduler using "COTHREADS_NAME" cothreads", gst_opt_scheduler_get_type()); if (factory != NULL) { @@ -302,7 +302,7 @@ GstPluginDesc plugin_desc = { GST_VERSION_MAJOR, GST_VERSION_MINOR, - "gstoptimalscheduler", + "gstopt"COTHREADS_NAME"scheduler", plugin_init }; |
From: Wim T. <wt...@us...> - 2002-11-07 18:50:21
|
CVS Root: /cvsroot/gstreamer Module: gstreamer Changes by: wtay Date: Thu Nov 07 2002 10:50:19 PST Log message: Remove groups from chains and elements from groups when they are destroyed. Modified files: gst/schedulers : gstoptimalscheduler.c Links: http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/gst/schedulers/gstoptimalscheduler.c.diff?r1=1.6&r2=1.7 ====Begin Diffs==== Index: gstoptimalscheduler.c =================================================================== RCS file: /cvsroot/gstreamer/gstreamer/gst/schedulers/gstoptimalscheduler.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- gstoptimalscheduler.c 2 Nov 2002 13:54:34 -0000 1.6 +++ gstoptimalscheduler.c 7 Nov 2002 18:50:06 -0000 1.7 @@ -313,12 +313,23 @@ static void delete_chain (GstOptScheduler *osched, GstOptSchedulerChain *chain) { + GSList *groups; + GST_INFO (GST_CAT_SCHEDULING, "delete chain %p", chain); g_assert (chain->sched == osched); osched->chains = g_slist_remove (osched->chains, chain); + groups = chain->groups; + while (groups) { + GstOptSchedulerGroup *group = (GstOptSchedulerGroup *) groups->data; + + group->chain = NULL; + + groups = g_slist_next (groups); + } + g_slist_free (chain->groups); g_free (chain); } @@ -460,6 +471,8 @@ static void delete_group (GstOptSchedulerGroup *group) { + GSList *elements; + GST_INFO (GST_CAT_SCHEDULING, "delete group %p", group); g_assert (group->chain == NULL); @@ -467,6 +480,16 @@ if (group->flags & GST_OPT_SCHEDULER_GROUP_SCHEDULABLE) destroy_group_scheduler (group); + /* remove all elements from the group */ + elements = group->elements; + while (elements) { + GstElement *element = GST_ELEMENT (elements->data); + + GST_ELEMENT_SCHED_GROUP (element) = NULL; + + elements = g_slist_next (elements); + } + g_slist_free (group->elements); g_free (group); } @@ -1030,9 +1053,14 @@ /* the element is guaranteed to live in it's own group/chain now */ get_group (element, &group); if (group) { + if (group->chain) { - remove_from_chain (group->chain, group); - delete_chain (osched, group->chain); + GstOptSchedulerChain *chain; + + chain = group->chain; + + remove_from_chain (chain, group); + delete_chain (osched, chain); } delete_group (group); |
From: Wim T. <wt...@us...> - 2002-11-22 23:17:51
|
CVS Root: /cvsroot/gstreamer Module: gstreamer Changes by: wtay Date: Fri Nov 22 2002 15:17:51 PST Log message: Make sure to unset the scheduler Modified files: gst/schedulers : gstoptimalscheduler.c Links: http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/gst/schedulers/gstoptimalscheduler.c.diff?r1=1.7&r2=1.8 ====Begin Diffs==== Index: gstoptimalscheduler.c =================================================================== RCS file: /cvsroot/gstreamer/gstreamer/gst/schedulers/gstoptimalscheduler.c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- gstoptimalscheduler.c 7 Nov 2002 18:50:06 -0000 1.7 +++ gstoptimalscheduler.c 22 Nov 2002 23:17:39 -0000 1.8 @@ -1054,6 +1054,8 @@ get_group (element, &group); if (group) { + GST_ELEMENT_SCHED_GROUP (element) = NULL; + if (group->chain) { GstOptSchedulerChain *chain; |
From: Wim T. <wt...@us...> - 2002-11-25 00:21:05
|
CVS Root: /cvsroot/gstreamer Module: gstreamer Changes by: wtay Date: Sun Nov 24 2002 16:21:04 PST Log message: Make different names for the different cothreads implementations Modified files: gst/schedulers : gstoptimalscheduler.c Links: http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/gst/schedulers/gstoptimalscheduler.c.diff?r1=1.8&r2=1.9 ====Begin Diffs==== Index: gstoptimalscheduler.c =================================================================== RCS file: /cvsroot/gstreamer/gstreamer/gst/schedulers/gstoptimalscheduler.c,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- gstoptimalscheduler.c 22 Nov 2002 23:17:39 -0000 1.8 +++ gstoptimalscheduler.c 25 Nov 2002 00:20:52 -0000 1.9 @@ -220,7 +220,8 @@ NULL }; - _gst_opt_scheduler_type = g_type_register_static (GST_TYPE_SCHEDULER, "GstOptScheduler", &scheduler_info, 0); + _gst_opt_scheduler_type = g_type_register_static (GST_TYPE_SCHEDULER, + "GstOpt"COTHREADS_NAME_CAPITAL"Scheduler", &scheduler_info, 0); } return _gst_opt_scheduler_type; } |