summaryrefslogtreecommitdiff
path: root/gst
diff options
context:
space:
mode:
authorWim Taymans <wim.taymans@gmail.com>2001-01-07 03:42:27 +0000
committerWim Taymans <wim.taymans@gmail.com>2001-01-07 03:42:27 +0000
commit6ae2ad5edbe111ae0d84cdf7bcf107ecc1a66e02 (patch)
tree3f4081b1dcb87b1959ab2b55f45801bce64877b3 /gst
parentc116d7baa5c67e19cf9dab7f0fe4eab4a1c41898 (diff)
Added sleep time to identity
Original commit message from CVS: Added sleep time to identity Added timeout value in queue (not activated yet)
Diffstat (limited to 'gst')
-rw-r--r--gst/elements/gstidentity.c14
-rw-r--r--gst/elements/gstidentity.h2
-rw-r--r--gst/elements/gstqueue.c12
-rw-r--r--gst/elements/gstqueue.h1
4 files changed, 27 insertions, 2 deletions
diff --git a/gst/elements/gstidentity.c b/gst/elements/gstidentity.c
index 740d135d77..b64f584361 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 e2585f90b9..3c536484ec 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 5b16408ef4..e8ac887962 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 8d8a5d4589..65ad4ff8bd 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 {