}
/**
- * gst_scheduler_get_prefered_stack:
+ * gst_scheduler_get_preferred_stack:
* @sched: the scheduler
- * @stack: a pointer to the location of the prefered stack
- * @size: a pointer to the size of the prefered stack
+ * @stack: a pointer to the location of the preferred 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
-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);
- if (CLASS (sched)->get_prefered_stack)
- return CLASS (sched)->get_prefered_stack (sched, stack, size);
+ if (CLASS (sched)->get_preferred_stack)
+ return CLASS (sched)->get_preferred_stack (sched, stack, size);
return FALSE;
}
/* virtual methods */
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 (*add_element) (GstScheduler *sched, GstElement *element);
void (*remove_element) (GstScheduler *sched, GstElement *element);
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_add_element (GstScheduler *sched, GstElement *element);
void gst_scheduler_remove_element (GstScheduler *sched, GstElement *element);
gst_thread_dispose (GObject *object)
{
GstThread *thread = GST_THREAD (object);
- void *stack;
- long stacksize;
GST_DEBUG (GST_CAT_REFCOUNTING, "dispose");
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)) {
gst_object_unref (GST_OBJECT (GST_ELEMENT_SCHED (thread)));
}
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), GST_STATE_FAILURE);
if (pthread_attr_init (&thread->attr) != 0)
g_warning ("pthread_attr_init returned an error !");
- if (gst_scheduler_get_prefered_stack (GST_ELEMENT_SCHED (element), &stack, &stacksize)) {
- if (pthread_attr_setstack (&thread->attr, stack, stacksize) != 0)
- g_warning ("pthread_attr_setstack failed !\n");
- GST_DEBUG (GST_CAT_THREAD,
- "pthread attr set stack at %p of size %ld",
- stack, stacksize);
+ if (gst_scheduler_get_preferred_stack (GST_ELEMENT_SCHED (element), &thread->stack, &stacksize)) {
+ if (pthread_attr_setstack (&thread->attr, thread->stack, stacksize) != 0) {
+ g_warning ("pthread_attr_setstack failed");
+ return GST_STATE_FAILURE;
+ }
+ 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 */
THR_DEBUG ("going to pthread_create...");
thread->thread_id = -1;
g_mutex_unlock (thread->lock);
- /*
- * FIXME: we moved this code to the scheduler dispose function
- pthread_attr_getstack (&thread->attr, &stack, (size_t *) &stacksize);
- GST_DEBUG (GST_CAT_THREAD, "undng posix_memalign at %p of size %ld\n",
- stack, stacksize);
- stack, stacksize);
- free (thread->stack);
- thread->stack = 0;
-*/
+ if (thread->stack) {
+ GST_DEBUG (GST_CAT_THREAD, "freeing allocated stack (%p)", thread->stack);
+ free (thread->stack);
+ thread->stack = NULL;
+ }
+
GST_FLAG_UNSET (thread, GST_THREAD_STATE_REAPING);
GST_FLAG_UNSET (thread, GST_THREAD_STATE_STARTED);
GST_FLAG_UNSET (thread, GST_THREAD_STATE_SPINNING);
pthread_t thread_id; /* id of the thread, if any */
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 ppid; /* the pid of the thread's parent process */
GMutex *lock; /* thread lock/condititon pair ... */
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 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_add_element (GstScheduler *sched, GstElement *element);
static void gst_basic_scheduler_remove_element (GstScheduler *sched, GstElement *element);
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->get_preferred_stack= GST_DEBUG_FUNCPTR (gst_basic_scheduler_get_preferred_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);
}
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)) {
- 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 FALSE;