mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 04:36:20 +00:00
Added _get_prefered_stack to the scheduler
Original commit message from CVS: Added _get_prefered_stack to the scheduler
This commit is contained in:
parent
87b2474153
commit
3dd3895eea
7 changed files with 49 additions and 2 deletions
|
@ -122,6 +122,7 @@ typedef enum {
|
||||||
GST_PAD_QUERY_TOTAL,
|
GST_PAD_QUERY_TOTAL,
|
||||||
GST_PAD_QUERY_POSITION,
|
GST_PAD_QUERY_POSITION,
|
||||||
GST_PAD_QUERY_LATENCY,
|
GST_PAD_QUERY_LATENCY,
|
||||||
|
GST_PAD_QUERY_JITTER,
|
||||||
} GstPadQueryType;
|
} GstPadQueryType;
|
||||||
|
|
||||||
/* this defines the functions used to chain buffers
|
/* this defines the functions used to chain buffers
|
||||||
|
|
|
@ -93,6 +93,27 @@ gst_scheduler_setup (GstScheduler *sched)
|
||||||
CLASS (sched)->setup (sched);
|
CLASS (sched)->setup (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:
|
* gst_scheduler_reset:
|
||||||
* @sched: the scheduler
|
* @sched: the scheduler
|
||||||
|
|
|
@ -85,6 +85,7 @@ struct _GstSchedulerClass {
|
||||||
|
|
||||||
/* virtual methods */
|
/* virtual methods */
|
||||||
void (*setup) (GstScheduler *sched);
|
void (*setup) (GstScheduler *sched);
|
||||||
|
gboolean (*get_prefered_stack) (GstScheduler *sched, gpointer *stack, gulong *size);
|
||||||
void (*reset) (GstScheduler *sched);
|
void (*reset) (GstScheduler *sched);
|
||||||
void (*add_element) (GstScheduler *sched, GstElement *element);
|
void (*add_element) (GstScheduler *sched, GstElement *element);
|
||||||
void (*remove_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);
|
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_reset (GstScheduler *sched);
|
||||||
void gst_scheduler_add_element (GstScheduler *sched, GstElement *element);
|
void gst_scheduler_add_element (GstScheduler *sched, GstElement *element);
|
||||||
void gst_scheduler_remove_element (GstScheduler *sched, GstElement *element);
|
void gst_scheduler_remove_element (GstScheduler *sched, GstElement *element);
|
||||||
|
|
|
@ -243,6 +243,8 @@ gst_thread_change_state (GstElement * element)
|
||||||
gboolean stateset = GST_STATE_SUCCESS;
|
gboolean stateset = GST_STATE_SUCCESS;
|
||||||
gint transition;
|
gint transition;
|
||||||
pthread_t self = pthread_self ();
|
pthread_t self = pthread_self ();
|
||||||
|
void *stack;
|
||||||
|
glong stacksize;
|
||||||
|
|
||||||
g_return_val_if_fail (GST_IS_THREAD (element), FALSE);
|
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);
|
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 */
|
/* 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);
|
g_mutex_unlock (thread->lock);
|
||||||
THR_DEBUG ("could not create thread \"%s\"", GST_ELEMENT_NAME (element));
|
THR_DEBUG ("could not create thread \"%s\"", GST_ELEMENT_NAME (element));
|
||||||
return GST_STATE_FAILURE;
|
return GST_STATE_FAILURE;
|
||||||
|
|
|
@ -65,6 +65,7 @@ struct _GstThread {
|
||||||
GstBin bin;
|
GstBin bin;
|
||||||
|
|
||||||
pthread_t thread_id; /* id of the thread, if any */
|
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 pid; /* the pid of the thread */
|
||||||
gint ppid; /* the pid of the thread's parent process */
|
gint ppid; /* the pid of the thread's parent process */
|
||||||
GMutex *lock; /* thread lock/condititon pair ... */
|
GMutex *lock; /* thread lock/condititon pair ... */
|
||||||
|
|
|
@ -40,6 +40,8 @@ typedef cothread_state cothread;
|
||||||
*/
|
*/
|
||||||
#define do_cothreads_init(x) /* NOP */
|
#define do_cothreads_init(x) /* NOP */
|
||||||
|
|
||||||
|
#define do_cothreads_stackquery(stack,size) FALSE
|
||||||
|
|
||||||
#define do_cothread_switch(to) cothread_switch(to)
|
#define do_cothread_switch(to) cothread_switch(to)
|
||||||
|
|
||||||
#define do_cothread_create(new_thread, context, func, argc, argv) \
|
#define do_cothread_create(new_thread, context, func, argc, argv) \
|
||||||
|
@ -91,6 +93,9 @@ typedef cothread cothread_context;
|
||||||
cothreads_init(x); \
|
cothreads_init(x); \
|
||||||
}G_STMT_END
|
}G_STMT_END
|
||||||
|
|
||||||
|
#define do_cothreads_stackquery(stack,size) \
|
||||||
|
cothreads_alloc_thread_stack (stack, size)
|
||||||
|
|
||||||
#define do_cothread_switch(to) G_STMT_START{ \
|
#define do_cothread_switch(to) G_STMT_START{ \
|
||||||
cothread *from = cothread_self (); \
|
cothread *from = cothread_self (); \
|
||||||
if (from == (to)) { \
|
if (from == (to)) { \
|
||||||
|
|
|
@ -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_dispose (GObject *object);
|
||||||
|
|
||||||
static void gst_basic_scheduler_setup (GstScheduler *sched);
|
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_reset (GstScheduler *sched);
|
||||||
static void gst_basic_scheduler_add_element (GstScheduler *sched, GstElement *element);
|
static void gst_basic_scheduler_add_element (GstScheduler *sched, GstElement *element);
|
||||||
static void gst_basic_scheduler_remove_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);
|
gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_basic_scheduler_dispose);
|
||||||
|
|
||||||
gstscheduler_class->setup = GST_DEBUG_FUNCPTR (gst_basic_scheduler_setup);
|
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->reset = GST_DEBUG_FUNCPTR (gst_basic_scheduler_reset);
|
||||||
gstscheduler_class->add_element = GST_DEBUG_FUNCPTR (gst_basic_scheduler_add_element);
|
gstscheduler_class->add_element = GST_DEBUG_FUNCPTR (gst_basic_scheduler_add_element);
|
||||||
gstscheduler_class->remove_element = GST_DEBUG_FUNCPTR (gst_basic_scheduler_remove_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
|
static void
|
||||||
gst_basic_scheduler_setup (GstScheduler *sched)
|
gst_basic_scheduler_setup (GstScheduler *sched)
|
||||||
{
|
{
|
||||||
|
|
||||||
/* first create thread context */
|
/* first create thread context */
|
||||||
if (GST_BASIC_SCHEDULER_CAST (sched)->context == NULL) {
|
if (GST_BASIC_SCHEDULER_CAST (sched)->context == NULL) {
|
||||||
GST_DEBUG (GST_CAT_SCHEDULING, "initializing cothread context");
|
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
|
static void
|
||||||
gst_basic_scheduler_reset (GstScheduler *sched)
|
gst_basic_scheduler_reset (GstScheduler *sched)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue