enum {
ARG_0,
ARG_LOOP_BASED,
+ ARG_SLEEP_TIME,
};
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;
gst_element_add_pad (GST_ELEMENT (identity), identity->srcpad);
identity->loop_based = FALSE;
+ identity->sleep_time = 10000;
}
static void
g_print("(%s:%s)i ",GST_DEBUG_PAD_NAME(pad));
gst_pad_push (identity->srcpad, buf);
+
+ usleep (identity->sleep_time);
}
static void
gst_pad_push (identity->srcpad, buf);
+ usleep (identity->sleep_time);
+
} while (!GST_ELEMENT_IS_COTHREAD_STOPPING(element));
}
gst_element_set_loop_function (GST_ELEMENT (identity), NULL);
}
break;
+ case ARG_SLEEP_TIME:
+ identity->sleep_time = GTK_VALUE_UINT (*arg);
+ break;
default:
break;
}
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;
GstPad *srcpad;
gboolean loop_based;
+
+ guint sleep_time;
};
struct _GstIdentityClass {
ARG_LEVEL,
ARG_MAX_LEVEL,
ARG_BLOCK,
+ ARG_TIMEOUT,
};
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;
queue->queue = NULL;
queue->level_buffers = 0;
+ queue->timeval = NULL;
}
static void
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");
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");
case ARG_BLOCK:
queue->block = GTK_VALUE_BOOL (*arg);
break;
+ case ARG_TIMEOUT:
+ break;
default:
break;
}
case ARG_BLOCK:
GTK_VALUE_BOOL (*arg) = queue->block;
break;
+ case ARG_TIMEOUT:
+ break;
default:
arg->type = GTK_TYPE_INVALID;
break;
GCond *emptycond;
GMutex *fulllock; /* used when the queue is full */
GCond *fullcond;
+ GTimeVal *timeval; /* the timeout for the queue locking */
};
struct _GstQueueClass {
enum {
ARG_0,
ARG_LOOP_BASED,
+ ARG_SLEEP_TIME,
};
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;
gst_element_add_pad (GST_ELEMENT (identity), identity->srcpad);
identity->loop_based = FALSE;
+ identity->sleep_time = 10000;
}
static void
g_print("(%s:%s)i ",GST_DEBUG_PAD_NAME(pad));
gst_pad_push (identity->srcpad, buf);
+
+ usleep (identity->sleep_time);
}
static void
gst_pad_push (identity->srcpad, buf);
+ usleep (identity->sleep_time);
+
} while (!GST_ELEMENT_IS_COTHREAD_STOPPING(element));
}
gst_element_set_loop_function (GST_ELEMENT (identity), NULL);
}
break;
+ case ARG_SLEEP_TIME:
+ identity->sleep_time = GTK_VALUE_UINT (*arg);
+ break;
default:
break;
}
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;
GstPad *srcpad;
gboolean loop_based;
+
+ guint sleep_time;
};
struct _GstIdentityClass {
ARG_LEVEL,
ARG_MAX_LEVEL,
ARG_BLOCK,
+ ARG_TIMEOUT,
};
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;
queue->queue = NULL;
queue->level_buffers = 0;
+ queue->timeval = NULL;
}
static void
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");
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");
case ARG_BLOCK:
queue->block = GTK_VALUE_BOOL (*arg);
break;
+ case ARG_TIMEOUT:
+ break;
default:
break;
}
case ARG_BLOCK:
GTK_VALUE_BOOL (*arg) = queue->block;
break;
+ case ARG_TIMEOUT:
+ break;
default:
arg->type = GTK_TYPE_INVALID;
break;
GCond *emptycond;
GMutex *fulllock; /* used when the queue is full */
GCond *fullcond;
+ GTimeVal *timeval; /* the timeout for the queue locking */
};
struct _GstQueueClass {