mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 02:01:12 +00:00
Added sleep time to identity
Original commit message from CVS: Added sleep time to identity Added timeout value in queue (not activated yet)
This commit is contained in:
parent
c116d7baa5
commit
6ae2ad5edb
8 changed files with 54 additions and 4 deletions
|
@ -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;
|
||||
|
|
|
@ -58,6 +58,8 @@ struct _GstIdentity {
|
|||
GstPad *srcpad;
|
||||
|
||||
gboolean loop_based;
|
||||
|
||||
guint sleep_time;
|
||||
};
|
||||
|
||||
struct _GstIdentityClass {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -58,6 +58,8 @@ struct _GstIdentity {
|
|||
GstPad *srcpad;
|
||||
|
||||
gboolean loop_based;
|
||||
|
||||
guint sleep_time;
|
||||
};
|
||||
|
||||
struct _GstIdentityClass {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue