fixed cothread locking and set_arg/get_arg safety, and switched to 64 cothreads of...
authorErik Walthinsen <omega@temple-baptist.org>
Sat, 26 May 2001 22:58:15 +0000 (22:58 +0000)
committerErik Walthinsen <omega@temple-baptist.org>
Sat, 26 May 2001 22:58:15 +0000 (22:58 +0000)
Original commit message from CVS:
fixed cothread locking and set_arg/get_arg safety, and switched to 64 cothreads of 32KB

gst/cothreads.c
gst/gstelement.c
gst/gstscheduler.c

index 478dba0..855df5f 100644 (file)
@@ -36,8 +36,8 @@
 #include "gstarch.h"
 
 
-#define COTHREAD_STACKSIZE 16384
-#define COTHREAD_MAXTHREADS 128
+#define COTHREAD_STACKSIZE 32768
+#define COTHREAD_MAXTHREADS 64
 #define STACK_SIZE 0x200000
 
 
@@ -385,7 +385,8 @@ cothread_lock (cothread_state *thread)
 #ifdef COTHREAD_ATOMIC
   // do something to lock the cothread
 #else
-  g_mutex_lock(thread->lock);
+  if (thread->lock)
+    g_mutex_lock(thread->lock);
 #endif
 }
 
@@ -395,7 +396,10 @@ cothread_trylock (cothread_state *thread)
 #ifdef COTHREAD_ATOMIC
   // do something to try to lock the cothread
 #else
-  return g_mutex_trylock(thread->lock);
+  if (thread->lock)
+    return g_mutex_trylock(thread->lock);
+  else
+    return FALSE;
 #endif
 }
 
@@ -405,7 +409,8 @@ cothread_unlock (cothread_state *thread)
 #ifdef COTHREAD_ATOMIC
   // do something to unlock the cothread
 #else
-  g_mutex_unlock(thread->lock);
+  if (thread->lock)
+    g_mutex_unlock(thread->lock);
 #endif
 }
 
index d728d58..f7a16ff 100644 (file)
@@ -49,6 +49,7 @@ enum {
 
 static void                    gst_element_class_init          (GstElementClass *klass);
 static void                    gst_element_init                (GstElement *element);
+static void                    gst_element_base_class_init     (GstElementClass *klass);
 
 static void                    gst_element_set_arg             (GtkObject *object, GtkArg *arg, guint id);
 static void                    gst_element_get_arg             (GtkObject *object, GtkArg *arg, guint id);
@@ -75,7 +76,7 @@ GtkType gst_element_get_type(void) {
       (GtkObjectInitFunc)gst_element_init,
       (GtkArgSetFunc)gst_element_set_arg,
       (GtkArgGetFunc)gst_element_get_arg,
-      (GtkClassInitFunc)NULL,
+      (GtkClassInitFunc)gst_element_base_class_init,
     };
     element_type = gtk_type_unique(GST_TYPE_OBJECT,&element_info);
   }
@@ -144,6 +145,17 @@ gst_element_class_init (GstElementClass *klass)
 }
 
 static void
+gst_element_base_class_init (GstElementClass *klass)
+{
+  GtkObjectClass *gtkobject_class;
+
+  gtkobject_class = (GtkObjectClass*) klass;
+
+  gtkobject_class->set_arg =           GST_DEBUG_FUNCPTR(gst_element_set_arg);
+  gtkobject_class->get_arg =           GST_DEBUG_FUNCPTR(gst_element_get_arg);
+}
+
+static void
 gst_element_init (GstElement *element)
 {
   element->current_state = GST_STATE_NULL;
index 0795c18..44392d9 100644 (file)
@@ -778,13 +778,15 @@ void gst_bin_schedule_func(GstBin *bin) {
 static void 
 gst_schedule_lock_element (GstSchedule *sched,GstElement *element)
 {
-  cothread_lock(element->threadstate);
+  if (element->threadstate)
+    cothread_lock(element->threadstate);
 }
 
 static void
 gst_schedule_unlock_element (GstSchedule *sched,GstElement *element)
 {
-  cothread_unlock(element->threadstate);
+  if (element->threadstate)
+    cothread_unlock(element->threadstate);
 }