diff options
author | Wim Taymans <wim.taymans@gmail.com> | 2005-07-18 12:49:53 +0000 |
---|---|---|
committer | Wim Taymans <wim.taymans@gmail.com> | 2005-07-18 12:49:53 +0000 |
commit | e1aeec6d775a777295669ccd0165bd477e476025 (patch) | |
tree | c1b63c41ddc86d057e4b2150cdb3474f1f2e887e | |
parent | fba0bf771b53b87d6a54dcb707e4299b93a4ff3c (diff) |
Removed plugable schedulers.
Original commit message from CVS:
Removed plugable schedulers.
Removed Scheduler/Manager from elements.
Removed gsttypes.h, rearranged includes.
Removed dependency pad<->element, element<>pipeline, and
various others, fix includes.
implement gst_pad_get_parent() with gst_object_get_parent()
Make GstTask sefcontained.
Fix _get_state() on GstBin, it did not return ASYNC with a 0
timeout.
Fix endless loop in iterator_fold_with_resync.
46 files changed, 324 insertions, 1558 deletions
@@ -1,5 +1,78 @@ 2005-07-18 Wim Taymans <wim@fluendo.com> + * check/elements/gstfakesrc.c: (GST_START_TEST): + * configure.ac: + * gst/Makefile.am: + * gst/gst.c: (gst_init_get_popt_table), (init_pre), (init_post), + (init_popt_callback): + * gst/gst.h: + * gst/gst_private.h: + * gst/gstbin.c: (gst_bin_class_init), (gst_bin_add_func), + (gst_bin_remove_func), (gst_bin_get_state), (gst_bin_change_state): + * gst/gstbin.h: + * gst/gstbus.h: + * gst/gstconfig.h.in: + * gst/gstelement.c: (gst_element_class_init), + (gst_element_set_base_time), (gst_element_get_base_time), + (iterator_fold_with_resync), (gst_element_change_state), + (gst_element_dispose), (gst_element_get_bus): + * gst/gstelement.h: + * gst/gstelementfactory.h: + * gst/gsterror.c: (_gst_core_errors_init): + * gst/gsterror.h: + * gst/gstevent.h: + * gst/gstghostpad.c: (gst_ghost_pad_do_activate_push): + * gst/gstindex.c: + * gst/gstinfo.c: (_gst_debug_init): + * gst/gstmessage.c: (_gst_message_copy): + * gst/gstmessage.h: + * gst/gstminiobject.h: + * gst/gstobject.c: + * gst/gstobject.h: + * gst/gstpad.c: (gst_pad_get_caps_unlocked), (gst_pad_accept_caps), + (gst_pad_set_caps), (gst_pad_start_task), (gst_pad_stop_task): + * gst/gstpad.h: + * gst/gstparse.h: + * gst/gstpipeline.c: (gst_pipeline_init), (gst_pipeline_dispose), + (gst_pipeline_change_state), (gst_pipeline_set_new_stream_time), + (gst_pipeline_get_last_stream_time): + * gst/gstpipeline.h: + * gst/gstpluginfeature.h: + * gst/gstquery.h: + * gst/gstscheduler.c: + * gst/gstscheduler.h: + * gst/gststructure.h: + * gst/gsttask.c: (gst_task_get_type), (gst_task_class_init), + (gst_task_finalize), (gst_task_func), (gst_task_create), + (gst_task_set_lock), (gst_task_get_state), (gst_task_start), + (gst_task_stop), (gst_task_pause): + * gst/gsttask.h: + * gst/gsttypefind.h: + * gst/gsttypes.h: + * gst/registries/gstlibxmlregistry.c: (load_feature), + (gst_xml_registry_load), (gst_xml_registry_save_feature): + * gst/registries/gstxmlregistry.c: + (gst_xml_registry_start_element), (gst_xml_registry_save_feature): + * gst/schedulers/threadscheduler.c: + * libs/gst/control/dparammanager.h: + * tools/gst-inspect.c: (print_element_list), + (print_plugin_features), (print_element_features): + * tools/gst-xmlinspect.c: (print_element_list), + (print_plugin_info), (main): + Removed plugable schedulers. + Removed Scheduler/Manager from elements. + Removed gsttypes.h, rearranged includes. + Removed dependency pad<->element, element<>pipeline, and + various others, fix includes. + implement gst_pad_get_parent() with gst_object_get_parent() + Make GstTask sefcontained. + Fix _get_state() on GstBin, it did not return ASYNC with a 0 + timeout. + Fix endless loop in iterator_fold_with_resync. + + +2005-07-18 Wim Taymans <wim@fluendo.com> + * gst/Makefile.am: * gst/gstarch.h: Remove old file. diff --git a/check/elements/gstfakesrc.c b/check/elements/gstfakesrc.c index 85be97f14..febebea3f 100644 --- a/check/elements/gstfakesrc.c +++ b/check/elements/gstfakesrc.c @@ -60,7 +60,6 @@ event_func (GstPad * pad, GstEvent * event) GST_START_TEST (test_num_buffers) { GstElement *src; - GstScheduler *scheduler; GstPad *srcpad, *sinkpad; src = gst_element_factory_make ("fakesrc", "src"); @@ -73,9 +72,6 @@ GST_START_TEST (test_num_buffers) g_object_set (G_OBJECT (src), "num-buffers", 3, NULL); - scheduler = gst_scheduler_factory_make (NULL, src); - gst_element_set_scheduler (src, scheduler); - srcpad = gst_element_get_pad (src, "src"); fail_if (srcpad == NULL, "Could not get source pad from fakesrc"); gst_pad_set_caps (sinkpad, NULL); diff --git a/configure.ac b/configure.ac index a9237e35a..ca3eff5d1 100644 --- a/configure.ac +++ b/configure.ac @@ -653,7 +653,6 @@ gst/base/Makefile gst/indexers/Makefile gst/elements/Makefile gst/parse/Makefile -gst/schedulers/Makefile gst/registries/Makefile libs/Makefile libs/gst/Makefile diff --git a/gst/Makefile.am b/gst/Makefile.am index 98db1a949..08f5b40d7 100644 --- a/gst/Makefile.am +++ b/gst/Makefile.am @@ -61,8 +61,8 @@ else GST_URI_SRC = gsturi.c endif -SUBDIRS = $(GST_PARSE_DIRS) $(GST_REGISTRY_DIRS) . base elements schedulers $(GST_INDEX_DIRS) -DIST_SUBDIRS = base elements parse registries schedulers indexers +SUBDIRS = $(GST_PARSE_DIRS) $(GST_REGISTRY_DIRS) . base elements $(GST_INDEX_DIRS) +DIST_SUBDIRS = base elements parse registries indexers # make variables for all generated source and header files to make the # distinction clear @@ -103,7 +103,6 @@ libgstreamer_@GST_MAJORMINOR@_la_SOURCES = \ gstquery.c \ gstqueryutils.c \ gstqueue.c \ - gstscheduler.c \ gststructure.c \ gstsystemclock.c \ gsttag.c \ @@ -179,7 +178,6 @@ gst_headers = \ gstquery.h \ gstqueryutils.h \ gstqueue.h \ - gstscheduler.h \ gststructure.h \ gstsystemclock.h \ gsttag.h \ @@ -188,7 +186,6 @@ gst_headers = \ gsttrace.h \ gsttrashstack.h \ gsttypefind.h \ - gsttypes.h \ gsturi.h \ gsturitype.h \ gstutils.h \ @@ -93,7 +93,6 @@ enum ARG_PLUGIN_PATH, ARG_PLUGIN_LOAD, ARG_SEGTRAP_DISABLE, - ARG_SCHEDULER, ARG_REGISTRY }; @@ -191,8 +190,6 @@ gst_init_get_popt_table (void) ARG_SEGTRAP_DISABLE, N_("Disable trapping of segmentation faults during plugin loading"), NULL}, - {"gst-scheduler", NUL, POPT_ARG_STRING | POPT_ARGFLAG_STRIP, NULL, - ARG_SCHEDULER, NULL, N_("SCHEDULER")}, {"gst-registry", NUL, POPT_ARG_STRING | POPT_ARGFLAG_STRIP, NULL, ARG_REGISTRY, N_("Registry to use"), N_("REGISTRY")}, POPT_TABLEEND @@ -209,10 +206,6 @@ gst_init_get_popt_table (void) g_strdup_printf (_ ("path list for loading plugins (separated by '%s')"), G_SEARCHPATH_SEPARATOR_S); - } else if (strcmp (gstreamer_options[i].longName, "gst-scheduler") == 0) { - gstreamer_options[i].descrip = - g_strdup_printf (_("Scheduler to use (default is '%s')"), - GST_SCHEDULER_DEFAULT_NAME); } } @@ -500,8 +493,6 @@ init_pre (void) gst_registry_add_path (_global_registry, PLUGINS_BUILDDIR "/gst/elements"); gst_registry_add_path (_global_registry, PLUGINS_BUILDDIR "/gst/types"); gst_registry_add_path (_global_registry, PLUGINS_BUILDDIR "/gst/autoplug"); - gst_registry_add_path (_global_registry, - PLUGINS_BUILDDIR "/gst/schedulers"); gst_registry_add_path (_global_registry, PLUGINS_BUILDDIR "/gst/indexers"); #else /* add the main (installed) library path if GST_PLUGIN_PATH_ONLY not set */ @@ -585,7 +576,6 @@ init_post (void) gst_pad_get_type (); gst_element_factory_get_type (); gst_element_get_type (); - gst_scheduler_factory_get_type (); gst_type_find_factory_get_type (); gst_bin_get_type (); @@ -784,9 +774,6 @@ init_popt_callback (poptContext context, enum poptCallbackReason reason, case ARG_SEGTRAP_DISABLE: _gst_disable_segtrap = TRUE; break; - case ARG_SCHEDULER: - gst_scheduler_factory_set_default_name (arg); - break; case ARG_REGISTRY: #ifndef GST_DISABLE_REGISTRY g_object_set (G_OBJECT (_user_registry), "location", arg, NULL); @@ -28,7 +28,6 @@ #include <popt.h> #include <gst/gstenumtypes.h> -#include <gst/gsttypes.h> #include <gst/gstversion.h> #include <gst/gstbin.h> @@ -52,7 +51,6 @@ #include <gst/gstplugin.h> #include <gst/gstquery.h> #include <gst/gstqueryutils.h> -#include <gst/gstscheduler.h> #include <gst/gststructure.h> #include <gst/gstsystemclock.h> #include <gst/gsttag.h> diff --git a/gst/gst_private.h b/gst/gst_private.h index c1facbd8b..97fe87862 100644 --- a/gst/gst_private.h +++ b/gst/gst_private.h @@ -46,13 +46,10 @@ gboolean __gst_in_valgrind (void); #include <gst/gstinfo.h> extern GstDebugCategory *GST_CAT_GST_INIT; -extern GstDebugCategory *GST_CAT_COTHREADS; -extern GstDebugCategory *GST_CAT_COTHREAD_SWITCH; extern GstDebugCategory *GST_CAT_AUTOPLUG; extern GstDebugCategory *GST_CAT_AUTOPLUG_ATTEMPT; extern GstDebugCategory *GST_CAT_PARENTAGE; extern GstDebugCategory *GST_CAT_STATES; -extern GstDebugCategory *GST_CAT_PLANNING; extern GstDebugCategory *GST_CAT_SCHEDULING; extern GstDebugCategory *GST_CAT_BUFFER; extern GstDebugCategory *GST_CAT_CAPS; @@ -78,13 +75,10 @@ extern GstDebugCategory *GST_CAT_PROBE; #else #define GST_CAT_GST_INIT NULL -#define GST_CAT_COTHREADS NULL -#define GST_CAT_COTHREAD_SWITCH NULL #define GST_CAT_AUTOPLUG NULL #define GST_CAT_AUTOPLUG_ATTEMPT NULL #define GST_CAT_PARENTAGE NULL #define GST_CAT_STATES NULL -#define GST_CAT_PLANNING NULL #define GST_CAT_SCHEDULING NULL #define GST_CAT_DATAFLOW NULL #define GST_CAT_BUFFER NULL diff --git a/gst/gstbin.c b/gst/gstbin.c index 5a38c6402..a23394167 100644 --- a/gst/gstbin.c +++ b/gst/gstbin.c @@ -32,7 +32,6 @@ #include "gstinfo.h" #include "gsterror.h" -#include "gstscheduler.h" #include "gstindex.h" #include "gstutils.h" @@ -67,9 +66,6 @@ static void gst_bin_set_index_func (GstElement * element, GstIndex * index); static GstClock *gst_bin_get_clock_func (GstElement * element); static void gst_bin_set_clock_func (GstElement * element, GstClock * clock); -static void gst_bin_set_manager (GstElement * element, GstPipeline * manager); -static void gst_bin_set_scheduler (GstElement * element, GstScheduler * sched); - static gboolean gst_bin_send_event (GstElement * element, GstEvent * event); static GstBusSyncReply bin_bus_handler (GstBus * bus, GstMessage * message, GstBin * bin); @@ -179,8 +175,6 @@ gst_bin_class_init (GstBinClass * klass) #endif gstelement_class->get_clock = GST_DEBUG_FUNCPTR (gst_bin_get_clock_func); gstelement_class->set_clock = GST_DEBUG_FUNCPTR (gst_bin_set_clock_func); - gstelement_class->set_manager = GST_DEBUG_FUNCPTR (gst_bin_set_manager); - gstelement_class->set_scheduler = GST_DEBUG_FUNCPTR (gst_bin_set_scheduler); gstelement_class->send_event = GST_DEBUG_FUNCPTR (gst_bin_send_event); gstelement_class->query = GST_DEBUG_FUNCPTR (gst_bin_query); @@ -295,50 +289,6 @@ gst_bin_get_clock_func (GstElement * element) return result; } -/* set the scheduler on all of the children in this bin - * - * MT safe - */ -static void -gst_bin_set_scheduler (GstElement * element, GstScheduler * sched) -{ - GList *children; - GstBin *bin; - - bin = GST_BIN (element); - - parent_class->set_scheduler (element, sched); - - GST_LOCK (bin); - for (children = bin->children; children; children = g_list_next (children)) { - GstElement *child = GST_ELEMENT (children->data); - - gst_element_set_scheduler (child, sched); - } - GST_UNLOCK (bin); -} - -/* set the manager on all of the children in this bin - * - * MT safe - */ -static void -gst_bin_set_manager (GstElement * element, GstPipeline * manager) -{ - GstBin *bin = GST_BIN (element); - GList *kids; - GstElement *kid; - - GST_ELEMENT_CLASS (parent_class)->set_manager (element, manager); - - GST_LOCK (element); - for (kids = bin->children; kids != NULL; kids = kids->next) { - kid = GST_ELEMENT (kids->data); - gst_element_set_manager (kid, manager); - } - GST_UNLOCK (element); -} - static gboolean is_eos (GstBin * bin) { @@ -426,9 +376,9 @@ gst_bin_add_func (GstBin * bin, GstElement * element) bin->numchildren++; bin->children_cookie++; - gst_element_set_manager (element, GST_ELEMENT (bin)->manager); gst_element_set_bus (element, bin->child_bus); - gst_element_set_scheduler (element, GST_ELEMENT_SCHEDULER (bin)); + + gst_element_set_base_time (element, GST_ELEMENT (bin)->base_time); gst_element_set_clock (element, GST_ELEMENT_CLOCK (bin)); GST_UNLOCK (bin); @@ -552,9 +502,7 @@ gst_bin_remove_func (GstBin * bin, GstElement * element) elem_name); g_free (elem_name); - gst_element_set_manager (element, NULL); gst_element_set_bus (element, NULL); - gst_element_set_scheduler (element, NULL); /* unlock any waiters for the state change. It is possible that * we are waiting for an ASYNC state change on this element. The @@ -878,14 +826,10 @@ gst_bin_get_state (GstElement * element, GstElementState * state, GstElementStateReturn ret = GST_STATE_SUCCESS; GList *children; guint32 children_cookie; - gboolean zero_timeout; gboolean have_no_preroll; GST_CAT_INFO_OBJECT (GST_CAT_STATES, element, "getting state"); - zero_timeout = timeout != NULL && timeout->tv_sec == 0 - && timeout->tv_usec == 0; - /* lock bin, no element can be added or removed between going into * the quick scan and the blocking wait. */ GST_LOCK (bin); @@ -893,11 +837,11 @@ gst_bin_get_state (GstElement * element, GstElementState * state, restart: have_no_preroll = FALSE; - /* if we have a non zero timeout we must make sure not to block + /* first we need to poll with a non zero timeout to make sure we don't block * on the sinks when we have NO_PREROLL elements. This is why we do * a quick check if there are still NO_PREROLL elements. We also * catch the error elements this way. */ - if (!zero_timeout) { + { GTimeVal tv; gboolean have_async = FALSE; @@ -928,7 +872,7 @@ restart: } switch (ret) { - /* report FAILURE or NO_PREROLL immediatly */ + /* report FAILURE immediatly */ case GST_STATE_FAILURE: goto done; case GST_STATE_NO_PREROLL: @@ -996,13 +940,8 @@ restart: case GST_STATE_NO_PREROLL: /* report FAILURE and NO_PREROLL immediatly */ goto done; - break; case GST_STATE_ASYNC: - /* since we checked for non prerollable elements before, - * the first ASYNC return is the real return value */ - if (!zero_timeout) - goto done; - break; + goto done; default: g_assert_not_reached (); } @@ -1244,36 +1183,42 @@ restart: peer = gst_pad_get_peer (pad); if (peer) { - GstElement *peer_elem; + GstObject *peer_parent; - peer_elem = gst_pad_get_parent (peer); + /* get parent */ + peer_parent = gst_object_get_parent (GST_OBJECT (peer)); - if (peer_elem) { + /* if we have an element parent, follow it */ + if (peer_parent && GST_IS_ELEMENT (peer_parent)) { GstObject *parent; /* see if this element is in the bin we are currently handling */ - parent = gst_object_get_parent (GST_OBJECT_CAST (peer_elem)); + parent = gst_object_get_parent (peer_parent); if (parent) { if (parent == GST_OBJECT_CAST (bin)) { GST_CAT_DEBUG_OBJECT (GST_CAT_STATES, element, - "adding element %s to queue", GST_ELEMENT_NAME (peer_elem)); + "adding element %s to queue", GST_ELEMENT_NAME (peer_parent)); /* make sure we don't have duplicates */ - remove_all_from_queue (semi_queue, peer_elem, TRUE); - remove_all_from_queue (elem_queue, peer_elem, TRUE); + remove_all_from_queue (semi_queue, peer_parent, TRUE); + remove_all_from_queue (elem_queue, peer_parent, TRUE); /* was reffed before pushing on the queue by the * gst_object_get_parent() call we used to get the element. */ - g_queue_push_tail (elem_queue, peer_elem); + g_queue_push_tail (elem_queue, peer_parent); + /* so that we don't unref it */ + peer_parent = NULL; } else { GST_CAT_DEBUG_OBJECT (GST_CAT_STATES, element, "not adding element %s to queue, it is in another bin", - GST_ELEMENT_NAME (peer_elem)); - gst_object_unref (peer_elem); + GST_ELEMENT_NAME (peer_parent)); } gst_object_unref (parent); } } + if (peer_parent) + gst_object_unref (peer_parent); + gst_object_unref (peer); } else { GST_CAT_DEBUG_OBJECT (GST_CAT_STATES, element, diff --git a/gst/gstbin.h b/gst/gstbin.h index 3006eee08..a4113a2e0 100644 --- a/gst/gstbin.h +++ b/gst/gstbin.h @@ -54,8 +54,8 @@ typedef enum { GST_BIN_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 5 } GstBinFlags; -/*typedef struct _GstBin GstBin; */ -/*typedef struct _GstBinClass GstBinClass; */ +typedef struct _GstBin GstBin; +typedef struct _GstBinClass GstBinClass; #define GST_BIN_NUMCHILDREN(bin) (GST_BIN_CAST(bin)->numchildren); #define GST_BIN_CHILDREN(bin) (GST_BIN_CAST(bin)->children); diff --git a/gst/gstbus.h b/gst/gstbus.h index 23881f076..90adf59af 100644 --- a/gst/gstbus.h +++ b/gst/gstbus.h @@ -22,7 +22,9 @@ #ifndef __GST_BUS_H__ #define __GST_BUS_H__ -#include <gst/gsttypes.h> +typedef struct _GstBus GstBus; +typedef struct _GstBusClass GstBusClass; + #include <gst/gstmessage.h> #include <gst/gstclock.h> diff --git a/gst/gstconfig.h.in b/gst/gstconfig.h.in index 767cd0940..d4125ec43 100644 --- a/gst/gstconfig.h.in +++ b/gst/gstconfig.h.in @@ -20,6 +20,9 @@ #define GST_DISABLE_URI 1 #endif +/***** default padding of structures *****/ +#define GST_PADDING 4 +#define GST_PADDING_INIT {0} /***** disabling of subsystems *****/ diff --git a/gst/gstelement.c b/gst/gstelement.c index 3d5698d3c..87269ef45 100644 --- a/gst/gstelement.c +++ b/gst/gstelement.c @@ -29,7 +29,6 @@ #include "gstbus.h" #include "gstmarshal.h" #include "gsterror.h" -#include "gstscheduler.h" #include "gstevent.h" #include "gstutils.h" #include "gstinfo.h" @@ -67,11 +66,7 @@ static void gst_element_finalize (GObject * object); static GstElementStateReturn gst_element_change_state (GstElement * element); static GstElementStateReturn gst_element_get_state_func (GstElement * element, GstElementState * state, GstElementState * pending, GTimeVal * timeout); -static void gst_element_set_manager_func (GstElement * element, - GstPipeline * manager); static void gst_element_set_bus_func (GstElement * element, GstBus * bus); -static void gst_element_set_scheduler_func (GstElement * element, - GstScheduler * scheduler); #ifndef GST_DISABLE_LOADSAVE static xmlNodePtr gst_element_save_thyself (GstObject * object, @@ -174,9 +169,7 @@ gst_element_class_init (GstElementClass * klass) klass->change_state = GST_DEBUG_FUNCPTR (gst_element_change_state); klass->get_state = GST_DEBUG_FUNCPTR (gst_element_get_state_func); - klass->set_manager = GST_DEBUG_FUNCPTR (gst_element_set_manager_func); klass->set_bus = GST_DEBUG_FUNCPTR (gst_element_set_bus_func); - klass->set_scheduler = GST_DEBUG_FUNCPTR (gst_element_set_scheduler_func); klass->numpadtemplates = 0; klass->elementfactory = NULL; @@ -1915,6 +1908,7 @@ iterator_fold_with_resync (GstIterator * iter, GstIteratorFoldFunction func, switch (ires) { case GST_ITERATOR_RESYNC: + gst_iterator_resync (iter); break; case GST_ITERATOR_DONE: res = TRUE; @@ -1999,13 +1993,6 @@ gst_element_change_state (GstElement * element) } break; case GST_STATE_PAUSED_TO_PLAYING: - /* FIXME really needed? */ - GST_LOCK (element); - if (GST_ELEMENT_MANAGER (element)) { - element->base_time = - GST_ELEMENT_CAST (GST_ELEMENT_MANAGER (element))->base_time; - } - GST_UNLOCK (element); break; case GST_STATE_PLAYING_TO_PAUSED: break; @@ -2072,7 +2059,6 @@ gst_element_dispose (GObject * object) } GST_LOCK (element); - gst_object_replace ((GstObject **) & element->manager, NULL); gst_object_replace ((GstObject **) & element->clock, NULL); GST_UNLOCK (element); @@ -2239,20 +2225,6 @@ gst_element_restore_thyself (GstObject * object, xmlNodePtr self) #endif /* GST_DISABLE_LOADSAVE */ static void -gst_element_set_manager_func (GstElement * element, GstPipeline * manager) -{ - g_return_if_fail (GST_IS_ELEMENT (element)); - - GST_CAT_DEBUG_OBJECT (GST_CAT_PARENTAGE, element, "setting manager to %p", - manager); - - /* setting the manager cannot increase the refcount */ - GST_LOCK (element); - GST_ELEMENT_MANAGER (element) = manager; - GST_UNLOCK (element); -} - -static void gst_element_set_bus_func (GstElement * element, GstBus * bus) { g_return_if_fail (GST_IS_ELEMENT (element)); @@ -2265,69 +2237,6 @@ gst_element_set_bus_func (GstElement * element, GstBus * bus) GST_UNLOCK (element); } -static void -gst_element_set_scheduler_func (GstElement * element, GstScheduler * scheduler) -{ - g_return_if_fail (GST_IS_ELEMENT (element)); - - GST_CAT_DEBUG_OBJECT (GST_CAT_PARENTAGE, element, "setting scheduler to %p", - scheduler); - - GST_LOCK (element); - gst_object_replace ((GstObject **) & GST_ELEMENT_SCHEDULER (element), - GST_OBJECT (scheduler)); - GST_UNLOCK (element); -} - -/** - * gst_element_set_manager: - * @element: a #GstElement to set the manager of. - * @manager: the #GstManager to set. - * - * Sets the manager of the element. For internal use only, unless you're - * writing a new bin subclass. - * - * MT safe. - */ -void -gst_element_set_manager (GstElement * element, GstPipeline * manager) -{ - GstElementClass *oclass; - - g_return_if_fail (GST_IS_ELEMENT (element)); - - oclass = GST_ELEMENT_GET_CLASS (element); - - if (oclass->set_manager) - oclass->set_manager (element, manager); -} - - -/** - * gst_element_get_manager: - * @element: a #GstElement to get the manager of. - * - * Returns the manager of the element. - * - * Returns: the element's #GstPipeline. unref after usage. - * - * MT safe. - */ -GstPipeline * -gst_element_get_manager (GstElement * element) -{ - GstPipeline *result = NULL; - - g_return_val_if_fail (GST_IS_ELEMENT (element), result); - - GST_LOCK (element); - result = GST_ELEMENT_MANAGER (element); - gst_object_ref (result); - GST_UNLOCK (element); - - return result; -} - /** * gst_element_set_bus: * @element: a #GstElement to set the bus of. @@ -2377,50 +2286,3 @@ gst_element_get_bus (GstElement * element) return result; } - -/** - * gst_element_set_scheduler: - * @element: a #GstElement to set the scheduler of. - * @scheduler: the #GstScheduler to set. - * - * Sets the scheduler of the element. For internal use only, unless you're - * testing elements. - * - * MT safe. - */ -void -gst_element_set_scheduler (GstElement * element, GstScheduler * scheduler) -{ - GstElementClass *oclass; - - g_return_if_fail (GST_IS_ELEMENT (element)); - - oclass = GST_ELEMENT_GET_CLASS (element); - - if (oclass->set_scheduler) - oclass->set_scheduler (element, scheduler); -} - -/** - * gst_element_get_scheduler: - * @element: a #GstElement to get the scheduler of. - * - * Returns the scheduler of the element. - * - * Returns: the element's #GstScheduler. - * - * MT safe. - */ -GstScheduler * -gst_element_get_scheduler (GstElement * element) -{ - GstScheduler *result = NULL; - - g_return_val_if_fail (GST_IS_ELEMENT (element), result); - - GST_LOCK (element); - result = GST_ELEMENT_SCHEDULER (element); - GST_UNLOCK (element); - - return result; -} diff --git a/gst/gstelement.h b/gst/gstelement.h index 98c6385bb..5ce64295c 100644 --- a/gst/gstelement.h +++ b/gst/gstelement.h @@ -24,10 +24,25 @@ #ifndef __GST_ELEMENT_H__ #define __GST_ELEMENT_H__ +/* gstelement.h and gstelementfactory.h include eachother */ +typedef struct _GstElement GstElement; +typedef struct _GstElementClass GstElementClass; + +/* gstmessage.h needs ElementState */ +#define GST_NUM_STATES 4 +typedef enum { + GST_STATE_VOID_PENDING = 0, + GST_STATE_NULL = (1 << 0), + GST_STATE_READY = (1 << 1), + GST_STATE_PAUSED = (1 << 2), + GST_STATE_PLAYING = (1 << 3) +} GstElementState; + + #include <gst/gstconfig.h> -#include <gst/gsttypes.h> #include <gst/gstobject.h> #include <gst/gstpad.h> +#include <gst/gstbus.h> #include <gst/gstclock.h> #include <gst/gstelementfactory.h> #include <gst/gstplugin.h> @@ -49,7 +64,13 @@ GST_EXPORT GType _gst_element_type; #define GST_ELEMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_ELEMENT, GstElementClass)) #define GST_ELEMENT_CAST(obj) ((GstElement*)(obj)) -#define GST_NUM_STATES 4 +typedef enum { + GST_STATE_FAILURE = 0, + GST_STATE_SUCCESS = 1, + GST_STATE_ASYNC = 2, + GST_STATE_NO_PREROLL = 3 +} GstElementStateReturn; + /* NOTE: this probably should be done with an #ifdef to decide * whether to safe-cast or to just do the non-checking cast. */ @@ -87,10 +108,6 @@ GST_EXPORT GType _gst_element_type; typedef enum { - /* private flags that can be used by the scheduler */ - GST_ELEMENT_SCHEDULER_PRIVATE1, - GST_ELEMENT_SCHEDULER_PRIVATE2, - /* ignore state changes from parent */ GST_ELEMENT_LOCKED_STATE, @@ -105,9 +122,7 @@ typedef enum #define GST_ELEMENT_NAME(obj) (GST_OBJECT_NAME(obj)) #define GST_ELEMENT_PARENT(obj) (GST_ELEMENT_CAST(GST_OBJECT_PARENT(obj))) -#define GST_ELEMENT_MANAGER(obj) (GST_ELEMENT_CAST(obj)->manager) #define GST_ELEMENT_BUS(obj) (GST_ELEMENT_CAST(obj)->bus) -#define GST_ELEMENT_SCHEDULER(obj) (GST_ELEMENT_CAST(obj)->scheduler) #define GST_ELEMENT_CLOCK(obj) (GST_ELEMENT_CAST(obj)->clock) #define GST_ELEMENT_PADS(obj) (GST_ELEMENT_CAST(obj)->pads) @@ -179,10 +194,7 @@ struct _GstElement change. it is cleared when doing another state change. */ gboolean no_preroll; /* flag is set when the element cannot preroll */ /*< public >*/ /* with LOCK */ - /* element manager */ - GstPipeline *manager; GstBus *bus; - GstScheduler *scheduler; /* allocated clock */ GstClock *clock; @@ -237,10 +249,8 @@ struct _GstElementClass GstElementState * pending, GTimeVal * timeout); GstElementStateReturn (*change_state) (GstElement *element); - /* manager */ - void (*set_manager) (GstElement * element, GstPipeline * pipeline); + /* bus */ void (*set_bus) (GstElement * element, GstBus * bus); - void (*set_scheduler) (GstElement *element, GstScheduler *scheduler); /* set/get clocks */ GstClock* (*get_clock) (GstElement *element); @@ -289,13 +299,9 @@ gboolean gst_element_is_indexable (GstElement *element); void gst_element_set_index (GstElement *element, GstIndex *index); GstIndex* gst_element_get_index (GstElement *element); -/* manager and tasks */ -void gst_element_set_manager (GstElement * element, GstPipeline * pipeline); -GstPipeline * gst_element_get_manager (GstElement * element); +/* bus */ void gst_element_set_bus (GstElement * element, GstBus * bus); GstBus * gst_element_get_bus (GstElement * element); -void gst_element_set_scheduler (GstElement *element, GstScheduler *scheduler); -GstScheduler* gst_element_get_scheduler (GstElement *element); /* pad management */ gboolean gst_element_add_pad (GstElement *element, GstPad *pad); diff --git a/gst/gstelementfactory.h b/gst/gstelementfactory.h index 8aadec530..15b26c3d3 100644 --- a/gst/gstelementfactory.h +++ b/gst/gstelementfactory.h @@ -24,8 +24,10 @@ #ifndef __GST_ELEMENT_FACTORY_H__ #define __GST_ELEMENT_FACTORY_H__ +typedef struct _GstElementFactory GstElementFactory; +typedef struct _GstElementFactoryClass GstElementFactoryClass; + #include <gst/gstconfig.h> -#include <gst/gsttypes.h> #include <gst/gstelement.h> #include <gst/gstobject.h> #include <gst/gstplugin.h> @@ -34,6 +36,8 @@ G_BEGIN_DECLS +typedef struct _GstElementDetails GstElementDetails; + /* FIXME: need translatable stuff in here (how handle in registry)? */ struct _GstElementDetails { @@ -48,7 +52,7 @@ struct _GstElementDetails }; #define GST_ELEMENT_DETAILS(longname,klass,description,author) \ - { longname, klass, description, author, GST_PADDING_INIT } + { longname, klass, description, author, {0} } #define GST_IS_ELEMENT_DETAILS(details) ( \ (details) && ((details)->longname != NULL) && ((details)->klass != NULL) \ && ((details)->description != NULL) && ((details)->author != NULL)) diff --git a/gst/gsterror.c b/gst/gsterror.c index a75f6ba8e..59319b956 100644 --- a/gst/gsterror.c +++ b/gst/gsterror.c @@ -66,8 +66,6 @@ _gst_core_errors_init (void) N_("Internal GStreamer error: pad problem. Please file a bug.")); TABLE (t, CORE, THREAD, N_("Internal GStreamer error: thread problem. Please file a bug.")); - TABLE (t, CORE, SCHEDULER, - N_("Internal GStreamer error: scheduler problem. Please file a bug.")); TABLE (t, CORE, NEGOTIATION, N_("Internal GStreamer error: negotiation problem. Please file a bug.")); TABLE (t, CORE, EVENT, diff --git a/gst/gsterror.h b/gst/gsterror.h index 53f39fc26..be0d7e569 100644 --- a/gst/gsterror.h +++ b/gst/gsterror.h @@ -45,7 +45,6 @@ G_BEGIN_DECLS * @GST_CORE_ERROR_STATE_CHANGE: used for state change errors. * @GST_CORE_ERROR_PAD: used for pad-related errors. * @GST_CORE_ERROR_THREAD: used for thread-related errors. - * @GST_CORE_ERROR_SCHEDULER: used for scheduler-related errors. * @GST_CORE_ERROR_NEGOTIATION: used for negotiation-related errors. * @GST_CORE_ERROR_EVENT: used for event-related errors. * @GST_CORE_ERROR_SEEK: used for seek-related errors. @@ -66,7 +65,6 @@ typedef enum GST_CORE_ERROR_STATE_CHANGE, GST_CORE_ERROR_PAD, GST_CORE_ERROR_THREAD, - GST_CORE_ERROR_SCHEDULER, GST_CORE_ERROR_NEGOTIATION, GST_CORE_ERROR_EVENT, GST_CORE_ERROR_SEEK, diff --git a/gst/gstevent.h b/gst/gstevent.h index 624172b15..fbc7d4847 100644 --- a/gst/gstevent.h +++ b/gst/gstevent.h @@ -24,7 +24,6 @@ #ifndef __GST_EVENT_H__ #define __GST_EVENT_H__ -#include <gst/gsttypes.h> #include <gst/gstminiobject.h> #include <gst/gstformat.h> #include <gst/gstobject.h> @@ -211,6 +210,8 @@ struct _GstEvent { struct _GstEventClass { GstMiniObjectClass mini_object_class; + /*< private >*/ + gpointer _gst_reserved[GST_PADDING]; }; void _gst_event_initialize (void); @@ -245,6 +246,7 @@ gboolean gst_event_discont_get_value (GstEvent *event, GstFormat format, gint64 *start_value, gint64 *end_value); #define gst_event_new_filler() gst_event_new(GST_EVENT_FILLER) +#define gst_event_new_eos() gst_event_new(GST_EVENT_EOS) /* flush events */ GstEvent* gst_event_new_flush (gboolean done); diff --git a/gst/gstghostpad.c b/gst/gstghostpad.c index c7f7f009d..81628377b 100644 --- a/gst/gstghostpad.c +++ b/gst/gstghostpad.c @@ -25,9 +25,6 @@ #include "gst_private.h" #include "gstghostpad.h" -#include "gstelement.h" -#include "gstbin.h" - #define GST_TYPE_PROXY_PAD (gst_proxy_pad_get_type ()) #define GST_IS_PROXY_PAD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_PROXY_PAD)) diff --git a/gst/gstindex.c b/gst/gstindex.c index b5164d28a..1a9d8d27c 100644 --- a/gst/gstindex.c +++ b/gst/gstindex.c @@ -24,9 +24,11 @@ #include "gstinfo.h" #include "gstregistrypool.h" -#include "gstpad.h" #include "gstindex.h" #include "gstmarshal.h" +/* for constructing an entry name */ +#include "gstelement.h" +#include "gstpad.h" /* Index signals and args */ enum diff --git a/gst/gstinfo.c b/gst/gstinfo.c index e16a06138..73f6ca4c4 100644 --- a/gst/gstinfo.c +++ b/gst/gstinfo.c @@ -37,9 +37,6 @@ #include <unistd.h> #endif #include <string.h> /* G_VA_COPY */ -#include "gstelement.h" -#include "gstpad.h" -#include "gstscheduler.h" #include "gst_private.h" #include "gstutils.h" #ifdef HAVE_VALGRIND @@ -129,17 +126,12 @@ gboolean __gst_debug_enabled = TRUE; GstDebugCategory *GST_CAT_DEFAULT = NULL; GstDebugCategory *GST_CAT_GST_INIT = NULL; -GstDebugCategory *GST_CAT_COTHREADS = NULL; -GstDebugCategory *GST_CAT_COTHREAD_SWITCH = NULL; GstDebugCategory *GST_CAT_AUTOPLUG = NULL; GstDebugCategory *GST_CAT_AUTOPLUG_ATTEMPT = NULL; GstDebugCategory *GST_CAT_PARENTAGE = NULL; GstDebugCategory *GST_CAT_STATES = NULL; -GstDebugCategory *GST_CAT_PLANNING = NULL; GstDebugCategory *GST_CAT_SCHEDULING = NULL; -/* FIXME: remove GST_CAT_DATAFLOW in 0.9 */ -GstDebugCategory *GST_CAT_DATAFLOW = NULL; GstDebugCategory *GST_CAT_BUFFER = NULL; GstDebugCategory *GST_CAT_CAPS = NULL; GstDebugCategory *GST_CAT_CLOCK = NULL; @@ -159,7 +151,6 @@ GstDebugCategory *GST_CAT_EVENT = NULL; GstDebugCategory *GST_CAT_MESSAGE = NULL; GstDebugCategory *GST_CAT_PARAMS = NULL; GstDebugCategory *GST_CAT_CALL_TRACE = NULL; -GstDebugCategory *GST_CAT_SEEK = NULL; GstDebugCategory *GST_CAT_SIGNAL = NULL; GstDebugCategory *GST_CAT_PROBE = NULL; @@ -232,10 +223,6 @@ _gst_debug_init (void) /* FIXME: add descriptions here */ GST_CAT_GST_INIT = _gst_debug_category_new ("GST_INIT", GST_DEBUG_BOLD | GST_DEBUG_FG_RED, NULL); - GST_CAT_COTHREADS = _gst_debug_category_new ("GST_COTHREADS", - GST_DEBUG_BOLD | GST_DEBUG_FG_GREEN, NULL); - GST_CAT_COTHREAD_SWITCH = _gst_debug_category_new ("GST_COTHREAD_SWITCH", - GST_DEBUG_BOLD | GST_DEBUG_FG_WHITE | GST_DEBUG_BG_GREEN, NULL); GST_CAT_AUTOPLUG = _gst_debug_category_new ("GST_AUTOPLUG", GST_DEBUG_BOLD | GST_DEBUG_FG_BLUE, NULL); GST_CAT_AUTOPLUG_ATTEMPT = _gst_debug_category_new ("GST_AUTOPLUG_ATTEMPT", @@ -244,13 +231,8 @@ _gst_debug_init (void) GST_DEBUG_BOLD | GST_DEBUG_FG_WHITE | GST_DEBUG_BG_RED, NULL); GST_CAT_STATES = _gst_debug_category_new ("GST_STATES", GST_DEBUG_BOLD | GST_DEBUG_FG_RED, NULL); - GST_CAT_PLANNING = _gst_debug_category_new ("GST_PLANNING", - GST_DEBUG_BOLD | GST_DEBUG_FG_MAGENTA, NULL); GST_CAT_SCHEDULING = _gst_debug_category_new ("GST_SCHEDULING", GST_DEBUG_BOLD | GST_DEBUG_FG_MAGENTA, NULL); -/* FIXME: remove GST_CAT_DATAFLOW in 0.9 */ - GST_CAT_DATAFLOW = _gst_debug_category_new ("GST_DATAFLOW", - GST_DEBUG_BOLD | GST_DEBUG_FG_GREEN, "dataflow inside pads"); GST_CAT_BUFFER = _gst_debug_category_new ("GST_BUFFER", GST_DEBUG_BOLD | GST_DEBUG_FG_GREEN, NULL); GST_CAT_CAPS = _gst_debug_category_new ("GST_CAPS", @@ -290,9 +272,6 @@ _gst_debug_init (void) GST_DEBUG_BOLD | GST_DEBUG_FG_BLACK | GST_DEBUG_BG_YELLOW, NULL); GST_CAT_CALL_TRACE = _gst_debug_category_new ("GST_CALL_TRACE", GST_DEBUG_BOLD, NULL); - /* FIXME: fold back to GST_CAT_EVENT in 0.9 */ - GST_CAT_SEEK = _gst_debug_category_new ("GST_SEEK", - GST_DEBUG_BOLD | GST_DEBUG_FG_BLUE, "plugins reacting to seek events"); GST_CAT_SIGNAL = _gst_debug_category_new ("GST_SIGNAL", GST_DEBUG_BOLD | GST_DEBUG_FG_WHITE | GST_DEBUG_BG_RED, NULL); GST_CAT_PROBE = _gst_debug_category_new ("GST_PROBE", diff --git a/gst/gstmessage.c b/gst/gstmessage.c index b5300dff2..5d4731e54 100644 --- a/gst/gstmessage.c +++ b/gst/gstmessage.c @@ -129,7 +129,7 @@ _gst_message_copy (GstMessage * message) copy = (GstMessage *) gst_mini_object_new (GST_TYPE_MESSAGE); - /* FIXME */ + /* FIXME, need to copy relevant data from the miniobject. */ //memcpy (copy, message, sizeof (GstMessage)); copy->lock = message->lock; diff --git a/gst/gstmessage.h b/gst/gstmessage.h index e1b11dba7..054e3c04f 100644 --- a/gst/gstmessage.h +++ b/gst/gstmessage.h @@ -22,14 +22,11 @@ #ifndef __GST_MESSAGE_H__ #define __GST_MESSAGE_H__ -#include <gst/gsttypes.h> -#include <gst/gstminiobject.h> -#include <gst/gstobject.h> -#include <gst/gsttag.h> -#include <gst/gststructure.h> - G_BEGIN_DECLS +typedef struct _GstMessage GstMessage; +typedef struct _GstMessageClass GstMessageClass; + /** * GstMessageType: * @GST_MESSAGE_UNKNOWN: an undefined message @@ -51,7 +48,7 @@ G_BEGIN_DECLS * @GST_MESSAGE_SEGMENT_DONE: pipeline completed playback of a segment. * @GST_MESSAGE_ANY: mask for all of the above messages. */ -typedef enum +typedef enum _GstMessageType { GST_MESSAGE_UNKNOWN = 0, GST_MESSAGE_EOS = (1 << 0), @@ -71,10 +68,13 @@ typedef enum GST_MESSAGE_ANY = 0xffffffff } GstMessageType; -#define GST_MESSAGE_TRACE_NAME "GstMessage" +#include <gst/gstminiobject.h> +#include <gst/gstobject.h> +#include <gst/gstelement.h> +#include <gst/gsttag.h> +#include <gst/gststructure.h> -typedef struct _GstMessage GstMessage; -typedef struct _GstMessageClass GstMessageClass; +#define GST_MESSAGE_TRACE_NAME "GstMessage" #define GST_TYPE_MESSAGE (gst_message_get_type()) #define GST_IS_MESSAGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_MESSAGE)) @@ -118,6 +118,9 @@ struct _GstMessage struct _GstMessageClass { GstMiniObjectClass mini_object_class; + + /*< private > */ + gpointer _gst_reserved[GST_PADDING]; }; void _gst_message_initialize (void); @@ -146,6 +149,6 @@ void gst_message_parse_state_changed (GstMessage *message, GstElementState *old GstElementState *new_state); const GstStructure * gst_message_get_structure (GstMessage *message); - G_END_DECLS + #endif /* __GST_MESSAGE_H__ */ diff --git a/gst/gstminiobject.h b/gst/gstminiobject.h index 45cea9811..ce24f79e9 100644 --- a/gst/gstminiobject.h +++ b/gst/gstminiobject.h @@ -23,8 +23,9 @@ #ifndef __GST_MINI_OBJECT_H__ #define __GST_MINI_OBJECT_H__ +#include <gst/gstconfig.h> + #include <glib-object.h> -#include "gst/gsttypes.h" G_BEGIN_DECLS diff --git a/gst/gstobject.c b/gst/gstobject.c index 58b7f8af8..5a8862083 100644 --- a/gst/gstobject.c +++ b/gst/gstobject.c @@ -42,7 +42,7 @@ * we use our own atomic refcounting to do proper MT safe refcounting. * * A proper fix is of course to make the glib refcounting threadsafe which is - * planned. + * planned. Update: atomic refcounting is now in glib >= 2.7.3 */ #ifdef REFCOUNT_HACK #define PATCH_REFCOUNT(obj) ((GObject*)(obj))->ref_count = 100000; diff --git a/gst/gstobject.h b/gst/gstobject.h index f466a2918..30eea792e 100644 --- a/gst/gstobject.h +++ b/gst/gstobject.h @@ -26,9 +26,7 @@ #include <gst/gstconfig.h> -#include <glib-object.h> /* note that this gets wrapped in __GST_OBJECT_H__ */ - -#include <gst/gsttypes.h> +#include <glib-object.h> G_BEGIN_DECLS @@ -81,6 +79,9 @@ typedef enum #define GST_OBJECT_IS_DESTROYED(obj) (GST_FLAG_IS_SET (obj, GST_OBJECT_DESTROYED)) #define GST_OBJECT_IS_FLOATING(obj) (GST_FLAG_IS_SET (obj, GST_OBJECT_FLOATING)) +typedef struct _GstObject GstObject; +typedef struct _GstObjectClass GstObjectClass; + struct _GstObject { GObject object; diff --git a/gst/gstpad.c b/gst/gstpad.c index 58523f128..4ca039157 100644 --- a/gst/gstpad.c +++ b/gst/gstpad.c @@ -26,10 +26,6 @@ #include "gstenumtypes.h" #include "gstmarshal.h" #include "gstutils.h" -#include "gstelement.h" -#include "gstbin.h" -#include "gstscheduler.h" -#include "gstevent.h" #include "gstinfo.h" #include "gsterror.h" #include "gstvalue.h" @@ -372,35 +368,6 @@ gst_pad_new_from_template (GstPadTemplate * templ, const gchar * name) } /** - * gst_pad_get_parent: - * @pad: a pad - * - * Gets the parent of @pad, cast to a #GstElement. If a @pad has no parent or - * its parent is not an element, return NULL. - * - * Returns: The parent of the pad. The caller has a reference on the parent, so - * unref when you're finished with it. - * - * MT safe. - */ -GstElement * -gst_pad_get_parent (GstPad * pad) -{ - GstObject *p; - - g_return_val_if_fail (GST_IS_PAD (pad), NULL); - - p = gst_object_get_parent (GST_OBJECT_CAST (pad)); - - if (p && !GST_IS_ELEMENT (p)) { - gst_object_unref (p); - p = NULL; - } - - return GST_ELEMENT_CAST (p); -} - -/** * gst_pad_get_direction: * @pad: a #GstPad to get the direction of. * @@ -3545,55 +3512,27 @@ gst_pad_get_element_private (GstPad * pad) * dataflow. This function will automatically acauire the STREAM_LOCK of * the pad before calling @func. * - * Returns: a TRUE if the task could be started. FALSE when the pad has - * no parent or the parent has no scheduler. + * Returns: a TRUE if the task could be started. */ gboolean gst_pad_start_task (GstPad * pad, GstTaskFunction func, gpointer data) { - GstElement *parent; - GstScheduler *sched; GstTask *task; g_return_val_if_fail (GST_IS_PAD (pad), FALSE); g_return_val_if_fail (func != NULL, FALSE); GST_LOCK (pad); - parent = GST_PAD_PARENT (pad); - - if (parent == NULL || !GST_IS_ELEMENT (parent)) - goto no_parent; - - sched = GST_ELEMENT_SCHEDULER (parent); - if (sched == NULL) - goto no_sched; - task = GST_PAD_TASK (pad); if (task == NULL) { - task = gst_scheduler_create_task (sched, func, data); + task = gst_task_create (func, data); gst_task_set_lock (task, GST_STREAM_GET_LOCK (pad)); - GST_PAD_TASK (pad) = task; } - GST_UNLOCK (pad); - gst_task_start (task); + GST_UNLOCK (pad); return TRUE; - - /* ERRORS */ -no_parent: - { - GST_UNLOCK (pad); - GST_DEBUG ("no parent"); - return FALSE; - } -no_sched: - { - GST_UNLOCK (pad); - GST_DEBUG ("no scheduler"); - return FALSE; - } } /** @@ -3654,9 +3593,8 @@ gst_pad_stop_task (GstPad * pad) if (task == NULL) goto no_task; GST_PAD_TASK (pad) = NULL; - GST_UNLOCK (pad); - gst_task_stop (task); + GST_UNLOCK (pad); GST_STREAM_LOCK (pad); GST_STREAM_UNLOCK (pad); diff --git a/gst/gstpad.h b/gst/gstpad.h index 9876af915..1188c99cf 100644 --- a/gst/gstpad.h +++ b/gst/gstpad.h @@ -34,7 +34,6 @@ #include <gst/gstqueryutils.h> #include <gst/gsttask.h> - G_BEGIN_DECLS GST_EXPORT GType _gst_pad_type; @@ -50,12 +49,11 @@ GST_EXPORT GType _gst_pad_type; #define GST_PAD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_PAD, GstPadClass)) #define GST_PAD_CAST(obj) ((GstPad*)(obj)) +typedef struct _GstPad GstPad; +typedef struct _GstPadClass GstPadClass; -/* why are these in gsttypes, again? */ -/*typedef struct _GstPad GstPad;*/ -/*typedef struct _GstPadClass GstPadClass;*/ -/*typedef struct _GstPadTemplate GstPadTemplate;*/ -/*typedef struct _GstPadTemplateClass GstPadTemplateClass;*/ +typedef struct _GstPadTemplate GstPadTemplate; +typedef struct _GstPadTemplateClass GstPadTemplateClass; typedef struct _GstStaticPadTemplate GstStaticPadTemplate; typedef enum { @@ -366,7 +364,7 @@ GstPad* gst_pad_new (const gchar *name, GstPadDirection direction); GstPad* gst_pad_new_from_template (GstPadTemplate *templ, const gchar *name); #define gst_pad_get_name(pad) gst_object_get_name (GST_OBJECT_CAST (pad)) -GstElement* gst_pad_get_parent (GstPad *pad); +#define gst_pad_get_parent(pad) gst_object_get_parent (GST_OBJECT_CAST (pad)) GstPadDirection gst_pad_get_direction (GstPad *pad); diff --git a/gst/gstparse.h b/gst/gstparse.h index b3221a9e8..58127d6fd 100644 --- a/gst/gstparse.h +++ b/gst/gstparse.h @@ -23,7 +23,7 @@ #ifndef __GST_PARSE_H__ #define __GST_PARSE_H__ -#include <gst/gstbin.h> +#include <gst/gstelement.h> G_BEGIN_DECLS diff --git a/gst/gstpipeline.c b/gst/gstpipeline.c index 421aa9def..e9c4a57f8 100644 --- a/gst/gstpipeline.c +++ b/gst/gstpipeline.c @@ -24,7 +24,6 @@ #include "gstpipeline.h" #include "gstinfo.h" -#include "gstscheduler.h" #include "gstsystemclock.h" static GstElementDetails gst_pipeline_details = @@ -137,29 +136,10 @@ gst_pipeline_class_init (gpointer g_class, gpointer class_data) static void gst_pipeline_init (GTypeInstance * instance, gpointer g_class) { - GstScheduler *scheduler; GstPipeline *pipeline = GST_PIPELINE (instance); - /* get an instance of the default scheduler */ - scheduler = gst_scheduler_factory_make (NULL, GST_ELEMENT (pipeline)); - - /* FIXME need better error handling */ - if (scheduler == NULL) { - const gchar *name = gst_scheduler_factory_get_default_name (); - - g_error ("Critical error: could not get scheduler \"%s\"\n" - "Are you sure you have a registry ?\n" - "Run gst-register as root if you haven't done so yet.", name); - } else { - gst_element_set_scheduler (GST_ELEMENT (pipeline), scheduler); - /* set_scheduler refs the bus via gst_object_replace, we drop our ref */ - gst_object_unref ((GstObject *) scheduler); - } - pipeline->delay = DEFAULT_DELAY; pipeline->play_timeout = DEFAULT_PLAY_TIMEOUT; - /* we are our own manager */ - GST_ELEMENT_MANAGER (pipeline) = pipeline; } static void @@ -169,8 +149,6 @@ gst_pipeline_dispose (GObject * object) GST_CAT_DEBUG_OBJECT (GST_CAT_REFCOUNTING, pipeline, "dispose"); - gst_scheduler_reset (GST_ELEMENT_SCHEDULER (object)); - gst_element_set_scheduler (GST_ELEMENT (pipeline), NULL); gst_object_replace ((GstObject **) & pipeline->fixed_clock, NULL); G_OBJECT_CLASS (parent_class)->dispose (object); @@ -285,7 +263,6 @@ gst_pipeline_change_state (GstElement * element) if (element->bus) gst_bus_set_flushing (element->bus, FALSE); GST_UNLOCK (element); - gst_scheduler_setup (GST_ELEMENT_SCHEDULER (pipeline)); break; case GST_STATE_READY_TO_PAUSED: break; @@ -393,22 +370,6 @@ gst_pipeline_change_state (GstElement * element) } /** - * gst_pipeline_get_scheduler: - * @pipeline: the pipeline - * - * Gets the #GstScheduler of this pipeline. - * - * Returns: a GstScheduler. - * - * MT safe. - */ -GstScheduler * -gst_pipeline_get_scheduler (GstPipeline * pipeline) -{ - return gst_element_get_scheduler (GST_ELEMENT (pipeline)); -} - -/** * gst_pipeline_get_bus: * @pipeline: the pipeline * diff --git a/gst/gstpipeline.h b/gst/gstpipeline.h index 014106161..b3f52f41f 100644 --- a/gst/gstpipeline.h +++ b/gst/gstpipeline.h @@ -24,7 +24,6 @@ #ifndef __GST_PIPELINE_H__ #define __GST_PIPELINE_H__ -#include <gst/gsttypes.h> #include <gst/gstbin.h> G_BEGIN_DECLS @@ -36,6 +35,9 @@ G_BEGIN_DECLS #define GST_IS_PIPELINE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_PIPELINE)) #define GST_PIPELINE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_PIPELINE, GstPipelineClass)) +typedef struct _GstPipeline GstPipeline; +typedef struct _GstPipelineClass GstPipelineClass; + typedef enum { /* this pipeline works with a fixed clock */ GST_PIPELINE_FLAG_FIXED_CLOCK = GST_BIN_FLAG_LAST, @@ -67,7 +69,6 @@ struct _GstPipelineClass { GType gst_pipeline_get_type (void); GstElement* gst_pipeline_new (const gchar *name); -GstScheduler* gst_pipeline_get_scheduler (GstPipeline *pipeline); GstBus* gst_pipeline_get_bus (GstPipeline *pipeline); void gst_pipeline_set_new_stream_time (GstPipeline *pipeline, GstClockTime time); diff --git a/gst/gstpluginfeature.h b/gst/gstpluginfeature.h index c2c88a8bf..eaf4ab434 100644 --- a/gst/gstpluginfeature.h +++ b/gst/gstpluginfeature.h @@ -25,7 +25,6 @@ #define __GST_PLUGIN_FEATURE_H__ #include <glib-object.h> -#include <gst/gsttypes.h> G_BEGIN_DECLS @@ -41,6 +40,14 @@ G_BEGIN_DECLS typedef struct _GstPluginFeature GstPluginFeature; typedef struct _GstPluginFeatureClass GstPluginFeatureClass; +/* some predefined ranks */ +typedef enum { + GST_RANK_NONE = 0, + GST_RANK_MARGINAL = 64, + GST_RANK_SECONDARY = 128, + GST_RANK_PRIMARY = 256 +} GstRank; + struct _GstPluginFeature { GObject object; @@ -50,6 +57,7 @@ struct _GstPluginFeature { gpointer manager; + /*< private >*/ gpointer _gst_reserved[GST_PADDING]; }; diff --git a/gst/gstquery.h b/gst/gstquery.h index 7d5fdb0a4..5c72458ea 100644 --- a/gst/gstquery.h +++ b/gst/gstquery.h @@ -107,6 +107,9 @@ struct _GstQuery struct _GstQueryClass { GstMiniObjectClass mini_object_class; + + /*< private > */ + gpointer _gst_reserved[GST_PADDING]; }; void _gst_query_initialize (void); diff --git a/gst/gstscheduler.c b/gst/gstscheduler.c deleted file mode 100644 index c3c0d1c18..000000000 --- a/gst/gstscheduler.c +++ /dev/null @@ -1,415 +0,0 @@ -/* GStreamer - * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu> - * 2000 Wim Taymans <wim.taymans@chello.be> - * - * 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, - * Boston, MA 02111-1307, USA. - */ - -#include "gst_private.h" - -#include "gstsystemclock.h" -#include "gstscheduler.h" -#include "gstinfo.h" -#include "gstregistrypool.h" - -static void gst_scheduler_class_init (GstSchedulerClass * klass); -static void gst_scheduler_init (GstScheduler * sched); -static void gst_scheduler_dispose (GObject * object); - -static GstObjectClass *parent_class = NULL; - -static gchar *_default_name = NULL; - -GType -gst_scheduler_get_type (void) -{ - static GType _gst_scheduler_type = 0; - - if (!_gst_scheduler_type) { - static const GTypeInfo scheduler_info = { - sizeof (GstSchedulerClass), - NULL, - NULL, - (GClassInitFunc) gst_scheduler_class_init, - NULL, - NULL, - sizeof (GstScheduler), - 0, - (GInstanceInitFunc) gst_scheduler_init, - NULL - }; - - _gst_scheduler_type = - g_type_register_static (GST_TYPE_OBJECT, "GstScheduler", - &scheduler_info, G_TYPE_FLAG_ABSTRACT); - } - return _gst_scheduler_type; -} - -static void -gst_scheduler_class_init (GstSchedulerClass * klass) -{ - GObjectClass *gobject_class; - - gobject_class = (GObjectClass *) klass; - - parent_class = g_type_class_ref (GST_TYPE_OBJECT); - - gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_scheduler_dispose); -} - -static void -gst_scheduler_init (GstScheduler * sched) -{ - sched->parent = NULL; -} - -static void -gst_scheduler_dispose (GObject * object) -{ - GstScheduler *sched = GST_SCHEDULER (object); - - G_OBJECT_CLASS (parent_class)->dispose (G_OBJECT (sched)); -} - -/** - * gst_scheduler_setup: - * @sched: the scheduler - * - * Prepare the scheduler. - */ -void -gst_scheduler_setup (GstScheduler * sched) -{ - GstSchedulerClass *sclass; - - g_return_if_fail (GST_IS_SCHEDULER (sched)); - - sclass = GST_SCHEDULER_GET_CLASS (sched); - - if (sclass->setup) - sclass->setup (sched); -} - -/** - * gst_scheduler_reset: - * @sched: a #GstScheduler to reset. - * - * Reset the schedulers. - */ -void -gst_scheduler_reset (GstScheduler * sched) -{ - GstSchedulerClass *sclass; - - g_return_if_fail (GST_IS_SCHEDULER (sched)); - - sclass = GST_SCHEDULER_GET_CLASS (sched); - - if (sclass->reset) - sclass->reset (sched); -} - -GstTask * -gst_scheduler_create_task (GstScheduler * sched, GstTaskFunction func, - gpointer data) -{ - GstSchedulerClass *sclass; - GstTask *result = NULL; - - g_return_val_if_fail (GST_IS_SCHEDULER (sched), result); - - sclass = GST_SCHEDULER_GET_CLASS (sched); - - if (sclass->create_task) - result = sclass->create_task (sched, func, data); - - return result; -} - -/* - * Factory stuff starts here - * - */ -static void gst_scheduler_factory_class_init (GstSchedulerFactoryClass * klass); -static void gst_scheduler_factory_init (GstSchedulerFactory * factory); - -static GstPluginFeatureClass *factory_parent_class = NULL; - -/* static guint gst_scheduler_factory_signals[LAST_SIGNAL] = { 0 }; */ - -GType -gst_scheduler_factory_get_type (void) -{ - static GType schedulerfactory_type = 0; - - if (!schedulerfactory_type) { - static const GTypeInfo schedulerfactory_info = { - sizeof (GstSchedulerFactoryClass), - NULL, - NULL, - (GClassInitFunc) gst_scheduler_factory_class_init, - NULL, - NULL, - sizeof (GstSchedulerFactory), - 0, - (GInstanceInitFunc) gst_scheduler_factory_init, - NULL - }; - - schedulerfactory_type = g_type_register_static (GST_TYPE_PLUGIN_FEATURE, - "GstSchedulerFactory", &schedulerfactory_info, 0); - } - return schedulerfactory_type; -} - -static void -gst_scheduler_factory_class_init (GstSchedulerFactoryClass * klass) -{ - GObjectClass *gobject_class; - GstObjectClass *gstobject_class; - GstPluginFeatureClass *gstpluginfeature_class; - - gobject_class = (GObjectClass *) klass; - gstobject_class = (GstObjectClass *) klass; - gstpluginfeature_class = (GstPluginFeatureClass *) klass; - - factory_parent_class = g_type_class_ref (GST_TYPE_PLUGIN_FEATURE); - - if (!_default_name) { - if (g_getenv ("GST_SCHEDULER")) { - _default_name = g_strdup (g_getenv ("GST_SCHEDULER")); - } else { - _default_name = g_strdup (GST_SCHEDULER_DEFAULT_NAME); - } - } - g_assert (_default_name); -} - -static void -gst_scheduler_factory_init (GstSchedulerFactory * factory) -{ -} - - -/** - * gst_scheduler_register: - * @plugin: a #GstPlugin - * @name: name of the scheduler to register - * @longdesc: description of the scheduler - * @type: #GType of the scheduler to register - * - * Registers a scheduler with GStreamer. - * - * Returns: TRUE, if the registering succeeded, FALSE on error. - * - * Since: 0.8.5 - **/ -gboolean -gst_scheduler_register (GstPlugin * plugin, const gchar * name, - const gchar * longdesc, GType type) -{ - GstSchedulerFactory *factory; - - g_return_val_if_fail (plugin != NULL, FALSE); - g_return_val_if_fail (name != NULL, FALSE); - g_return_val_if_fail (longdesc != NULL, FALSE); - g_return_val_if_fail (g_type_is_a (type, GST_TYPE_SCHEDULER), FALSE); - - factory = gst_scheduler_factory_find (name); - if (factory) { - g_return_val_if_fail (factory->type == 0, FALSE); - g_free (factory->longdesc); - factory->longdesc = g_strdup (longdesc); - factory->type = type; - } else { - factory = gst_scheduler_factory_new (name, longdesc, type); - g_return_val_if_fail (factory, FALSE); - gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (factory)); - } - - return TRUE; -} - -/** - * gst_scheduler_factory_new: - * @name: name of schedulerfactory to create - * @longdesc: long description of schedulerfactory to create - * @type: the gtk type of the GstScheduler element of this factory - * - * Create a new schedulerfactory with the given parameters - * - * Returns: a new #GstSchedulerFactory. - */ -GstSchedulerFactory * -gst_scheduler_factory_new (const gchar * name, const gchar * longdesc, - GType type) -{ - GstSchedulerFactory *factory; - - g_return_val_if_fail (name != NULL, NULL); - - factory = gst_scheduler_factory_find (name); - - if (!factory) { - factory = - GST_SCHEDULER_FACTORY (g_object_new (GST_TYPE_SCHEDULER_FACTORY, NULL)); - GST_PLUGIN_FEATURE_NAME (factory) = g_strdup (name); - } else { - g_free (factory->longdesc); - } - - factory->longdesc = g_strdup (longdesc); - factory->type = type; - - return factory; -} - -/** - * gst_scheduler_factory_destroy: - * @factory: factory to destroy - * - * Removes the scheduler from the global list. - */ -void -gst_scheduler_factory_destroy (GstSchedulerFactory * factory) -{ - g_return_if_fail (factory != NULL); - - /* we don't free the struct bacause someone might have a handle to it.. */ -} - -/** - * gst_scheduler_factory_find: - * @name: name of schedulerfactory to find - * - * Search for an schedulerfactory of the given name. - * - * Returns: #GstSchedulerFactory if found, NULL otherwise - */ -GstSchedulerFactory * -gst_scheduler_factory_find (const gchar * name) -{ - GstPluginFeature *feature; - - g_return_val_if_fail (name != NULL, NULL); - - GST_DEBUG ("gstscheduler: find \"%s\"", name); - - feature = gst_registry_pool_find_feature (name, GST_TYPE_SCHEDULER_FACTORY); - - if (feature) - return GST_SCHEDULER_FACTORY (feature); - - return NULL; -} - -/** - * gst_scheduler_factory_create: - * @factory: the factory used to create the instance - * @parent: the parent element of this scheduler - * - * Create a new #GstScheduler instance from the - * given schedulerfactory with the given parent. @parent will - * have its scheduler set to the returned #GstScheduler instance. - * - * Returns: A new #GstScheduler instance with a reference count of %1. - */ -GstScheduler * -gst_scheduler_factory_create (GstSchedulerFactory * factory, - GstElement * parent) -{ - GstScheduler *sched = NULL; - - g_return_val_if_fail (factory != NULL, NULL); - g_return_val_if_fail (GST_IS_ELEMENT (parent), NULL); - - if (gst_plugin_feature_ensure_loaded (GST_PLUGIN_FEATURE (factory))) { - g_return_val_if_fail (factory->type != 0, NULL); - - sched = GST_SCHEDULER (g_object_new (factory->type, NULL)); - sched->parent = parent; - - /* let's refcount the scheduler */ - gst_object_ref (sched); - gst_object_sink (GST_OBJECT (sched)); - } - - return sched; -} - -/** - * gst_scheduler_factory_make: - * @name: the name of the factory used to create the instance - * @parent: the parent element of this scheduler - * - * Create a new #GstScheduler instance from the - * schedulerfactory with the given name and parent. @parent will - * have its scheduler set to the returned #GstScheduler instance. - * If %NULL is passed as @name, the default scheduler name will - * be used. - * - * Returns: A new #GstScheduler instance with a reference count of %1. - */ -GstScheduler * -gst_scheduler_factory_make (const gchar * name, GstElement * parent) -{ - GstSchedulerFactory *factory; - const gchar *default_name = gst_scheduler_factory_get_default_name (); - - if (name) - factory = gst_scheduler_factory_find (name); - else { - /* FIXME: do better error handling */ - if (default_name == NULL) - g_error ("No default scheduler name - do you have a registry ?"); - factory = gst_scheduler_factory_find (default_name); - } - - if (factory == NULL) - return NULL; - - return gst_scheduler_factory_create (factory, parent); -} - -/** - * gst_scheduler_factory_set_default_name: - * @name: the name of the factory used as a default - * - * Set the default schedulerfactory name. - */ -void -gst_scheduler_factory_set_default_name (const gchar * name) -{ - g_free (_default_name); - - _default_name = g_strdup (name); -} - -/** - * gst_scheduler_factory_get_default_name: - * - * Get the default schedulerfactory name. - * - * Returns: the name of the default scheduler. - */ -const gchar * -gst_scheduler_factory_get_default_name (void) -{ - return _default_name; -} diff --git a/gst/gstscheduler.h b/gst/gstscheduler.h deleted file mode 100644 index d6e610233..000000000 --- a/gst/gstscheduler.h +++ /dev/null @@ -1,130 +0,0 @@ -/* GStreamer - * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu> - * 2000 Wim Taymans <wtay@chello.be> - * - * gstscheduler.h: Header for default scheduler code - * - * 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, - * Boston, MA 02111-1307, USA. - */ - - -#ifndef __GST_SCHEDULER_H__ -#define __GST_SCHEDULER_H__ - -#include <glib.h> -#include <gst/gstelement.h> -#include <gst/gstbin.h> -#include <gst/gsttask.h> - -G_BEGIN_DECLS - -#define GST_TYPE_SCHEDULER (gst_scheduler_get_type ()) -#define GST_SCHEDULER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_SCHEDULER, GstScheduler)) -#define GST_IS_SCHEDULER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_SCHEDULER)) -#define GST_SCHEDULER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_SCHEDULER,GstSchedulerClass)) -#define GST_IS_SCHEDULER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_SCHEDULER)) -#define GST_SCHEDULER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_SCHEDULER, GstSchedulerClass)) - -typedef enum { - /* padding */ - GST_SCHEDULER_FLAG_LAST = GST_OBJECT_FLAG_LAST + 4 -} GstSchedulerFlags; - -#define GST_SCHEDULER_PARENT(sched) ((sched)->parent) -#define GST_SCHEDULER_STATE(sched) ((sched)->state) - -/*typedef struct _GstScheduler GstScheduler; */ -/*typedef struct _GstSchedulerClass GstSchedulerClass; */ - -struct _GstScheduler { - GstObject object; - - GstElement *parent; - - gpointer _gst_reserved[GST_PADDING]; -}; - -struct _GstSchedulerClass { - GstObjectClass parent_class; - - /* virtual methods */ - void (*setup) (GstScheduler *sched); - void (*reset) (GstScheduler *sched); - - GstTask* (*create_task) (GstScheduler *sched, GstTaskFunction func, gpointer data); - - gpointer _gst_reserved[GST_PADDING]; -}; - -GType gst_scheduler_get_type (void); - - -void gst_scheduler_setup (GstScheduler *sched); -void gst_scheduler_reset (GstScheduler *sched); -GstTask* gst_scheduler_create_task (GstScheduler *sched, GstTaskFunction func, gpointer data); - - -/* - * creating schedulers - * - */ -#define GST_TYPE_SCHEDULER_FACTORY (gst_scheduler_factory_get_type ()) -#define GST_SCHEDULER_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_SCHEDULER_FACTORY, GstSchedulerFactory)) -#define GST_IS_SCHEDULER_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_SCHEDULER_FACTORY)) -#define GST_SCHEDULER_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_SCHEDULER_FACTORY, GstSchedulerFactoryClass)) -#define GST_IS_SCHEDULER_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_SCHEDULER_FACTORY)) -#define GST_SCHEDULER_FACTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_SCHEDULER_FACTORY, GstSchedulerFactoryClass)) - -/* change this to change the default scheduler */ -#define GST_SCHEDULER_DEFAULT_NAME "thread" - -typedef struct _GstSchedulerFactory GstSchedulerFactory; -typedef struct _GstSchedulerFactoryClass GstSchedulerFactoryClass; - -struct _GstSchedulerFactory { - GstPluginFeature feature; - - gchar *longdesc; /* long description of the scheduler (well, don't overdo it..) */ - GType type; /* unique GType of the scheduler */ - - gpointer _gst_reserved[GST_PADDING]; -}; - -struct _GstSchedulerFactoryClass { - GstPluginFeatureClass parent; - - gpointer _gst_reserved[GST_PADDING]; -}; - -GType gst_scheduler_factory_get_type (void); - -gboolean gst_scheduler_register (GstPlugin *plugin, const gchar *name, - const gchar *longdesc, GType type); -GstSchedulerFactory* gst_scheduler_factory_new (const gchar *name, const gchar *longdesc, GType type); -void gst_scheduler_factory_destroy (GstSchedulerFactory *factory); - -GstSchedulerFactory* gst_scheduler_factory_find (const gchar *name); - -GstScheduler* gst_scheduler_factory_create (GstSchedulerFactory *factory, GstElement *parent); -GstScheduler* gst_scheduler_factory_make (const gchar *name, GstElement *parent); - -void gst_scheduler_factory_set_default_name (const gchar* name); -G_CONST_RETURN gchar* gst_scheduler_factory_get_default_name (void); - - -G_END_DECLS - -#endif /* __GST_SCHEDULER_H__ */ diff --git a/gst/gststructure.h b/gst/gststructure.h index f729c1387..1658f4798 100644 --- a/gst/gststructure.h +++ b/gst/gststructure.h @@ -21,7 +21,6 @@ #define __GST_STRUCTURE_H__ #include <gst/gstconfig.h> -#include <gst/gsttypes.h> #include <glib-object.h> G_BEGIN_DECLS diff --git a/gst/gsttask.c b/gst/gsttask.c index 332724bd1..fec1f8eac 100644 --- a/gst/gsttask.c +++ b/gst/gsttask.c @@ -27,7 +27,9 @@ static void gst_task_class_init (GstTaskClass * klass); static void gst_task_init (GstTask * task); -static void gst_task_dispose (GObject * object); +static void gst_task_finalize (GObject * object); + +static void gst_task_func (GstTask * task, GstTaskClass * tclass); static GstObjectClass *parent_class = NULL; @@ -51,8 +53,7 @@ gst_task_get_type (void) }; _gst_task_type = - g_type_register_static (GST_TYPE_OBJECT, "GstTask", - &task_info, G_TYPE_FLAG_ABSTRACT); + g_type_register_static (GST_TYPE_OBJECT, "GstTask", &task_info, 0); } return _gst_task_type; } @@ -66,7 +67,10 @@ gst_task_class_init (GstTaskClass * klass) parent_class = g_type_class_ref (GST_TYPE_OBJECT); - gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_task_dispose); + gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_task_finalize); + + klass->pool = g_thread_pool_new ( + (GFunc) gst_task_func, klass, -1, FALSE, NULL); } static void @@ -78,17 +82,60 @@ gst_task_init (GstTask * task) } static void -gst_task_dispose (GObject * object) +gst_task_finalize (GObject * object) { GstTask *task = GST_TASK (object); - GST_DEBUG ("task %p dispose", task); + GST_DEBUG ("task %p finalize", task); g_cond_free (task->cond); + task->cond = NULL; G_OBJECT_CLASS (parent_class)->dispose (object); } +static void +gst_task_func (GstTask * task, GstTaskClass * tclass) +{ + GST_DEBUG ("Entering task %p, thread %p", task, g_thread_self ()); + + /* locking order is TASK_LOCK, LOCK */ + GST_TASK_LOCK (task); + GST_LOCK (task); + while (G_LIKELY (task->state != GST_TASK_STOPPED)) { + while (G_UNLIKELY (task->state == GST_TASK_PAUSED)) { + gint t; + + t = GST_TASK_UNLOCK_FULL (task); + if (t <= 0) { + g_warning ("wrong STREAM_LOCK count %d", t); + } + GST_TASK_SIGNAL (task); + GST_TASK_WAIT (task); + GST_UNLOCK (task); + /* locking order.. */ + if (t > 0) + GST_TASK_LOCK_FULL (task, t); + + GST_LOCK (task); + if (task->state == GST_TASK_STOPPED) + goto done; + } + GST_UNLOCK (task); + + task->func (task->data); + + GST_LOCK (task); + } +done: + GST_UNLOCK (task); + GST_TASK_UNLOCK (task); + + GST_DEBUG ("Exit task %p, thread %p", task, g_thread_self ()); + + gst_object_unref (task); +} + /** * gst_task_create: * @func: The #GstTaskFunction to use @@ -105,7 +152,15 @@ gst_task_dispose (GObject * object) GstTask * gst_task_create (GstTaskFunction func, gpointer data) { - return NULL; + GstTask *task; + + task = g_object_new (GST_TYPE_TASK, NULL); + task->func = func; + task->data = data; + + GST_DEBUG ("Created task %p", task); + + return task; } /** @@ -164,16 +219,38 @@ gboolean gst_task_start (GstTask * task) { GstTaskClass *tclass; - gboolean result = FALSE; + GstTaskState old; + GStaticRecMutex *lock; g_return_val_if_fail (GST_IS_TASK (task), FALSE); tclass = GST_TASK_GET_CLASS (task); - if (tclass->start) - result = tclass->start (task); + GST_DEBUG_OBJECT (task, "Starting task %p", task); - return result; + GST_LOCK (task); + if (G_UNLIKELY (GST_TASK_GET_LOCK (task) == NULL)) { + lock = g_new (GStaticRecMutex, 1); + g_static_rec_mutex_init (lock); + GST_TASK_GET_LOCK (task) = lock; + } + + old = task->state; + task->state = GST_TASK_STARTED; + switch (old) { + case GST_TASK_STOPPED: + gst_object_ref (task); + g_thread_pool_push (tclass->pool, task, NULL); + break; + case GST_TASK_PAUSED: + GST_TASK_SIGNAL (task); + break; + case GST_TASK_STARTED: + break; + } + GST_UNLOCK (task); + + return TRUE; } /** @@ -190,16 +267,29 @@ gboolean gst_task_stop (GstTask * task) { GstTaskClass *tclass; - gboolean result = FALSE; + GstTaskState old; g_return_val_if_fail (GST_IS_TASK (task), FALSE); tclass = GST_TASK_GET_CLASS (task); - if (tclass->stop) - result = tclass->stop (task); + GST_DEBUG_OBJECT (task, "Stopping task %p", task); - return result; + GST_LOCK (task); + old = task->state; + task->state = GST_TASK_STOPPED; + switch (old) { + case GST_TASK_STOPPED: + break; + case GST_TASK_PAUSED: + GST_TASK_SIGNAL (task); + break; + case GST_TASK_STARTED: + break; + } + GST_UNLOCK (task); + + return TRUE; } /** @@ -216,14 +306,28 @@ gboolean gst_task_pause (GstTask * task) { GstTaskClass *tclass; - gboolean result = FALSE; + GstTaskState old; g_return_val_if_fail (GST_IS_TASK (task), FALSE); tclass = GST_TASK_GET_CLASS (task); - if (tclass->pause) - result = tclass->pause (task); + GST_DEBUG_OBJECT (task, "Pausing task %p", task); - return result; + GST_LOCK (task); + old = task->state; + task->state = GST_TASK_PAUSED; + switch (old) { + case GST_TASK_STOPPED: + gst_object_ref (task); + g_thread_pool_push (tclass->pool, task, NULL); + break; + case GST_TASK_PAUSED: + break; + case GST_TASK_STARTED: + break; + } + GST_UNLOCK (task); + + return TRUE; } diff --git a/gst/gsttask.h b/gst/gsttask.h index a42dbb8af..c1210c371 100644 --- a/gst/gsttask.h +++ b/gst/gsttask.h @@ -63,7 +63,6 @@ typedef enum { struct _GstTask { GstObject object; - /*< public >*/ /* with LOCK */ GstTaskState state; GCond *cond; @@ -80,10 +79,8 @@ struct _GstTask { struct _GstTaskClass { GstObjectClass parent_class; - /*< protected >*/ - gboolean (*start) (GstTask *task); - gboolean (*stop) (GstTask *task); - gboolean (*pause) (GstTask *task); + /*< private >*/ + GThreadPool *pool; /*< private >*/ gpointer _gst_reserved[GST_PADDING]; diff --git a/gst/gsttypefind.h b/gst/gsttypefind.h index bf4867d47..7f3471703 100644 --- a/gst/gsttypefind.h +++ b/gst/gsttypefind.h @@ -23,11 +23,9 @@ #ifndef __GST_TYPE_FIND_H__ #define __GST_TYPE_FIND_H__ -#include <gst/gstbuffer.h> #include <gst/gstcaps.h> #include <gst/gstplugin.h> #include <gst/gstpluginfeature.h> -#include <gst/gsttypes.h> G_BEGIN_DECLS @@ -54,17 +52,17 @@ typedef enum { struct _GstTypeFind { /* private to the caller of the typefind function */ - guint8 * (* peek) (gpointer data, - gint64 offset, - guint size); - void (* suggest) (gpointer data, - guint probability, - const GstCaps * caps); + guint8 * (* peek) (gpointer data, + gint64 offset, + guint size); + void (* suggest) (gpointer data, + guint probability, + const GstCaps * caps); - gpointer data; + gpointer data; /* optional */ - guint64 (* get_length) (gpointer data); + guint64 (* get_length) (gpointer data); /* <private> */ gpointer _gst_reserved[GST_PADDING]; diff --git a/gst/gsttypes.h b/gst/gsttypes.h deleted file mode 100644 index a00819be7..000000000 --- a/gst/gsttypes.h +++ /dev/null @@ -1,74 +0,0 @@ -/* GStreamer - * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu> - * - * 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, - * Boston, MA 02111-1307, USA. - */ - -#ifndef __GST_TYPES_H__ -#define __GST_TYPES_H__ - -#include <glib.h> - -G_BEGIN_DECLS - -typedef struct _GstBin GstBin; -typedef struct _GstBinClass GstBinClass; -typedef struct _GstBus GstBus; -typedef struct _GstBusClass GstBusClass; -typedef struct _GstElement GstElement; -typedef struct _GstElementClass GstElementClass; -typedef struct _GstElementDetails GstElementDetails; -typedef struct _GstElementFactory GstElementFactory; -typedef struct _GstElementFactoryClass GstElementFactoryClass; -typedef struct _GstObject GstObject; -typedef struct _GstObjectClass GstObjectClass; -typedef struct _GstPad GstPad; -typedef struct _GstPadClass GstPadClass; -typedef struct _GstPadTemplate GstPadTemplate; -typedef struct _GstPadTemplateClass GstPadTemplateClass; -typedef struct _GstPipeline GstPipeline; -typedef struct _GstPipelineClass GstPipelineClass; -typedef struct _GstScheduler GstScheduler; -typedef struct _GstSchedulerClass GstSchedulerClass; - -typedef enum { - GST_STATE_VOID_PENDING = 0, - GST_STATE_NULL = (1 << 0), - GST_STATE_READY = (1 << 1), - GST_STATE_PAUSED = (1 << 2), - GST_STATE_PLAYING = (1 << 3) -} GstElementState; - -typedef enum { - GST_STATE_FAILURE = 0, - GST_STATE_SUCCESS = 1, - GST_STATE_ASYNC = 2, - GST_STATE_NO_PREROLL = 3 -} GstElementStateReturn; - -typedef enum { - GST_RANK_NONE = 0, - GST_RANK_MARGINAL = 64, - GST_RANK_SECONDARY = 128, - GST_RANK_PRIMARY = 256 -} GstRank; - -#define GST_PADDING 4 -#define GST_PADDING_INIT { 0 } - -G_END_DECLS - -#endif /* __GST_TYPES_H__ */ diff --git a/gst/registries/gstlibxmlregistry.c b/gst/registries/gstlibxmlregistry.c index 9cdb29927..38b72afe0 100644 --- a/gst/registries/gstlibxmlregistry.c +++ b/gst/registries/gstlibxmlregistry.c @@ -54,7 +54,6 @@ #include <gst/gst_private.h> #include <gst/gstelement.h> #include <gst/gsttypefind.h> -#include <gst/gstscheduler.h> #include <gst/gsturi.h> #include <gst/gstinfo.h> #include <gst/gstenumtypes.h> @@ -798,11 +797,6 @@ load_feature (xmlTextReaderPtr reader) g_free (s); } } - } else if (GST_IS_SCHEDULER_FACTORY (feature)) { - GstSchedulerFactory *factory = GST_SCHEDULER_FACTORY (feature); - - if (g_str_equal (tag, "longdesc")) - read_string (reader, &factory->longdesc); } else if (GST_IS_INDEX_FACTORY (feature)) { GstIndexFactory *factory = GST_INDEX_FACTORY (feature); @@ -905,7 +899,6 @@ gst_xml_registry_load (GstRegistry * registry) /* make sure these types exist */ GST_TYPE_ELEMENT_FACTORY; - GST_TYPE_SCHEDULER_FACTORY; GST_TYPE_TYPE_FIND_FACTORY; GST_TYPE_INDEX_FACTORY; @@ -1125,8 +1118,6 @@ gst_xml_registry_save_feature (GstXMLRegistry * xmlregistry, i++; } } - } else if (GST_IS_SCHEDULER_FACTORY (feature)) { - PUT_ESCAPED ("longdesc", GST_SCHEDULER_FACTORY (feature)->longdesc); } else if (GST_IS_INDEX_FACTORY (feature)) { PUT_ESCAPED ("longdesc", GST_INDEX_FACTORY (feature)->longdesc); } diff --git a/gst/registries/gstxmlregistry.c b/gst/registries/gstxmlregistry.c index d5092b34c..7dd2a281b 100644 --- a/gst/registries/gstxmlregistry.c +++ b/gst/registries/gstxmlregistry.c @@ -54,7 +54,6 @@ #include <gst/gst_private.h> #include <gst/gstelement.h> #include <gst/gsttypefind.h> -#include <gst/gstscheduler.h> #include <gst/gsturi.h> #include <gst/gstinfo.h> @@ -853,22 +852,6 @@ gst_xml_registry_parse_type_find_factory (GMarkupParseContext * context, } static gboolean -gst_xml_registry_parse_scheduler_factory (GMarkupParseContext * context, - const gchar * tag, const gchar * text, gsize text_len, - GstXMLRegistry * registry, GError ** error) -{ - GstSchedulerFactory *factory = - GST_SCHEDULER_FACTORY (registry->current_feature); - - if (!strcmp (tag, "name")) { - registry->current_feature->name = g_strndup (text, text_len); - } else if (!strcmp (tag, "longdesc")) { - factory->longdesc = g_strndup (text, text_len); - } - return TRUE; -} - -static gboolean gst_xml_registry_parse_index_factory (GMarkupParseContext * context, const gchar * tag, const gchar * text, gsize text_len, GstXMLRegistry * registry, GError ** error) @@ -971,9 +954,6 @@ gst_xml_registry_start_element (GMarkupParseContext * context, break; } else if (GST_IS_TYPE_FIND_FACTORY (feature)) { xmlregistry->parser = gst_xml_registry_parse_type_find_factory; - } else if (GST_IS_SCHEDULER_FACTORY (feature)) { - xmlregistry->parser = gst_xml_registry_parse_scheduler_factory; - GST_SCHEDULER_FACTORY (feature)->type = 0; } else if (GST_IS_INDEX_FACTORY (feature)) { xmlregistry->parser = gst_xml_registry_parse_index_factory; } else { @@ -1274,8 +1254,6 @@ gst_xml_registry_save_feature (GstXMLRegistry * xmlregistry, i++; } } - } else if (GST_IS_SCHEDULER_FACTORY (feature)) { - PUT_ESCAPED ("longdesc", GST_SCHEDULER_FACTORY (feature)->longdesc); } else if (GST_IS_INDEX_FACTORY (feature)) { PUT_ESCAPED ("longdesc", GST_INDEX_FACTORY (feature)->longdesc); } diff --git a/gst/schedulers/threadscheduler.c b/gst/schedulers/threadscheduler.c deleted file mode 100644 index a94c3a29a..000000000 --- a/gst/schedulers/threadscheduler.c +++ /dev/null @@ -1,388 +0,0 @@ -/* GStreamer2 - * Copyright (C) 2004 Wim Taymans <wim@fluendo.com> - * - * threadscheduler.c: scheduler using threads - * - * 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, - * Boston, MA 02111-1307, USA. - */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include <gst/gst.h> -#include "../gst-i18n-lib.h" - -GST_DEBUG_CATEGORY_STATIC (debug_scheduler); -#define GST_CAT_DEFAULT debug_scheduler - -#define GST_TYPE_THREAD_SCHEDULER \ - (gst_thread_scheduler_get_type ()) -#define GST_THREAD_SCHEDULER(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_THREAD_SCHEDULER,GstThreadScheduler)) -#define GST_THREAD_SCHEDULER_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_THREAD_SCHEDULER,GstThreadSchedulerClass)) -#define GST_IS_THREAD_SCHEDULER(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_THREAD_SCHEDULER)) -#define GST_IS_THREAD_SCHEDULER_CLASS(obj) \ - (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_THREAD_SCHEDULER)) - -#define SCHED(element) (GST_THREAD_SCHEDULER ((element)->sched)) - -GType gst_thread_scheduler_get_type (void); - -typedef struct _GstThreadScheduler GstThreadScheduler; -typedef struct _GstThreadSchedulerClass GstThreadSchedulerClass; - -struct _GstThreadScheduler -{ - GstScheduler scheduler; - - GThreadPool *pool; -}; - -struct _GstThreadSchedulerClass -{ - GstSchedulerClass scheduler_class; -}; - -#define ELEMENT_PRIVATE(element) GST_ELEMENT (element)->sched_private -#define PAD_PRIVATE(pad) (GST_REAL_PAD (pad))->sched_private - -#define GST_TYPE_THREAD_SCHEDULER_TASK \ - (gst_thread_scheduler_task_get_type ()) -#define GST_THREAD_SCHEDULER_TASK(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_THREAD_SCHEDULER_TASK,GstThreadSchedulerTask)) -#define GST_THREAD_SCHEDULER_TASK_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_THREAD_SCHEDULER_TASK,GstThreadSchedulerTaskClass)) -#define GST_IS_THREAD_SCHEDULER_TASK(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_THREAD_SCHEDULER_TASK)) -#define GST_IS_THREAD_SCHEDULER_TASK_CLASS(obj) \ - (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_THREAD_SCHEDULER_TASK)) - -typedef struct _GstThreadSchedulerTask GstThreadSchedulerTask; -typedef struct _GstThreadSchedulerTaskClass GstThreadSchedulerTaskClass; - -struct _GstThreadSchedulerTask -{ - GstTask task; -}; - -struct _GstThreadSchedulerTaskClass -{ - GstTaskClass parent_class; -}; - -static void gst_thread_scheduler_task_class_init (gpointer g_class, - gpointer data); -static void gst_thread_scheduler_task_init (GstThreadSchedulerTask * object); - -static gboolean gst_thread_scheduler_task_start (GstTask * task); -static gboolean gst_thread_scheduler_task_stop (GstTask * task); -static gboolean gst_thread_scheduler_task_pause (GstTask * task); - -GType -gst_thread_scheduler_task_get_type (void) -{ - static GType object_type = 0; - - if (object_type == 0) { - static const GTypeInfo object_info = { - sizeof (GstThreadSchedulerTaskClass), - NULL, - NULL, - gst_thread_scheduler_task_class_init, - NULL, - NULL, - sizeof (GstThreadSchedulerTask), - 0, - (GInstanceInitFunc) gst_thread_scheduler_task_init - }; - - object_type = - g_type_register_static (GST_TYPE_TASK, - "GstThreadSchedulerTask", &object_info, 0); - } - return object_type; -} - -static void -gst_thread_scheduler_task_class_init (gpointer klass, gpointer class_data) -{ - GstTaskClass *task = GST_TASK_CLASS (klass); - - task->start = gst_thread_scheduler_task_start; - task->stop = gst_thread_scheduler_task_stop; - task->pause = gst_thread_scheduler_task_pause; -} - -static void -gst_thread_scheduler_task_init (GstThreadSchedulerTask * task) -{ - GST_TASK (task)->state = GST_TASK_STOPPED; -} - -static gboolean -gst_thread_scheduler_task_start (GstTask * task) -{ - GstThreadSchedulerTask *ttask = GST_THREAD_SCHEDULER_TASK (task); - GstThreadScheduler *tsched = - GST_THREAD_SCHEDULER (GST_OBJECT_PARENT (GST_OBJECT (task))); - GstTaskState old; - GStaticRecMutex *lock; - - GST_DEBUG_OBJECT (task, "Starting task %p", task); - - if ((lock = GST_TASK_GET_LOCK (task)) == NULL) { - lock = g_new (GStaticRecMutex, 1); - g_static_rec_mutex_init (lock); - GST_TASK_GET_LOCK (task) = lock; - } - - GST_LOCK (ttask); - old = GST_TASK_CAST (ttask)->state; - GST_TASK_CAST (ttask)->state = GST_TASK_STARTED; - switch (old) { - case GST_TASK_STOPPED: - gst_object_ref (task); - g_thread_pool_push (tsched->pool, task, NULL); - break; - case GST_TASK_PAUSED: - GST_TASK_SIGNAL (ttask); - break; - case GST_TASK_STARTED: - break; - } - GST_UNLOCK (ttask); - - return TRUE; -} - -static gboolean -gst_thread_scheduler_task_stop (GstTask * task) -{ - GstThreadSchedulerTask *ttask = GST_THREAD_SCHEDULER_TASK (task); - GstTaskState old; - - GST_DEBUG_OBJECT (task, "Stopping task %p", task); - - GST_LOCK (ttask); - old = GST_TASK_CAST (ttask)->state; - GST_TASK_CAST (ttask)->state = GST_TASK_STOPPED; - switch (old) { - case GST_TASK_STOPPED: - break; - case GST_TASK_PAUSED: - GST_TASK_SIGNAL (ttask); - break; - case GST_TASK_STARTED: - break; - } - GST_UNLOCK (ttask); - - return TRUE; -} - -static gboolean -gst_thread_scheduler_task_pause (GstTask * task) -{ - GstThreadSchedulerTask *ttask = GST_THREAD_SCHEDULER_TASK (task); - GstThreadScheduler *tsched = - GST_THREAD_SCHEDULER (GST_OBJECT_PARENT (GST_OBJECT (task))); - GstTaskState old; - - GST_DEBUG_OBJECT (task, "Pausing task %p", task); - - GST_LOCK (ttask); - old = GST_TASK_CAST (ttask)->state; - GST_TASK_CAST (ttask)->state = GST_TASK_PAUSED; - switch (old) { - case GST_TASK_STOPPED: - gst_object_ref (task); - g_thread_pool_push (tsched->pool, task, NULL); - break; - case GST_TASK_PAUSED: - break; - case GST_TASK_STARTED: - break; - } - GST_UNLOCK (ttask); - - return TRUE; -} - -static void gst_thread_scheduler_class_init (gpointer g_class, gpointer data); -static void gst_thread_scheduler_init (GstThreadScheduler * object); -static void gst_thread_scheduler_dispose (GObject * object); - -GType -gst_thread_scheduler_get_type (void) -{ - static GType object_type = 0; - - if (object_type == 0) { - static const GTypeInfo object_info = { - sizeof (GstThreadSchedulerClass), - NULL, - NULL, - gst_thread_scheduler_class_init, - NULL, - NULL, - sizeof (GstThreadScheduler), - 0, - (GInstanceInitFunc) gst_thread_scheduler_init - }; - - object_type = - g_type_register_static (GST_TYPE_SCHEDULER, - "GstThreadScheduler", &object_info, 0); - } - return object_type; -} - -static void gst_thread_scheduler_setup (GstScheduler * sched); -static void gst_thread_scheduler_reset (GstScheduler * sched); -static GstTask *gst_thread_scheduler_create_task (GstScheduler * sched, - GstTaskFunction func, gpointer data); - -static GObjectClass *parent_class = NULL; - -static void -gst_thread_scheduler_class_init (gpointer klass, gpointer class_data) -{ - GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - GstSchedulerClass *scheduler = GST_SCHEDULER_CLASS (klass); - - parent_class = g_type_class_ref (GST_TYPE_SCHEDULER); - - gobject_class->dispose = gst_thread_scheduler_dispose; - - scheduler->setup = gst_thread_scheduler_setup; - scheduler->reset = gst_thread_scheduler_reset; - scheduler->create_task = gst_thread_scheduler_create_task; -} - -static void -gst_thread_scheduler_func (GstThreadSchedulerTask * ttask, - GstThreadScheduler * sched) -{ - GstTask *task = GST_TASK (ttask); - - GST_DEBUG_OBJECT (sched, "Entering task %p, thread %p", task, - g_thread_self ()); - - /* locking order is TASK_LOCK, LOCK */ - GST_TASK_LOCK (task); - GST_LOCK (task); - while (G_LIKELY (task->state != GST_TASK_STOPPED)) { - while (G_UNLIKELY (task->state == GST_TASK_PAUSED)) { - guint t; - - t = GST_TASK_UNLOCK_FULL (task); - if (t <= 0) { - g_warning ("wrong STREAM_LOCK count"); - } - GST_TASK_SIGNAL (task); - GST_TASK_WAIT (task); - GST_UNLOCK (task); - /* locking order.. */ - if (t > 0) - GST_TASK_LOCK_FULL (task, t); - - GST_LOCK (task); - if (task->state == GST_TASK_STOPPED) - goto done; - } - GST_UNLOCK (task); - - task->func (task->data); - - GST_LOCK (task); - } -done: - GST_UNLOCK (task); - GST_TASK_UNLOCK (task); - - GST_DEBUG_OBJECT (sched, "Exit task %p, thread %p", task, g_thread_self ()); - - gst_object_unref (task); -} - -static void -gst_thread_scheduler_init (GstThreadScheduler * scheduler) -{ - scheduler->pool = g_thread_pool_new ( - (GFunc) gst_thread_scheduler_func, scheduler, -1, FALSE, NULL); -} -static void -gst_thread_scheduler_dispose (GObject * object) -{ - GstThreadScheduler *scheduler = GST_THREAD_SCHEDULER (object); - - if (scheduler->pool) { - g_thread_pool_free (scheduler->pool, FALSE, TRUE); - scheduler->pool = NULL; - } - G_OBJECT_CLASS (parent_class)->dispose (object); -} - -static GstTask * -gst_thread_scheduler_create_task (GstScheduler * sched, GstTaskFunction func, - gpointer data) -{ - GstThreadSchedulerTask *task; - - task = - GST_THREAD_SCHEDULER_TASK (g_object_new (GST_TYPE_THREAD_SCHEDULER_TASK, - NULL)); - gst_object_set_parent (GST_OBJECT (task), GST_OBJECT (sched)); - GST_TASK_CAST (task)->func = func; - GST_TASK_CAST (task)->data = data; - - GST_DEBUG_OBJECT (sched, "Created task %p", task); - - return GST_TASK_CAST (task); -} - -static void -gst_thread_scheduler_setup (GstScheduler * sched) -{ -} - -static void -gst_thread_scheduler_reset (GstScheduler * sched) -{ -} - -static gboolean -plugin_init (GstPlugin * plugin) -{ - GstSchedulerFactory *factory; - - GST_DEBUG_CATEGORY_INIT (debug_scheduler, "thread", 0, "thread scheduler"); - - factory = gst_scheduler_factory_new ("thread", - "A scheduler using threads", GST_TYPE_THREAD_SCHEDULER); - if (factory == NULL) - return FALSE; - - gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (factory)); - return TRUE; -} - -GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, GST_VERSION_MINOR, "gstthreadscheduler", - "a thread scheduler", plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, - GST_ORIGIN) diff --git a/libs/gst/control/dparammanager.h b/libs/gst/control/dparammanager.h index c5ee0be39..b12d5f833 100644 --- a/libs/gst/control/dparammanager.h +++ b/libs/gst/control/dparammanager.h @@ -22,7 +22,7 @@ #ifndef __GST_DPMAN_H__ #define __GST_DPMAN_H__ -#include <gst/gstobject.h> +#include <gst/gstelement.h> #include <gst/control/dparamcommon.h> #include <gst/control/dparam.h> #include <gst/control/unitconvert.h> diff --git a/tests/check/elements/gstfakesrc.c b/tests/check/elements/gstfakesrc.c index 85be97f14..febebea3f 100644 --- a/tests/check/elements/gstfakesrc.c +++ b/tests/check/elements/gstfakesrc.c @@ -60,7 +60,6 @@ event_func (GstPad * pad, GstEvent * event) GST_START_TEST (test_num_buffers) { GstElement *src; - GstScheduler *scheduler; GstPad *srcpad, *sinkpad; src = gst_element_factory_make ("fakesrc", "src"); @@ -73,9 +72,6 @@ GST_START_TEST (test_num_buffers) g_object_set (G_OBJECT (src), "num-buffers", 3, NULL); - scheduler = gst_scheduler_factory_make (NULL, src); - gst_element_set_scheduler (src, scheduler); - srcpad = gst_element_get_pad (src, "src"); fail_if (srcpad == NULL, "Could not get source pad from fakesrc"); gst_pad_set_caps (sinkpad, NULL); diff --git a/tools/gst-inspect.c b/tools/gst-inspect.c index 79db92bed..95a9db0b7 100644 --- a/tools/gst-inspect.c +++ b/tools/gst-inspect.c @@ -883,13 +883,6 @@ print_element_list (gboolean print_all) if (!print_all) g_print ("no extensions\n"); } - } else if (GST_IS_SCHEDULER_FACTORY (feature)) { - GstSchedulerFactory *factory; - - factory = GST_SCHEDULER_FACTORY (feature); - if (!print_all) - g_print ("%s: %s: %s\n", plugin->desc.name, - GST_PLUGIN_FEATURE_NAME (factory), factory->longdesc); } else { if (!print_all) n_print ("%s: %s (%s)\n", plugin->desc.name, @@ -923,7 +916,6 @@ print_plugin_features (GstPlugin * plugin) gint num_features = 0; gint num_elements = 0; gint num_types = 0; - gint num_schedulers = 0; gint num_indexes = 0; gint num_other = 0; @@ -968,12 +960,6 @@ print_plugin_features (GstPlugin * plugin) g_print ("%s type: N/A\n", plugin->desc.name); num_types++; - } else if (GST_IS_SCHEDULER_FACTORY (feature)) { - GstSchedulerFactory *factory; - - factory = GST_SCHEDULER_FACTORY (feature); - n_print (" %s: %s\n", GST_OBJECT_NAME (factory), factory->longdesc); - num_schedulers++; } else { n_print (" %s (%s)\n", gst_object_get_name (GST_OBJECT (feature)), g_type_name (G_OBJECT_TYPE (feature))); @@ -988,8 +974,6 @@ print_plugin_features (GstPlugin * plugin) n_print (" +-- %d elements\n", num_elements); if (num_types > 0) n_print (" +-- %d types\n", num_types); - if (num_schedulers > 0) - n_print (" +-- %d schedulers\n", num_schedulers); if (num_indexes > 0) n_print (" +-- %d indexes\n", num_indexes); if (num_other > 0) @@ -1004,12 +988,6 @@ print_element_features (const gchar * element_name) GstPluginFeature *feature; /* FIXME implement other pretty print function for these */ - feature = gst_registry_pool_find_feature (element_name, - GST_TYPE_SCHEDULER_FACTORY); - if (feature) { - n_print ("%s: a scheduler\n", element_name); - return 0; - } #ifndef GST_DISABLE_INDEX feature = gst_registry_pool_find_feature (element_name, GST_TYPE_INDEX_FACTORY); diff --git a/tools/gst-xmlinspect.c b/tools/gst-xmlinspect.c index 7d686f83a..dde66eb76 100644 --- a/tools/gst-xmlinspect.c +++ b/tools/gst-xmlinspect.c @@ -709,12 +709,6 @@ print_element_list (void) } } else g_print ("%s type: N/A\n", plugin->desc.name); - } else if (GST_IS_SCHEDULER_FACTORY (feature)) { - GstSchedulerFactory *factory; - - factory = GST_SCHEDULER_FACTORY (feature); - g_print ("%s: %s: %s\n", plugin->desc.name, - GST_PLUGIN_FEATURE_NAME (factory), factory->longdesc); } else { g_print ("%s: %s (%s)\n", plugin->desc.name, GST_PLUGIN_FEATURE_NAME (feature), @@ -734,7 +728,6 @@ print_plugin_info (GstPlugin * plugin) gint num_elements = 0; gint num_autoplug = 0; gint num_types = 0; - gint num_schedulers = 0; gint num_indexes = 0; gint num_other = 0; @@ -787,12 +780,6 @@ print_plugin_info (GstPlugin * plugin) } else g_print ("%s type: N/A\n", plugin->desc.name); num_types++; - } else if (GST_IS_SCHEDULER_FACTORY (feature)) { - GstSchedulerFactory *factory; - - factory = GST_SCHEDULER_FACTORY (feature); - g_print (" %s: %s\n", GST_OBJECT_NAME (factory), factory->longdesc); - num_schedulers++; } else { g_print (" %s (%s)\n", gst_object_get_name (GST_OBJECT (feature)), g_type_name (G_OBJECT_TYPE (feature))); @@ -808,8 +795,6 @@ print_plugin_info (GstPlugin * plugin) g_print (" +-- %d autopluggers\n", num_autoplug); if (num_types > 0) g_print (" +-- %d types\n", num_types); - if (num_schedulers > 0) - g_print (" +-- %d schedulers\n", num_schedulers); if (num_indexes > 0) g_print (" +-- %d indexes\n", num_indexes); if (num_other > 0) @@ -828,9 +813,6 @@ main (int argc, char *argv[]) struct poptOption options[] = { {"gst-inspect-plugin", 'p', POPT_ARG_STRING | POPT_ARGFLAG_STRIP, NULL, 0, "Show plugin details", NULL}, - {"gst-inspect-scheduler", 's', POPT_ARG_STRING | POPT_ARGFLAG_STRIP, NULL, - 0, - "Show scheduler details", NULL}, POPT_TABLEEND }; @@ -867,12 +849,6 @@ main (int argc, char *argv[]) GstPluginFeature *feature; /* FIXME implement other pretty print function for these */ - feature = gst_registry_pool_find_feature (argv[1], - GST_TYPE_SCHEDULER_FACTORY); - if (feature) { - g_print ("%s: a scheduler\n", argv[1]); - return 0; - } #ifndef GST_DISABLE_INDEX feature = gst_registry_pool_find_feature (argv[1], GST_TYPE_INDEX_FACTORY); |