- Removed unused locking from the cothreads
authorWim Taymans <wim.taymans@gmail.com>
Mon, 8 Jul 2002 19:07:30 +0000 (19:07 +0000)
committerWim Taymans <wim.taymans@gmail.com>
Mon, 8 Jul 2002 19:07:30 +0000 (19:07 +0000)
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.

39 files changed:
gst/autoplug/gstautoplugcache.c
gst/gst.h
gst/gstautoplug.c
gst/gstautoplug.h
gst/gstbin.c
gst/gstbin.h
gst/gstcaps.c
gst/gstcaps.h
gst/gstclock.h
gst/gstelement.h
gst/gstelementfactory.c
gst/gstextratypes.h
gst/gstobject.c
gst/gstobject.h
gst/gstparse.c
gst/gstparse.h
gst/gstpipeline.c
gst/gstpipeline.h
gst/gstplugin.c
gst/gstplugin.h
gst/gstpluginfeature.c
gst/gstpluginfeature.h
gst/gstprops.h
gst/gstregistry.c
gst/gstscheduler.c
gst/gstscheduler.h
gst/gstsystemclock.h
gst/gstthread.c
gst/gstthread.h
gst/gsttimecache.h
gst/gsttrace.h
gst/gsttype.c
gst/gsttype.h
gst/gsttypefind.c
gst/gsttypefind.h
gst/gsttypes.h
gst/gstutils.h
gst/gstxml.c
gst/gstxml.h

index 7601e02..482925e 100644 (file)
@@ -20,7 +20,6 @@
  */
 
 #include <gst/gst.h>
-#include "../cothreads.h"
 
 GstElementDetails gst_autoplugcache_details = {
   "AutoplugCache",
index 4e44429..f3c959e 100644 (file)
--- a/gst/gst.h
+++ b/gst/gst.h
@@ -58,9 +58,7 @@
 #include <gst/gstextratypes.h>
 #include <gst/gstenumtypes.h>
 
-#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 <gst/gstlog.h>
 
index e0439b2..dc314a9 100644 (file)
@@ -28,6 +28,7 @@
 
 #include "gstautoplug.h"
 #include "gstregistry.h"
+#include "gstlog.h"
 
 enum {
   NEW_OBJECT,
index c8a750b..4f40823 100644 (file)
@@ -28,9 +28,7 @@
 
 #include <gst/gstelement.h>
 
-#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 */
 
index dd4b187..2fdde6b 100644 (file)
@@ -27,6 +27,7 @@
 #include "gstevent.h"
 #include "gstbin.h"
 #include "gstxml.h"
+#include "gstlog.h"
 
 #include "gstscheduler.h"
 
index 7602092..d03d536 100644 (file)
@@ -26,9 +26,7 @@
 
 #include <gst/gstelement.h>
 
-#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__ */
index 8e1b214..94388f9 100644 (file)
@@ -25,6 +25,7 @@
 
 #include "gstcaps.h"
 #include "gsttype.h"
+#include "gstlog.h"
 
 static GMemChunk *_gst_caps_chunk;
 static GMutex *_gst_caps_chunk_lock;
index ad4ccb7..b3d4eb3 100644 (file)
 #ifndef __GST_CAPS_H__
 #define __GST_CAPS_H__
 
-#include <gst/gstconfig.h>
-
 #include <gst/gstprops.h>
 
-#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__ */
index e9fc321..c714de4 100644 (file)
 #ifndef __GST_CLOCK_H__
 #define __GST_CLOCK_H__
 
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
 #include <gst/gstobject.h>
 
+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__ */
index 509f616..44af35e 100644 (file)
@@ -25,7 +25,6 @@
 #define __GST_ELEMENT_H__
 
 #include <gst/gstconfig.h>
-
 #include <gst/gsttypes.h>
 #include <gst/gstobject.h>
 #include <gst/gstpad.h>
index 3871e39..eecc390 100644 (file)
@@ -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);
index eecd199..3d6956a 100644 (file)
 #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__ */
index b8e963e..cfbc5f3 100644 (file)
@@ -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
index 74a05c9..c5a3d04 100644 (file)
 #include <gst/gsttrace.h>
 #include <gst/gsttypes.h>
 
-/* 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__ */
 
index 835a0f1..cc753c8 100644 (file)
@@ -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;
index 807f001..a8569b5 100644 (file)
@@ -23,7 +23,7 @@
 #ifndef __GST_PARSE_H__
 #define __GST_PARSE_H__
 
-#include <gst/gstpipeline.h>
+#include <gst/gstbin.h>
 
 G_BEGIN_DECLS
 
index 5a57c91..972c712 100644 (file)
@@ -23,6 +23,7 @@
 #include "gst_private.h"
 
 #include "gstpipeline.h"
+#include "gstlog.h"
 #include "gstscheduler.h"
 
 GstElementDetails gst_pipeline_details = {
index 7539c04..3e15e01 100644 (file)
@@ -26,9 +26,7 @@
 
 #include <gst/gstbin.h>
 
-#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__ */
 
index 2ceac5f..041b351 100644 (file)
@@ -29,6 +29,7 @@
 #include "gstplugin.h"
 #include "gstversion.h"
 #include "gstregistry.h"
+#include "gstlog.h"
 #include "config.h"
 
 static GModule *main_module;
index d19fc21..130d9da 100644 (file)
 #include <gst/gstconfig.h>
 
 #include <gmodule.h>
-
 #include <gst/gstpluginfeature.h>
 
+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__ */
index ae29f0d..19e2895 100644 (file)
 #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
index e369a09..f1c1780 100644 (file)
 #ifndef __GST_PLUGIN_FEATURE_H__
 #define __GST_PLUGIN_FEATURE_H__
 
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+#include <glib-object.h>
 
-#include <gst/gstobject.h>
+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__ */
index 0387688..81d8d5c 100644 (file)
@@ -28,9 +28,7 @@
 
 #include <glib-object.h>
 
-#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__ */
index 7da950b..19a0e53 100644 (file)
@@ -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))
 
index bc3bc60..16f926e 100644 (file)
@@ -26,6 +26,7 @@
 
 #include "gstsystemclock.h"
 #include "gstscheduler.h"
+#include "gstlog.h"
 #include "gstregistry.h"
 
 static void    gst_scheduler_class_init        (GstSchedulerClass *klass);
index c694174..9492bfd 100644 (file)
 #include <gst/gstelement.h>
 #include <gst/gstbin.h>
 
-#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__ */
index f972e12..2bedb72 100644 (file)
@@ -26,9 +26,7 @@
 
 #include <gst/gstclock.h>
 
-#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__ */
index fdd4684..061fa0e 100644 (file)
@@ -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;
 }
 
index bb911e0..475e5e5 100644 (file)
@@ -30,9 +30,7 @@
 #include <gst/gstbin.h>
 
 
-#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__ */     
index ff150e6..330e57d 100644 (file)
 
 #include <gst/gstobject.h>
 
-
-#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__ */
index 2296384..d342e26 100644 (file)
@@ -28,6 +28,7 @@
 
 #include <glib.h>
 
+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__ */
index 7c6893b..f5dd2f7 100644 (file)
@@ -31,6 +31,8 @@
 
 #include "gsttype.h"
 #include "gstregistry.h"
+#include "gstobject.h"
+#include "gstlog.h"
 
 
 /* global list of registered types */
index 3080c03..f89dccd 100644 (file)
@@ -28,6 +28,7 @@
 #include <gst/gstcaps.h>
 #include <gst/gstpluginfeature.h>
 
+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__ */
index cd2101a..032e723 100644 (file)
@@ -25,6 +25,7 @@
 
 #include "gsttype.h"
 
+#include "gstlog.h"
 #include "gsttypefind.h"
 
 /* #define GST_DEBUG_ENABLED */
index b40842c..8c1d6d3 100644 (file)
 
 #include <gst/gstelement.h>
 
-
-#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 */
 
index 5595ab5..06e6b7b 100644 (file)
@@ -1,6 +1,29 @@
+/* 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 _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__ */
index 4b8a46c..373c0e8 100644 (file)
 #define __GST_UTILS_H__
 
 #include <glib.h>
-#include <gst/gstobject.h>
+#include <gst/gstelement.h>
 
-#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__ */
index adcf5a1..40e60cc 100644 (file)
@@ -23,6 +23,7 @@
 #include "gst_private.h"
 
 #include "gstxml.h"
+#include "gstlog.h"
 #include "gstbin.h"
 
 enum {
index e3f83b7..0ef2ded 100644 (file)
@@ -29,9 +29,7 @@
 
 #include <gst/gstelement.h>
 
-#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 */