From f3098e9546c3b4049512ce6d0636da8b100be387 Mon Sep 17 00:00:00 2001 From: Erik Walthinsen Date: Sat, 26 May 2001 22:58:15 +0000 Subject: [PATCH] fixed cothread locking and set_arg/get_arg safety, and switched to 64 cothreads of 32KB Original commit message from CVS: fixed cothread locking and set_arg/get_arg safety, and switched to 64 cothreads of 32KB --- gst/cothreads.c | 15 ++++++++++----- gst/gstelement.c | 14 +++++++++++++- gst/gstscheduler.c | 6 ++++-- 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/gst/cothreads.c b/gst/cothreads.c index 478dba0d35..855df5f148 100644 --- a/gst/cothreads.c +++ b/gst/cothreads.c @@ -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 } diff --git a/gst/gstelement.c b/gst/gstelement.c index d728d588a4..f7a16ff38d 100644 --- a/gst/gstelement.c +++ b/gst/gstelement.c @@ -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); } @@ -143,6 +144,17 @@ gst_element_class_init (GstElementClass *klass) klass->elementfactory = NULL; } +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) { diff --git a/gst/gstscheduler.c b/gst/gstscheduler.c index 0795c18cd0..44392d9847 100644 --- a/gst/gstscheduler.c +++ b/gst/gstscheduler.c @@ -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); }