mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-26 19:51:11 +00:00
free stack properly s/prefered/preferred/
Original commit message from CVS: * free stack properly * s/prefered/preferred/
This commit is contained in:
parent
781f489e87
commit
2eb7f04289
5 changed files with 28 additions and 40 deletions
|
@ -94,22 +94,22 @@ gst_scheduler_setup (GstScheduler *sched)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gst_scheduler_get_prefered_stack:
|
* gst_scheduler_get_preferred_stack:
|
||||||
* @sched: the scheduler
|
* @sched: the scheduler
|
||||||
* @stack: a pointer to the location of the prefered stack
|
* @stack: a pointer to the location of the preferred stack
|
||||||
* @size: a pointer to the size of the prefered stack
|
* @size: a pointer to the size of the preferred stack
|
||||||
*
|
*
|
||||||
* Get the prefered stack location and size of this scheduler.
|
* Get the preferred stack location and size of this scheduler.
|
||||||
*
|
*
|
||||||
* Returns: TRUE if the scheduler suggested a prefered stacksize and location.
|
* Returns: TRUE if the scheduler suggested a preferred stacksize and location.
|
||||||
*/
|
*/
|
||||||
gboolean
|
gboolean
|
||||||
gst_scheduler_get_prefered_stack (GstScheduler *sched, gpointer *stack, gulong *size)
|
gst_scheduler_get_preferred_stack (GstScheduler *sched, gpointer *stack, gulong *size)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (GST_IS_SCHEDULER (sched), FALSE);
|
g_return_val_if_fail (GST_IS_SCHEDULER (sched), FALSE);
|
||||||
|
|
||||||
if (CLASS (sched)->get_prefered_stack)
|
if (CLASS (sched)->get_preferred_stack)
|
||||||
return CLASS (sched)->get_prefered_stack (sched, stack, size);
|
return CLASS (sched)->get_preferred_stack (sched, stack, size);
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,7 +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);
|
gboolean (*get_preferred_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);
|
||||||
|
@ -115,7 +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);
|
gboolean gst_scheduler_get_preferred_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);
|
||||||
|
|
|
@ -154,8 +154,6 @@ static void
|
||||||
gst_thread_dispose (GObject *object)
|
gst_thread_dispose (GObject *object)
|
||||||
{
|
{
|
||||||
GstThread *thread = GST_THREAD (object);
|
GstThread *thread = GST_THREAD (object);
|
||||||
void *stack;
|
|
||||||
long stacksize;
|
|
||||||
|
|
||||||
GST_DEBUG (GST_CAT_REFCOUNTING, "dispose");
|
GST_DEBUG (GST_CAT_REFCOUNTING, "dispose");
|
||||||
|
|
||||||
|
@ -164,12 +162,6 @@ gst_thread_dispose (GObject *object)
|
||||||
|
|
||||||
G_OBJECT_CLASS (parent_class)->dispose (object);
|
G_OBJECT_CLASS (parent_class)->dispose (object);
|
||||||
|
|
||||||
GST_DEBUG (GST_CAT_THREAD, "Disposing of thread");
|
|
||||||
pthread_attr_getstack (&thread->attr, &stack, (size_t *) &stacksize);
|
|
||||||
GST_DEBUG (GST_CAT_THREAD, "undoing posix_memalign at %p of size %ld",
|
|
||||||
stack, stacksize);
|
|
||||||
free (stack);
|
|
||||||
|
|
||||||
if (GST_ELEMENT_SCHED (thread)) {
|
if (GST_ELEMENT_SCHED (thread)) {
|
||||||
gst_object_unref (GST_OBJECT (GST_ELEMENT_SCHED (thread)));
|
gst_object_unref (GST_OBJECT (GST_ELEMENT_SCHED (thread)));
|
||||||
}
|
}
|
||||||
|
@ -252,7 +244,6 @@ 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;
|
glong stacksize;
|
||||||
|
|
||||||
g_return_val_if_fail (GST_IS_THREAD (element), GST_STATE_FAILURE);
|
g_return_val_if_fail (GST_IS_THREAD (element), GST_STATE_FAILURE);
|
||||||
|
@ -284,15 +275,14 @@ gst_thread_change_state (GstElement * element)
|
||||||
|
|
||||||
if (pthread_attr_init (&thread->attr) != 0)
|
if (pthread_attr_init (&thread->attr) != 0)
|
||||||
g_warning ("pthread_attr_init returned an error !");
|
g_warning ("pthread_attr_init returned an error !");
|
||||||
if (gst_scheduler_get_prefered_stack (GST_ELEMENT_SCHED (element), &stack, &stacksize)) {
|
if (gst_scheduler_get_preferred_stack (GST_ELEMENT_SCHED (element), &thread->stack, &stacksize)) {
|
||||||
if (pthread_attr_setstack (&thread->attr, stack, stacksize) != 0)
|
if (pthread_attr_setstack (&thread->attr, thread->stack, stacksize) != 0) {
|
||||||
g_warning ("pthread_attr_setstack failed !\n");
|
g_warning ("pthread_attr_setstack failed");
|
||||||
GST_DEBUG (GST_CAT_THREAD,
|
return GST_STATE_FAILURE;
|
||||||
"pthread attr set stack at %p of size %ld",
|
}
|
||||||
stack, stacksize);
|
GST_DEBUG (GST_CAT_THREAD, "pthread attr set stack at %p of size %ld",
|
||||||
|
thread->stack, stacksize);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
g_warning ("_get_prefered_stack failed !\n");
|
|
||||||
|
|
||||||
/* create the thread */
|
/* create the thread */
|
||||||
THR_DEBUG ("going to pthread_create...");
|
THR_DEBUG ("going to pthread_create...");
|
||||||
|
@ -428,15 +418,12 @@ gst_thread_change_state (GstElement * element)
|
||||||
thread->thread_id = -1;
|
thread->thread_id = -1;
|
||||||
g_mutex_unlock (thread->lock);
|
g_mutex_unlock (thread->lock);
|
||||||
|
|
||||||
/*
|
if (thread->stack) {
|
||||||
* FIXME: we moved this code to the scheduler dispose function
|
GST_DEBUG (GST_CAT_THREAD, "freeing allocated stack (%p)", thread->stack);
|
||||||
pthread_attr_getstack (&thread->attr, &stack, (size_t *) &stacksize);
|
free (thread->stack);
|
||||||
GST_DEBUG (GST_CAT_THREAD, "undng posix_memalign at %p of size %ld\n",
|
thread->stack = NULL;
|
||||||
stack, stacksize);
|
}
|
||||||
stack, stacksize);
|
|
||||||
free (thread->stack);
|
|
||||||
thread->stack = 0;
|
|
||||||
*/
|
|
||||||
GST_FLAG_UNSET (thread, GST_THREAD_STATE_REAPING);
|
GST_FLAG_UNSET (thread, GST_THREAD_STATE_REAPING);
|
||||||
GST_FLAG_UNSET (thread, GST_THREAD_STATE_STARTED);
|
GST_FLAG_UNSET (thread, GST_THREAD_STATE_STARTED);
|
||||||
GST_FLAG_UNSET (thread, GST_THREAD_STATE_SPINNING);
|
GST_FLAG_UNSET (thread, GST_THREAD_STATE_SPINNING);
|
||||||
|
|
|
@ -66,6 +66,7 @@ struct _GstThread {
|
||||||
|
|
||||||
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 */
|
pthread_attr_t attr; /* attributes for the stack space */
|
||||||
|
void *stack; /* set with gst_scheduler_get_preferred_stack */
|
||||||
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 ... */
|
||||||
|
|
|
@ -109,7 +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 gboolean gst_basic_scheduler_get_preferred_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);
|
||||||
|
@ -201,7 +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->get_preferred_stack= GST_DEBUG_FUNCPTR (gst_basic_scheduler_get_preferred_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);
|
||||||
|
@ -952,10 +952,10 @@ gst_basic_scheduler_setup (GstScheduler *sched)
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_basic_scheduler_get_prefered_stack (GstScheduler *sched, gpointer *stack, gulong *size)
|
gst_basic_scheduler_get_preferred_stack (GstScheduler *sched, gpointer *stack, gulong *size)
|
||||||
{
|
{
|
||||||
if (do_cothreads_stackquery (stack, size)) {
|
if (do_cothreads_stackquery (stack, size)) {
|
||||||
GST_DEBUG (GST_CAT_SCHEDULING, "getting prefered stack size as %p and %lu", *stack, *size);
|
GST_DEBUG (GST_CAT_SCHEDULING, "getting preferred stack size as %p and %lu", *stack, *size);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
Loading…
Reference in a new issue