From ae87d97cb2aa860493e6f5453174b2506e1d893f Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Mon, 8 Jul 2002 19:07:30 +0000 Subject: [PATCH] - Removed unused locking from the cothreads Original commit message from CVS: - Removed unused locking from the cothreads - use G_*_DECLS in .h files - remove gstlog.h include from gstobject.h, add to .c files - removed unused refcounting code from gstobject - small fixes in #includes - Added Scheduling policy and priority properties to gstthread so that SCHED_FIFO and SCHED_RR threads can be constructed. --- gst/autoplug/gstautoplugcache.c | 1 - gst/gst.h | 8 +--- gst/gstautoplug.c | 1 + gst/gstautoplug.h | 8 +--- gst/gstbin.c | 1 + gst/gstbin.h | 9 ++--- gst/gstcaps.c | 1 + gst/gstcaps.h | 10 +---- gst/gstclock.h | 10 ++--- gst/gstelement.h | 1 - gst/gstelementfactory.c | 1 + gst/gstextratypes.h | 9 +---- gst/gstobject.c | 84 +---------------------------------------- gst/gstobject.h | 20 ++-------- gst/gstparse.c | 1 + gst/gstparse.h | 2 +- gst/gstpipeline.c | 1 + gst/gstpipeline.h | 9 +---- gst/gstplugin.c | 1 + gst/gstplugin.h | 4 +- gst/gstpluginfeature.c | 3 +- gst/gstpluginfeature.h | 10 ++--- gst/gstprops.h | 8 +--- gst/gstregistry.c | 2 + gst/gstscheduler.c | 1 + gst/gstscheduler.h | 9 +---- gst/gstsystemclock.h | 9 +---- gst/gstthread.c | 73 ++++++++++++++++++++++++++++++++++- gst/gstthread.h | 35 ++++++++--------- gst/gsttimecache.h | 10 +---- gst/gsttrace.h | 3 ++ gst/gsttype.c | 2 + gst/gsttype.h | 3 ++ gst/gsttypefind.c | 1 + gst/gsttypefind.h | 9 +---- gst/gsttypes.h | 27 ++++++++++++- gst/gstutils.h | 10 ++--- gst/gstxml.c | 1 + gst/gstxml.h | 8 +--- 39 files changed, 180 insertions(+), 226 deletions(-) diff --git a/gst/autoplug/gstautoplugcache.c b/gst/autoplug/gstautoplugcache.c index 7601e02..482925e 100644 --- a/gst/autoplug/gstautoplugcache.c +++ b/gst/autoplug/gstautoplugcache.c @@ -20,7 +20,6 @@ */ #include -#include "../cothreads.h" GstElementDetails gst_autoplugcache_details = { "AutoplugCache", diff --git a/gst/gst.h b/gst/gst.h index 4e44429..f3c959e 100644 --- a/gst/gst.h +++ b/gst/gst.h @@ -58,9 +58,7 @@ #include #include -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ +G_BEGIN_DECLS /* initialize GST */ void gst_init (int *argc, char **argv[]); @@ -74,9 +72,7 @@ gboolean gst_has_threads (void); void gst_main (void); void gst_main_quit (void); -#ifdef __cplusplus -} -#endif /* __cplusplus */ +G_END_DECLS #include diff --git a/gst/gstautoplug.c b/gst/gstautoplug.c index e0439b2..dc314a9 100644 --- a/gst/gstautoplug.c +++ b/gst/gstautoplug.c @@ -28,6 +28,7 @@ #include "gstautoplug.h" #include "gstregistry.h" +#include "gstlog.h" enum { NEW_OBJECT, diff --git a/gst/gstautoplug.h b/gst/gstautoplug.h index c8a750b..4f40823 100644 --- a/gst/gstautoplug.h +++ b/gst/gstautoplug.h @@ -28,9 +28,7 @@ #include -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ +G_BEGIN_DECLS #define GST_TYPE_AUTOPLUG \ (gst_autoplug_get_type()) @@ -118,9 +116,7 @@ GstAutoplugFactory* gst_autoplug_factory_find (const gchar *name); GstAutoplug* gst_autoplug_factory_create (GstAutoplugFactory *factory); GstAutoplug* gst_autoplug_factory_make (const gchar *name); -#ifdef __cplusplus -} -#endif /* __cplusplus */ +G_END_DECLS #else /* GST_DISABLE_AUTOPLUG */ diff --git a/gst/gstbin.c b/gst/gstbin.c index dd4b187..2fdde6b 100644 --- a/gst/gstbin.c +++ b/gst/gstbin.c @@ -27,6 +27,7 @@ #include "gstevent.h" #include "gstbin.h" #include "gstxml.h" +#include "gstlog.h" #include "gstscheduler.h" diff --git a/gst/gstbin.h b/gst/gstbin.h index 7602092..d03d536 100644 --- a/gst/gstbin.h +++ b/gst/gstbin.h @@ -26,9 +26,7 @@ #include -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ +G_BEGIN_DECLS extern GstElementDetails gst_bin_details; extern GType _gst_bin_type; @@ -133,9 +131,8 @@ void gst_bin_child_state_change (GstBin *bin, GstElementState oldstate, void gst_bin_set_pre_iterate_function (GstBin *bin, GstBinPrePostIterateFunction func, gpointer func_data); void gst_bin_set_post_iterate_function (GstBin *bin, GstBinPrePostIterateFunction func, gpointer func_data); -#ifdef __cplusplus -} -#endif /* __cplusplus */ + +G_END_DECLS #endif /* __GST_BIN_H__ */ diff --git a/gst/gstcaps.c b/gst/gstcaps.c index 8e1b214..94388f9 100644 --- a/gst/gstcaps.c +++ b/gst/gstcaps.c @@ -25,6 +25,7 @@ #include "gstcaps.h" #include "gsttype.h" +#include "gstlog.h" static GMemChunk *_gst_caps_chunk; static GMutex *_gst_caps_chunk_lock; diff --git a/gst/gstcaps.h b/gst/gstcaps.h index ad4ccb7..b3d4eb3 100644 --- a/gst/gstcaps.h +++ b/gst/gstcaps.h @@ -24,13 +24,9 @@ #ifndef __GST_CAPS_H__ #define __GST_CAPS_H__ -#include - #include -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ +G_BEGIN_DECLS typedef struct _GstCaps GstCaps; @@ -140,8 +136,6 @@ xmlNodePtr gst_caps_save_thyself (GstCaps *caps, xmlNodePtr parent); GstCaps* gst_caps_load_thyself (xmlNodePtr parent); #endif -#ifdef __cplusplus -} -#endif /* __cplusplus */ +G_END_DECLS #endif /* __GST_CAPS_H__ */ diff --git a/gst/gstclock.h b/gst/gstclock.h index e9fc321..c714de4 100644 --- a/gst/gstclock.h +++ b/gst/gstclock.h @@ -24,12 +24,10 @@ #ifndef __GST_CLOCK_H__ #define __GST_CLOCK_H__ -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - #include +G_BEGIN_DECLS + #define GST_TYPE_CLOCK \ (gst_clock_get_type()) #define GST_CLOCK(obj) \ @@ -130,8 +128,6 @@ GstClockTime gst_clock_id_get_time (GstClockID id); void gst_clock_set_resolution (GstClock *clock, guint64 resolution); guint64 gst_clock_get_resolution (GstClock *clock); -#ifdef __cplusplus -} -#endif /* __cplusplus */ +G_END_DECLS #endif /* __GST_CLOCK_H__ */ diff --git a/gst/gstelement.h b/gst/gstelement.h index 509f616..44af35e 100644 --- a/gst/gstelement.h +++ b/gst/gstelement.h @@ -25,7 +25,6 @@ #define __GST_ELEMENT_H__ #include - #include #include #include diff --git a/gst/gstelementfactory.c b/gst/gstelementfactory.c index 3871e39..eecc390 100644 --- a/gst/gstelementfactory.c +++ b/gst/gstelementfactory.c @@ -25,6 +25,7 @@ #include "gstelement.h" #include "gstregistry.h" +#include "gstlog.h" static void gst_element_factory_class_init (GstElementFactoryClass *klass); static void gst_element_factory_init (GstElementFactory *factory); diff --git a/gst/gstextratypes.h b/gst/gstextratypes.h index eecd199..3d6956a 100644 --- a/gst/gstextratypes.h +++ b/gst/gstextratypes.h @@ -24,18 +24,13 @@ #ifndef __GST_EXTRA_TYPES_H__ #define __GST_EXTRA_TYPES_H__ -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - +G_BEGIN_DECLS #define GST_TYPE_FILENAME (gst_extra_get_filename_type()) GType gst_extra_get_filename_type(void); -#ifdef __cplusplus -} -#endif /* __cplusplus */ +G_END_DECLS #endif /* __GST_EXTRA_TYPES_H__ */ diff --git a/gst/gstobject.c b/gst/gstobject.c index b8e963e..cfbc5f3 100644 --- a/gst/gstobject.c +++ b/gst/gstobject.c @@ -23,6 +23,7 @@ #include "gst_private.h" #include "gstobject.h" +#include "gstlog.h" /* Object signals and args */ enum { @@ -165,7 +166,6 @@ gst_object_ref (GstObject *object) g_object_ref (G_OBJECT (object)); return object; } -#define gst_object_ref gst_object_ref /** * gst_object_unref: @@ -184,7 +184,6 @@ gst_object_unref (GstObject *object) g_object_unref (G_OBJECT (object)); } -#define gst_object_unref gst_object_unref /** * gst_object_sink: @@ -396,87 +395,6 @@ gst_object_unparent (GstObject *object) } /** - * gst_object_ref: - * @object: GstObject to reference - * - * Increments the refence count on the object. - * - * Returns: Apointer to the Object - */ -#ifndef gst_object_ref -GstObject* -gst_object_ref (GstObject *object) -{ - g_return_if_fail (object != NULL, NULL); - g_return_if_fail (GST_IS_OBJECT (object), NULL); - -/* #ifdef HAVE_ATOMIC_H */ -/* g_return_if_fail (atomic_read (&(object->refcount)) > 0); */ -/* atomic_inc (&(object->refcount)) */ -/* #else */ - g_return_if_fail (object->refcount > 0); - GST_LOCK (object); -/* object->refcount++; */ - g_object_ref((GObject *)object); - GST_UNLOCK (object); -/* #endif */ - - return object; -} -#endif /* gst_object_ref */ - -/** - * gst_object_unref: - * @object: GstObject to unreference - * - * Decrements the refence count on the object. If reference count hits - * zero, destroy the object. - */ -#ifndef gst_object_unref -void -gst_object_unref (GstObject *object) -{ - int reftest; - - g_return_if_fail (object != NULL); - g_return_if_fail (GST_IS_OBJECT (object)); - -#ifdef HAVE_ATOMIC_H - g_return_if_fail (atomic_read (&(object->refcount)) > 0); - reftest = atomic_dec_and_test (&(object->refcount)) -#else - g_return_if_fail (object->refcount > 0); - GST_LOCK (object); - object->refcount--; - reftest = (object->refcount == 0); - GST_UNLOCK (object); -#endif - - /* if we ended up with the refcount at zero */ - if (reftest) { - /* get the count to 1 for gtk_object_destroy() */ -#ifdef HAVE_ATOMIC_H - atomic_set (&(object->refcount),1); -#else - object->refcount = 1; -#endif - /* destroy it */ - gtk_object_destroy (G_OBJECT (object)); - /* drop the refcount back to zero */ -#ifdef HAVE_ATOMIC_H - atomic_set (&(object->refcount),0); -#else - object->refcount = 0; -#endif - /* finalize the object */ - /* FIXME this is an evil hack that should be killed */ -/* FIXMEFIXMEFIXMEFIXME */ -/* gtk_object_finalize(G_OBJECT(object)); */ - } -} -#endif /* gst_object_unref */ - -/** * gst_object_check_uniqueness: * @list: a list of #GstObject to check through * @name: the name to search for diff --git a/gst/gstobject.h b/gst/gstobject.h index 74a05c9..c5a3d04 100644 --- a/gst/gstobject.h +++ b/gst/gstobject.h @@ -36,12 +36,7 @@ #include #include -/* FIXME */ -#include "gstlog.h" - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ +G_BEGIN_DECLS extern GType _gst_object_type; @@ -75,14 +70,8 @@ struct _GstObject { GObject object; gchar *name; - /* have to have a refcount for the object */ -#ifdef HAVE_ATOMIC_H - atomic_t refcount; -#else - gint refcount; -#endif - /* locking for all sorts of things (like the refcount) */ + /* locking for all sorts of things */ GMutex *lock; /* this object's parent */ GstObject *parent; @@ -176,10 +165,7 @@ void gst_class_signal_emit_by_name (GstObject *object, #endif -#ifdef __cplusplus -} -#endif /* __cplusplus */ - +G_END_DECLS #endif /* __GST_OBJECT_H__ */ diff --git a/gst/gstparse.c b/gst/gstparse.c index 835a0f1..cc753c8 100644 --- a/gst/gstparse.c +++ b/gst/gstparse.c @@ -25,6 +25,7 @@ #include "gstparse.h" #include "gstinfo.h" +#include "gstlog.h" #include "parse/types.h" typedef struct _gst_parse_delayed_pad gst_parse_delayed_pad; diff --git a/gst/gstparse.h b/gst/gstparse.h index 807f001..a8569b5 100644 --- a/gst/gstparse.h +++ b/gst/gstparse.h @@ -23,7 +23,7 @@ #ifndef __GST_PARSE_H__ #define __GST_PARSE_H__ -#include +#include G_BEGIN_DECLS diff --git a/gst/gstpipeline.c b/gst/gstpipeline.c index 5a57c91..972c712 100644 --- a/gst/gstpipeline.c +++ b/gst/gstpipeline.c @@ -23,6 +23,7 @@ #include "gst_private.h" #include "gstpipeline.h" +#include "gstlog.h" #include "gstscheduler.h" GstElementDetails gst_pipeline_details = { diff --git a/gst/gstpipeline.h b/gst/gstpipeline.h index 7539c04..3e15e01 100644 --- a/gst/gstpipeline.h +++ b/gst/gstpipeline.h @@ -26,9 +26,7 @@ #include -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ +G_BEGIN_DECLS extern GstElementDetails gst_pipeline_details; @@ -59,10 +57,7 @@ GstElement* gst_pipeline_new (const gchar *name); #define gst_pipeline_destroy(pipeline) gst_object_destroy(GST_OBJECT(pipeline)) -#ifdef __cplusplus -} -#endif /* __cplusplus */ - +G_END_DECLS #endif /* __GST_PIPELINE_H__ */ diff --git a/gst/gstplugin.c b/gst/gstplugin.c index 2ceac5f..041b351 100644 --- a/gst/gstplugin.c +++ b/gst/gstplugin.c @@ -29,6 +29,7 @@ #include "gstplugin.h" #include "gstversion.h" #include "gstregistry.h" +#include "gstlog.h" #include "config.h" static GModule *main_module; diff --git a/gst/gstplugin.h b/gst/gstplugin.h index d19fc21..130d9da 100644 --- a/gst/gstplugin.h +++ b/gst/gstplugin.h @@ -27,9 +27,10 @@ #include #include - #include +G_BEGIN_DECLS + GQuark gst_plugin_error_quark (void); #define GST_PLUGIN_ERROR gst_plugin_error_quark () @@ -119,5 +120,6 @@ void gst_plugin_add_feature (GstPlugin *plugin, GstPluginFeature *feature); gboolean gst_plugin_load (const gchar *name); gboolean gst_library_load (const gchar *name); +G_END_DECLS #endif /* __GST_PLUGIN_H__ */ diff --git a/gst/gstpluginfeature.c b/gst/gstpluginfeature.c index ae29f0d..19e2895 100644 --- a/gst/gstpluginfeature.c +++ b/gst/gstpluginfeature.c @@ -24,11 +24,12 @@ #include "gstpluginfeature.h" #include "gstplugin.h" #include "gstregistry.h" +#include "gstlog.h" static void gst_plugin_feature_class_init (GstPluginFeatureClass *klass); static void gst_plugin_feature_init (GstPluginFeature *feature); -static GstObjectClass *parent_class = NULL; +static GObjectClass *parent_class = NULL; /* static guint gst_plugin_feature_signals[LAST_SIGNAL] = { 0 }; */ GType diff --git a/gst/gstpluginfeature.h b/gst/gstpluginfeature.h index e369a09..f1c1780 100644 --- a/gst/gstpluginfeature.h +++ b/gst/gstpluginfeature.h @@ -24,11 +24,9 @@ #ifndef __GST_PLUGIN_FEATURE_H__ #define __GST_PLUGIN_FEATURE_H__ -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ +#include -#include +G_BEGIN_DECLS #define GST_TYPE_PLUGIN_FEATURE \ (gst_plugin_feature_get_type()) @@ -67,9 +65,7 @@ GType gst_plugin_feature_get_type (void); gboolean gst_plugin_feature_ensure_loaded (GstPluginFeature *feature); void gst_plugin_feature_unload_thyself (GstPluginFeature *feature); -#ifdef __cplusplus -} -#endif /* __cplusplus */ +G_END_DECLS #endif /* __GST_PLUGIN_FEATURE_H__ */ diff --git a/gst/gstprops.h b/gst/gstprops.h index 0387688..81d8d5c 100644 --- a/gst/gstprops.h +++ b/gst/gstprops.h @@ -28,9 +28,7 @@ #include -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ +G_BEGIN_DECLS typedef struct _GstProps GstProps; extern GType _gst_props_type; @@ -140,8 +138,6 @@ GstProps* gst_props_load_thyself (xmlNodePtr parent); #endif -#ifdef __cplusplus -} -#endif /* __cplusplus */ +G_END_DECLS #endif /* __GST_PROPS_H__ */ diff --git a/gst/gstregistry.c b/gst/gstregistry.c index 7da950b..19a0e53 100644 --- a/gst/gstregistry.c +++ b/gst/gstregistry.c @@ -30,6 +30,8 @@ #include "gstinfo.h" #include "gstregistry.h" +#include "gstlog.h" +#include "gstmarshal.h" #define CLASS(registry) GST_REGISTRY_CLASS (G_OBJECT_GET_CLASS (registry)) diff --git a/gst/gstscheduler.c b/gst/gstscheduler.c index bc3bc60..16f926e 100644 --- a/gst/gstscheduler.c +++ b/gst/gstscheduler.c @@ -26,6 +26,7 @@ #include "gstsystemclock.h" #include "gstscheduler.h" +#include "gstlog.h" #include "gstregistry.h" static void gst_scheduler_class_init (GstSchedulerClass *klass); diff --git a/gst/gstscheduler.h b/gst/gstscheduler.h index c694174..9492bfd 100644 --- a/gst/gstscheduler.h +++ b/gst/gstscheduler.h @@ -28,10 +28,7 @@ #include #include -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - +G_BEGIN_DECLS #define GST_TYPE_SCHEDULER \ (gst_scheduler_get_type()) @@ -184,8 +181,6 @@ void gst_scheduler_factory_set_default_name (const gchar* name); const gchar* gst_scheduler_factory_get_default_name (void); -#ifdef __cplusplus -} -#endif /* __cplusplus */ +G_END_DECLS #endif /* __GST_SCHEDULER_H__ */ diff --git a/gst/gstsystemclock.h b/gst/gstsystemclock.h index f972e12..2bedb72 100644 --- a/gst/gstsystemclock.h +++ b/gst/gstsystemclock.h @@ -26,9 +26,7 @@ #include -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ +G_BEGIN_DECLS #define GST_TYPE_SYSTEM_CLOCK \ (gst_system_clock_get_type()) @@ -57,9 +55,6 @@ GType gst_system_clock_get_type (void); GstClock* gst_system_clock_obtain (void); -#ifdef __cplusplus -} -#endif /* __cplusplus */ - +G_END_DECLS #endif /* __GST_SYSTEM_CLOCK_H__ */ diff --git a/gst/gstthread.c b/gst/gstthread.c index fdd4684..061fa0e 100644 --- a/gst/gstthread.c +++ b/gst/gstthread.c @@ -42,6 +42,7 @@ GstElementDetails gst_thread_details = { /* Thread signals and args */ enum { + SHUTDOWN, /* FILL ME */ LAST_SIGNAL }; @@ -54,6 +55,8 @@ enum { enum { ARG_0, + ARG_SCHEDPOLICY, + ARG_PRIORITY, }; @@ -75,8 +78,24 @@ static void gst_thread_restore_thyself (GstObject *object, xmlNodePtr self); static void* gst_thread_main_loop (void *arg); +#define GST_TYPE_THREAD_SCHEDPOLICY (gst_thread_schedpolicy_get_type()) +static GType +gst_thread_schedpolicy_get_type(void) { + static GType thread_schedpolicy_type = 0; + static GEnumValue thread_schedpolicy[] = { + {SCHED_OTHER, "SCHED_OTHER", "Normal Scheduling"}, + {SCHED_FIFO, "SCHED_FIFO", "FIFO Scheduling (requires root)"}, + {SCHED_RR, "SCHED_RR", "Round-Robin Scheduling (requires root)"}, + {0, NULL, NULL}, + }; + if (!thread_schedpolicy_type) { + thread_schedpolicy_type = g_enum_register_static("GstThreadSchedPolicy", thread_schedpolicy); + } + return thread_schedpolicy_type; +} + static GstBinClass *parent_class = NULL; -/* static guint gst_thread_signals[LAST_SIGNAL] = { 0 }; */ +static guint gst_thread_signals[LAST_SIGNAL] = { 0 }; GType gst_thread_get_type(void) { @@ -115,6 +134,18 @@ gst_thread_class_init (GstThreadClass *klass) parent_class = g_type_class_ref (GST_TYPE_BIN); + g_object_class_install_property(G_OBJECT_CLASS (klass), ARG_SCHEDPOLICY, + g_param_spec_enum("schedpolicy", "Scheduling Policy", "The scheduling policy of the thread", + GST_TYPE_THREAD_SCHEDPOLICY, SCHED_OTHER, G_PARAM_READWRITE)); + g_object_class_install_property(G_OBJECT_CLASS (klass), ARG_PRIORITY, + g_param_spec_int("priority", "Scheduling Priority", "The scheduling priority of the thread", + 0, 99, 0, G_PARAM_READWRITE)); + + gst_thread_signals[SHUTDOWN] = + g_signal_new ("shutdown", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (GstThreadClass, shutdown), NULL, NULL, + gst_marshal_VOID__VOID, G_TYPE_NONE, 0); + gobject_class->dispose = gst_thread_dispose; #ifndef GST_DISABLE_LOADSAVE @@ -148,6 +179,8 @@ gst_thread_init (GstThread *thread) thread->ppid = getpid (); thread->thread_id = -1; + thread->sched_policy = SCHED_OTHER; + thread->priority = 0; } static void @@ -170,10 +203,20 @@ gst_thread_dispose (GObject *object) static void gst_thread_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { + GstThread *thread; + /* it's not null if we got it, but it might not be ours */ g_return_if_fail (GST_IS_THREAD (object)); + thread = GST_THREAD (object); + switch (prop_id) { + case ARG_SCHEDPOLICY: + thread->sched_policy = g_value_get_enum (value); + break; + case ARG_PRIORITY: + thread->priority = g_value_get_int (value); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -183,10 +226,20 @@ gst_thread_set_property (GObject *object, guint prop_id, const GValue *value, GP static void gst_thread_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { + GstThread *thread; + /* it's not null if we got it, but it might not be ours */ g_return_if_fail (GST_IS_THREAD (object)); + thread = GST_THREAD (object); + switch (prop_id) { + case ARG_SCHEDPOLICY: + g_value_set_enum (value, thread->sched_policy); + break; + case ARG_PRIORITY: + g_value_set_int (value, thread->priority); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -275,6 +328,7 @@ gst_thread_change_state (GstElement * element) if (pthread_attr_init (&thread->attr) != 0) g_warning ("pthread_attr_init returned an error !"); + if (gst_scheduler_get_preferred_stack (GST_ELEMENT_SCHED (element), &thread->stack, &stacksize)) { if (pthread_attr_setstack (&thread->attr, thread->stack, stacksize) != 0) { g_warning ("pthread_attr_setstack failed"); @@ -465,6 +519,20 @@ gst_thread_main_loop (void *arg) thread = GST_THREAD (arg); g_mutex_lock (thread->lock); + if (thread->sched_policy != SCHED_OTHER) { + struct sched_param sched_param; + + memset (&sched_param, 0, sizeof (sched_param)); + if (thread->priority == 0) { + thread->priority = sched_get_priority_max (thread->sched_policy); + } + sched_param.sched_priority = thread->priority; + + if (sched_setscheduler (0, thread->sched_policy, &sched_param) != 0) { + GST_DEBUG (GST_CAT_THREAD, "not running with real-time priority"); + } + } + gst_scheduler_setup (GST_ELEMENT_SCHED (thread)); GST_FLAG_UNSET (thread, GST_THREAD_STATE_REAPING); @@ -600,6 +668,9 @@ gst_thread_main_loop (void *arg) GST_INFO (GST_CAT_THREAD, "gstthread: thread \"%s\" is stopped", GST_ELEMENT_NAME (thread)); + + g_signal_emit (G_OBJECT (thread), gst_thread_signals[SHUTDOWN], 0); + return NULL; } diff --git a/gst/gstthread.h b/gst/gstthread.h index bb911e0..475e5e5 100644 --- a/gst/gstthread.h +++ b/gst/gstthread.h @@ -30,9 +30,7 @@ #include -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ +G_BEGIN_DECLS extern GstElementDetails gst_thread_details; @@ -62,30 +60,33 @@ typedef struct _GstThread GstThread; typedef struct _GstThreadClass GstThreadClass; struct _GstThread { - GstBin bin; - - pthread_t thread_id; /* id of the thread, if any */ - pthread_attr_t attr; /* attributes for the stack space */ - void *stack; /* set with gst_scheduler_get_preferred_stack */ - gint pid; /* the pid of the thread */ - gint ppid; /* the pid of the thread's parent process */ - GMutex *lock; /* thread lock/condititon pair ... */ - GCond *cond; /* .... used to control the thread */ - - gint transition; /* the current state transition */ + GstBin bin; + + pthread_t thread_id; /* id of the thread, if any */ + pthread_attr_t attr; /* attributes for the stack space */ + int sched_policy; + int priority; + void *stack; /* set with gst_scheduler_get_preferred_stack */ + gint pid; /* the pid of the thread */ + gint ppid; /* the pid of the thread's parent process */ + GMutex *lock; /* thread lock/condititon pair ... */ + GCond *cond; /* .... used to control the thread */ + + gint transition; /* the current state transition */ }; struct _GstThreadClass { GstBinClass parent_class; + + /* signals */ + void (*shutdown) (GstThread *thread); }; GType gst_thread_get_type (void); GstElement* gst_thread_new (const gchar *name); -#ifdef __cplusplus -} -#endif /* __cplusplus */ +G_END_DECLS #endif /* __GST_THREAD_H__ */ diff --git a/gst/gsttimecache.h b/gst/gsttimecache.h index ff150e6..330e57d 100644 --- a/gst/gsttimecache.h +++ b/gst/gsttimecache.h @@ -25,11 +25,7 @@ #include - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - +G_BEGIN_DECLS #define GST_TYPE_TIME_CACHE (gst_time_cache_get_type ()) #define GST_TIME_CACHE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_TIME_CACHE, GstTimeCache)) @@ -100,9 +96,7 @@ void gst_time_cache_add_entry (GstTimeCache *tc, guint64 location, gint64 time gboolean gst_time_cache_find_location (GstTimeCache *tc, guint64 location, gint64 *timestamp); gboolean gst_time_cache_find_timestamp (GstTimeCache *tc, gint64 timestamp, guint64 *location); -#ifdef __cplusplus -} -#endif /* __cplusplus */ +G_END_DECLS #endif /* __GST_TIME_CACHE_H__ */ diff --git a/gst/gsttrace.h b/gst/gsttrace.h index 2296384..d342e26 100644 --- a/gst/gsttrace.h +++ b/gst/gsttrace.h @@ -28,6 +28,7 @@ #include +G_BEGIN_DECLS typedef struct _GstTrace GstTrace; typedef struct _GstTraceEntry GstTraceEntry; @@ -93,4 +94,6 @@ extern gint _gst_trace_on; #endif /* GST_DISABLE_TRACE */ +G_END_DECLS + #endif /* __GST_TRACE_H__ */ diff --git a/gst/gsttype.c b/gst/gsttype.c index 7c6893b..f5dd2f7 100644 --- a/gst/gsttype.c +++ b/gst/gsttype.c @@ -31,6 +31,8 @@ #include "gsttype.h" #include "gstregistry.h" +#include "gstobject.h" +#include "gstlog.h" /* global list of registered types */ diff --git a/gst/gsttype.h b/gst/gsttype.h index 3080c03..f89dccd 100644 --- a/gst/gsttype.h +++ b/gst/gsttype.h @@ -28,6 +28,7 @@ #include #include +G_BEGIN_DECLS /* type of function used to check a stream for equality with type */ typedef GstCaps *(*GstTypeFindFunc) (GstBuffer *buf, gpointer priv); @@ -97,4 +98,6 @@ GstType* gst_type_find_by_id (guint16 id); /* get the list of registered types (returns list of GstType!) */ const GList* gst_type_get_list (void); +G_END_DECLS + #endif /* __GST_TYPE_H__ */ diff --git a/gst/gsttypefind.c b/gst/gsttypefind.c index cd2101a..032e723 100644 --- a/gst/gsttypefind.c +++ b/gst/gsttypefind.c @@ -25,6 +25,7 @@ #include "gsttype.h" +#include "gstlog.h" #include "gsttypefind.h" /* #define GST_DEBUG_ENABLED */ diff --git a/gst/gsttypefind.h b/gst/gsttypefind.h index b40842c..8c1d6d3 100644 --- a/gst/gsttypefind.h +++ b/gst/gsttypefind.h @@ -28,10 +28,7 @@ #include - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ +G_BEGIN_DECLS extern GstElementDetails gst_type_find_details; @@ -67,9 +64,7 @@ struct _GstTypeFindClass { GType gst_type_find_get_type (void); -#ifdef __cplusplus -} -#endif /* __cplusplus */ +G_END_DECLS #endif /* GST_DISABLE_TYPE_FIND */ diff --git a/gst/gsttypes.h b/gst/gsttypes.h index 5595ab5..06e6b7b 100644 --- a/gst/gsttypes.h +++ b/gst/gsttypes.h @@ -1,6 +1,29 @@ +/* GStreamer + * Copyright (C) <1999> Erik Walthinsen + * + * 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 + +G_BEGIN_DECLS + typedef struct _GstObject GstObject; typedef struct _GstObjectClass GstObjectClass; typedef struct _GstPad GstPad; @@ -35,4 +58,6 @@ typedef enum { GST_RESULT_NOT_IMPL, } GstResult; -#endif +G_END_DECLS + +#endif /* __GST_TYPES_H__ */ diff --git a/gst/gstutils.h b/gst/gstutils.h index 4b8a46c..373c0e8 100644 --- a/gst/gstutils.h +++ b/gst/gstutils.h @@ -25,11 +25,9 @@ #define __GST_UTILS_H__ #include -#include +#include -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ +G_BEGIN_DECLS gboolean gst_util_has_arg (GObject *object, const gchar *argname, GType arg_type); @@ -50,8 +48,6 @@ void gst_util_dump_mem (guchar *mem, guint size); void gst_print_pad_caps (GString *buf, gint indent, GstPad *pad); void gst_print_element_args (GString *buf, gint indent, GstElement *element); -#ifdef __cplusplus -} -#endif /* __cplusplus */ +G_END_DECLS #endif /* __GST_UTILS_H__ */ diff --git a/gst/gstxml.c b/gst/gstxml.c index adcf5a1..40e60cc 100644 --- a/gst/gstxml.c +++ b/gst/gstxml.c @@ -23,6 +23,7 @@ #include "gst_private.h" #include "gstxml.h" +#include "gstlog.h" #include "gstbin.h" enum { diff --git a/gst/gstxml.h b/gst/gstxml.h index e3f83b7..0ef2ded 100644 --- a/gst/gstxml.h +++ b/gst/gstxml.h @@ -29,9 +29,7 @@ #include -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ +G_BEGIN_DECLS #define GST_TYPE_XML \ (gst_xml_get_type()) @@ -84,9 +82,7 @@ GList* gst_xml_get_topelements (GstXML *xml); GstElement* gst_xml_make_element (xmlNodePtr cur, GstObject *parent); -#ifdef __cplusplus -} -#endif /* __cplusplus */ +G_END_DECLS #else /* GST_DISABLE_LOADSAVE */ -- 2.7.4