summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gst/gstpad.h1
-rw-r--r--gst/gstscheduler.c21
-rw-r--r--gst/gstscheduler.h2
-rw-r--r--gst/gstthread.c8
-rw-r--r--gst/gstthread.h1
-rw-r--r--gst/schedulers/cothreads_compat.h5
-rw-r--r--gst/schedulers/gstbasicscheduler.c13
7 files changed, 49 insertions, 2 deletions
diff --git a/gst/gstpad.h b/gst/gstpad.h
index 477af6aa42..a8da155054 100644
--- a/gst/gstpad.h
+++ b/gst/gstpad.h
@@ -122,6 +122,7 @@ typedef enum {
GST_PAD_QUERY_TOTAL,
GST_PAD_QUERY_POSITION,
GST_PAD_QUERY_LATENCY,
+ GST_PAD_QUERY_JITTER,
} GstPadQueryType;
/* this defines the functions used to chain buffers
diff --git a/gst/gstscheduler.c b/gst/gstscheduler.c
index 7a9a5b5c06..4a6db43872 100644
--- a/gst/gstscheduler.c
+++ b/gst/gstscheduler.c
@@ -94,6 +94,27 @@ gst_scheduler_setup (GstScheduler *sched)
}
/**
+ * gst_scheduler_get_prefered_stack:
+ * @sched: the scheduler
+ * @stack: a pointer to the location of the prefered stack
+ * @size: a pointer to the size of the prefered stack
+ *
+ * Get the prefered stack location and size of this scheduler.
+ *
+ * Returns: TRUE if the scheduler suggested a prefered stacksize and location.
+ */
+gboolean
+gst_scheduler_get_prefered_stack (GstScheduler *sched, gpointer *stack, gulong *size)
+{
+ g_return_val_if_fail (GST_IS_SCHEDULER (sched), FALSE);
+
+ if (CLASS (sched)->get_prefered_stack)
+ return CLASS (sched)->get_prefered_stack (sched, stack, size);
+
+ return FALSE;
+}
+
+/**
* gst_scheduler_reset:
* @sched: the scheduler
*
diff --git a/gst/gstscheduler.h b/gst/gstscheduler.h
index 7006d020f4..1cc761c5b7 100644
--- a/gst/gstscheduler.h
+++ b/gst/gstscheduler.h
@@ -85,6 +85,7 @@ struct _GstSchedulerClass {
/* virtual methods */
void (*setup) (GstScheduler *sched);
+ gboolean (*get_prefered_stack) (GstScheduler *sched, gpointer *stack, gulong *size);
void (*reset) (GstScheduler *sched);
void (*add_element) (GstScheduler *sched, GstElement *element);
void (*remove_element) (GstScheduler *sched, GstElement *element);
@@ -114,6 +115,7 @@ GType gst_scheduler_get_type (void);
void gst_scheduler_setup (GstScheduler *sched);
+gboolean gst_scheduler_get_prefered_stack(GstScheduler *sched, gpointer *stack, gulong *size);
void gst_scheduler_reset (GstScheduler *sched);
void gst_scheduler_add_element (GstScheduler *sched, GstElement *element);
void gst_scheduler_remove_element (GstScheduler *sched, GstElement *element);
diff --git a/gst/gstthread.c b/gst/gstthread.c
index 100172285f..936a413eb2 100644
--- a/gst/gstthread.c
+++ b/gst/gstthread.c
@@ -243,6 +243,8 @@ gst_thread_change_state (GstElement * element)
gboolean stateset = GST_STATE_SUCCESS;
gint transition;
pthread_t self = pthread_self ();
+ void *stack;
+ glong stacksize;
g_return_val_if_fail (GST_IS_THREAD (element), FALSE);
@@ -270,8 +272,12 @@ gst_thread_change_state (GstElement * element)
g_mutex_lock (thread->lock);
+ pthread_attr_init (&thread->attr);
+ if (gst_scheduler_get_prefered_stack (GST_ELEMENT_SCHED (element), &stack, &stacksize)) {
+ pthread_attr_setstack (&thread->attr, stack, stacksize);
+ }
/* create the thread */
- if (pthread_create (&thread->thread_id, NULL, gst_thread_main_loop, thread) != 0) {
+ if (pthread_create (&thread->thread_id, &thread->attr, gst_thread_main_loop, thread) != 0) {
g_mutex_unlock (thread->lock);
THR_DEBUG ("could not create thread \"%s\"", GST_ELEMENT_NAME (element));
return GST_STATE_FAILURE;
diff --git a/gst/gstthread.h b/gst/gstthread.h
index 1e9da8e543..8cece606d3 100644
--- a/gst/gstthread.h
+++ b/gst/gstthread.h
@@ -65,6 +65,7 @@ struct _GstThread {
GstBin bin;
pthread_t thread_id; /* id of the thread, if any */
+ pthread_attr_t attr; /* attributes for the stack space */
gint pid; /* the pid of the thread */
gint ppid; /* the pid of the thread's parent process */
GMutex *lock; /* thread lock/condititon pair ... */
diff --git a/gst/schedulers/cothreads_compat.h b/gst/schedulers/cothreads_compat.h
index 42bef0b696..ae7e684c84 100644
--- a/gst/schedulers/cothreads_compat.h
+++ b/gst/schedulers/cothreads_compat.h
@@ -40,6 +40,8 @@ typedef cothread_state cothread;
*/
#define do_cothreads_init(x) /* NOP */
+#define do_cothreads_stackquery(stack,size) FALSE
+
#define do_cothread_switch(to) cothread_switch(to)
#define do_cothread_create(new_thread, context, func, argc, argv) \
@@ -91,6 +93,9 @@ typedef cothread cothread_context;
cothreads_init(x); \
}G_STMT_END
+#define do_cothreads_stackquery(stack,size) \
+ cothreads_alloc_thread_stack (stack, size)
+
#define do_cothread_switch(to) G_STMT_START{ \
cothread *from = cothread_self (); \
if (from == (to)) { \
diff --git a/gst/schedulers/gstbasicscheduler.c b/gst/schedulers/gstbasicscheduler.c
index d376f58ace..d38872a74d 100644
--- a/gst/schedulers/gstbasicscheduler.c
+++ b/gst/schedulers/gstbasicscheduler.c
@@ -109,6 +109,7 @@ static void gst_basic_scheduler_init (GstBasicScheduler * scheduler);
static void gst_basic_scheduler_dispose (GObject *object);
static void gst_basic_scheduler_setup (GstScheduler *sched);
+static gboolean gst_basic_scheduler_get_prefered_stack (GstScheduler *sched, gpointer *stack, gulong *size);
static void gst_basic_scheduler_reset (GstScheduler *sched);
static void gst_basic_scheduler_add_element (GstScheduler *sched, GstElement *element);
static void gst_basic_scheduler_remove_element (GstScheduler *sched, GstElement *element);
@@ -200,6 +201,7 @@ gst_basic_scheduler_class_init (GstBasicSchedulerClass * klass)
gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_basic_scheduler_dispose);
gstscheduler_class->setup = GST_DEBUG_FUNCPTR (gst_basic_scheduler_setup);
+ gstscheduler_class->get_prefered_stack= GST_DEBUG_FUNCPTR (gst_basic_scheduler_get_prefered_stack);
gstscheduler_class->reset = GST_DEBUG_FUNCPTR (gst_basic_scheduler_reset);
gstscheduler_class->add_element = GST_DEBUG_FUNCPTR (gst_basic_scheduler_add_element);
gstscheduler_class->remove_element = GST_DEBUG_FUNCPTR (gst_basic_scheduler_remove_element);
@@ -931,7 +933,6 @@ gst_basic_scheduler_chain_recursive_add (GstSchedulerChain * chain, GstElement *
static void
gst_basic_scheduler_setup (GstScheduler *sched)
{
-
/* first create thread context */
if (GST_BASIC_SCHEDULER_CAST (sched)->context == NULL) {
GST_DEBUG (GST_CAT_SCHEDULING, "initializing cothread context");
@@ -939,6 +940,16 @@ gst_basic_scheduler_setup (GstScheduler *sched)
}
}
+static gboolean
+gst_basic_scheduler_get_prefered_stack (GstScheduler *sched, gpointer *stack, gulong *size)
+{
+ if (do_cothreads_stackquery (stack, size)) {
+ GST_DEBUG (GST_CAT_SCHEDULING, "getting prefered stack size as %p and %lu", *stack, *size);
+ return TRUE;
+ }
+ return FALSE;
+}
+
static void
gst_basic_scheduler_reset (GstScheduler *sched)
{