From 6ae2ad5edbe111ae0d84cdf7bcf107ecc1a66e02 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Sun, 7 Jan 2001 03:42:27 +0000 Subject: [PATCH] Added sleep time to identity Original commit message from CVS: Added sleep time to identity Added timeout value in queue (not activated yet) --- gst/elements/gstidentity.c | 14 ++++++++++++++ gst/elements/gstidentity.h | 2 ++ gst/elements/gstqueue.c | 12 ++++++++++-- gst/elements/gstqueue.h | 1 + plugins/elements/gstidentity.c | 14 ++++++++++++++ plugins/elements/gstidentity.h | 2 ++ plugins/elements/gstqueue.c | 12 ++++++++++-- plugins/elements/gstqueue.h | 1 + 8 files changed, 54 insertions(+), 4 deletions(-) diff --git a/gst/elements/gstidentity.c b/gst/elements/gstidentity.c index 740d135..b64f584 100644 --- a/gst/elements/gstidentity.c +++ b/gst/elements/gstidentity.c @@ -43,6 +43,7 @@ enum { enum { ARG_0, ARG_LOOP_BASED, + ARG_SLEEP_TIME, }; @@ -89,6 +90,8 @@ gst_identity_class_init (GstIdentityClass *klass) gtk_object_add_arg_type ("GstIdentity::loop_based", GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_LOOP_BASED); + gtk_object_add_arg_type ("GstIdentity::sleep_time", GTK_TYPE_UINT, + GTK_ARG_READWRITE, ARG_SLEEP_TIME); gtkobject_class->set_arg = gst_identity_set_arg; gtkobject_class->get_arg = gst_identity_get_arg; @@ -105,6 +108,7 @@ gst_identity_init (GstIdentity *identity) gst_element_add_pad (GST_ELEMENT (identity), identity->srcpad); identity->loop_based = FALSE; + identity->sleep_time = 10000; } static void @@ -120,6 +124,8 @@ gst_identity_chain (GstPad *pad, GstBuffer *buf) g_print("(%s:%s)i ",GST_DEBUG_PAD_NAME(pad)); gst_pad_push (identity->srcpad, buf); + + usleep (identity->sleep_time); } static void @@ -139,6 +145,8 @@ gst_identity_loop (GstElement *element) gst_pad_push (identity->srcpad, buf); + usleep (identity->sleep_time); + } while (!GST_ELEMENT_IS_COTHREAD_STOPPING(element)); } @@ -164,6 +172,9 @@ gst_identity_set_arg (GtkObject *object, GtkArg *arg, guint id) gst_element_set_loop_function (GST_ELEMENT (identity), NULL); } break; + case ARG_SLEEP_TIME: + identity->sleep_time = GTK_VALUE_UINT (*arg); + break; default: break; } @@ -181,6 +192,9 @@ static void gst_identity_get_arg(GtkObject *object,GtkArg *arg,guint id) { case ARG_LOOP_BASED: GTK_VALUE_BOOL (*arg) = identity->loop_based; break; + case ARG_SLEEP_TIME: + GTK_VALUE_UINT (*arg) = identity->sleep_time; + break; default: arg->type = GTK_TYPE_INVALID; break; diff --git a/gst/elements/gstidentity.h b/gst/elements/gstidentity.h index e2585f9..3c53648 100644 --- a/gst/elements/gstidentity.h +++ b/gst/elements/gstidentity.h @@ -58,6 +58,8 @@ struct _GstIdentity { GstPad *srcpad; gboolean loop_based; + + guint sleep_time; }; struct _GstIdentityClass { diff --git a/gst/elements/gstqueue.c b/gst/elements/gstqueue.c index 5b16408..e8ac887 100644 --- a/gst/elements/gstqueue.c +++ b/gst/elements/gstqueue.c @@ -53,6 +53,7 @@ enum { ARG_LEVEL, ARG_MAX_LEVEL, ARG_BLOCK, + ARG_TIMEOUT, }; @@ -110,6 +111,8 @@ gst_queue_class_init (GstQueueClass *klass) GTK_ARG_READWRITE, ARG_MAX_LEVEL); gtk_object_add_arg_type ("GstQueue::block", GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_BLOCK); + gtk_object_add_arg_type ("GstQueue::timeout", GTK_TYPE_INT, + GTK_ARG_READWRITE, ARG_TIMEOUT); gtkobject_class->set_arg = gst_queue_set_arg; gtkobject_class->get_arg = gst_queue_get_arg; @@ -163,6 +166,7 @@ gst_queue_flush (GstQueue *queue) queue->queue = NULL; queue->level_buffers = 0; + queue->timeval = NULL; } static void @@ -197,7 +201,7 @@ gst_queue_chain (GstPad *pad, GstBuffer *buf) STATUS("%s: O\n"); g_mutex_lock (queue->fulllock); GST_UNLOCK (queue); - g_cond_wait (queue->fullcond, queue->fulllock); + g_cond_timed_wait (queue->fullcond, queue->fulllock, queue->timeval); GST_LOCK (queue); g_mutex_unlock (queue->fulllock); STATUS("%s: O+\n"); @@ -253,7 +257,7 @@ gst_queue_get (GstPad *pad) STATUS("queue: %s U released lock\n"); GST_UNLOCK (queue); g_mutex_lock (queue->emptylock); - g_cond_wait (queue->emptycond, queue->emptylock); + g_cond_timed_wait (queue->emptycond, queue->emptylock, queue->timeval); g_mutex_unlock (queue->emptylock); GST_LOCK (queue); // STATUS("queue: %s U- getting lock\n"); @@ -327,6 +331,8 @@ gst_queue_set_arg (GtkObject *object, GtkArg *arg, guint id) case ARG_BLOCK: queue->block = GTK_VALUE_BOOL (*arg); break; + case ARG_TIMEOUT: + break; default: break; } @@ -352,6 +358,8 @@ gst_queue_get_arg (GtkObject *object, GtkArg *arg, guint id) case ARG_BLOCK: GTK_VALUE_BOOL (*arg) = queue->block; break; + case ARG_TIMEOUT: + break; default: arg->type = GTK_TYPE_INVALID; break; diff --git a/gst/elements/gstqueue.h b/gst/elements/gstqueue.h index 8d8a5d4..65ad4ff 100644 --- a/gst/elements/gstqueue.h +++ b/gst/elements/gstqueue.h @@ -71,6 +71,7 @@ struct _GstQueue { GCond *emptycond; GMutex *fulllock; /* used when the queue is full */ GCond *fullcond; + GTimeVal *timeval; /* the timeout for the queue locking */ }; struct _GstQueueClass { diff --git a/plugins/elements/gstidentity.c b/plugins/elements/gstidentity.c index 740d135..b64f584 100644 --- a/plugins/elements/gstidentity.c +++ b/plugins/elements/gstidentity.c @@ -43,6 +43,7 @@ enum { enum { ARG_0, ARG_LOOP_BASED, + ARG_SLEEP_TIME, }; @@ -89,6 +90,8 @@ gst_identity_class_init (GstIdentityClass *klass) gtk_object_add_arg_type ("GstIdentity::loop_based", GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_LOOP_BASED); + gtk_object_add_arg_type ("GstIdentity::sleep_time", GTK_TYPE_UINT, + GTK_ARG_READWRITE, ARG_SLEEP_TIME); gtkobject_class->set_arg = gst_identity_set_arg; gtkobject_class->get_arg = gst_identity_get_arg; @@ -105,6 +108,7 @@ gst_identity_init (GstIdentity *identity) gst_element_add_pad (GST_ELEMENT (identity), identity->srcpad); identity->loop_based = FALSE; + identity->sleep_time = 10000; } static void @@ -120,6 +124,8 @@ gst_identity_chain (GstPad *pad, GstBuffer *buf) g_print("(%s:%s)i ",GST_DEBUG_PAD_NAME(pad)); gst_pad_push (identity->srcpad, buf); + + usleep (identity->sleep_time); } static void @@ -139,6 +145,8 @@ gst_identity_loop (GstElement *element) gst_pad_push (identity->srcpad, buf); + usleep (identity->sleep_time); + } while (!GST_ELEMENT_IS_COTHREAD_STOPPING(element)); } @@ -164,6 +172,9 @@ gst_identity_set_arg (GtkObject *object, GtkArg *arg, guint id) gst_element_set_loop_function (GST_ELEMENT (identity), NULL); } break; + case ARG_SLEEP_TIME: + identity->sleep_time = GTK_VALUE_UINT (*arg); + break; default: break; } @@ -181,6 +192,9 @@ static void gst_identity_get_arg(GtkObject *object,GtkArg *arg,guint id) { case ARG_LOOP_BASED: GTK_VALUE_BOOL (*arg) = identity->loop_based; break; + case ARG_SLEEP_TIME: + GTK_VALUE_UINT (*arg) = identity->sleep_time; + break; default: arg->type = GTK_TYPE_INVALID; break; diff --git a/plugins/elements/gstidentity.h b/plugins/elements/gstidentity.h index e2585f9..3c53648 100644 --- a/plugins/elements/gstidentity.h +++ b/plugins/elements/gstidentity.h @@ -58,6 +58,8 @@ struct _GstIdentity { GstPad *srcpad; gboolean loop_based; + + guint sleep_time; }; struct _GstIdentityClass { diff --git a/plugins/elements/gstqueue.c b/plugins/elements/gstqueue.c index 5b16408..e8ac887 100644 --- a/plugins/elements/gstqueue.c +++ b/plugins/elements/gstqueue.c @@ -53,6 +53,7 @@ enum { ARG_LEVEL, ARG_MAX_LEVEL, ARG_BLOCK, + ARG_TIMEOUT, }; @@ -110,6 +111,8 @@ gst_queue_class_init (GstQueueClass *klass) GTK_ARG_READWRITE, ARG_MAX_LEVEL); gtk_object_add_arg_type ("GstQueue::block", GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_BLOCK); + gtk_object_add_arg_type ("GstQueue::timeout", GTK_TYPE_INT, + GTK_ARG_READWRITE, ARG_TIMEOUT); gtkobject_class->set_arg = gst_queue_set_arg; gtkobject_class->get_arg = gst_queue_get_arg; @@ -163,6 +166,7 @@ gst_queue_flush (GstQueue *queue) queue->queue = NULL; queue->level_buffers = 0; + queue->timeval = NULL; } static void @@ -197,7 +201,7 @@ gst_queue_chain (GstPad *pad, GstBuffer *buf) STATUS("%s: O\n"); g_mutex_lock (queue->fulllock); GST_UNLOCK (queue); - g_cond_wait (queue->fullcond, queue->fulllock); + g_cond_timed_wait (queue->fullcond, queue->fulllock, queue->timeval); GST_LOCK (queue); g_mutex_unlock (queue->fulllock); STATUS("%s: O+\n"); @@ -253,7 +257,7 @@ gst_queue_get (GstPad *pad) STATUS("queue: %s U released lock\n"); GST_UNLOCK (queue); g_mutex_lock (queue->emptylock); - g_cond_wait (queue->emptycond, queue->emptylock); + g_cond_timed_wait (queue->emptycond, queue->emptylock, queue->timeval); g_mutex_unlock (queue->emptylock); GST_LOCK (queue); // STATUS("queue: %s U- getting lock\n"); @@ -327,6 +331,8 @@ gst_queue_set_arg (GtkObject *object, GtkArg *arg, guint id) case ARG_BLOCK: queue->block = GTK_VALUE_BOOL (*arg); break; + case ARG_TIMEOUT: + break; default: break; } @@ -352,6 +358,8 @@ gst_queue_get_arg (GtkObject *object, GtkArg *arg, guint id) case ARG_BLOCK: GTK_VALUE_BOOL (*arg) = queue->block; break; + case ARG_TIMEOUT: + break; default: arg->type = GTK_TYPE_INVALID; break; diff --git a/plugins/elements/gstqueue.h b/plugins/elements/gstqueue.h index 8d8a5d4..65ad4ff 100644 --- a/plugins/elements/gstqueue.h +++ b/plugins/elements/gstqueue.h @@ -71,6 +71,7 @@ struct _GstQueue { GCond *emptycond; GMutex *fulllock; /* used when the queue is full */ GCond *fullcond; + GTimeVal *timeval; /* the timeout for the queue locking */ }; struct _GstQueueClass { -- 2.7.4