summaryrefslogtreecommitdiff
path: root/gst/gsttask.c
diff options
context:
space:
mode:
authorWim Taymans <wim.taymans@collabora.co.uk>2009-04-23 17:05:21 +0200
committerWim Taymans <wim@metal.(none)>2009-05-12 00:26:48 +0200
commita8d2516fa6630a90811f6550f87416007c4aa4d1 (patch)
tree3adc413bca44ec8d489c9175ac99ea4899b40fcd /gst/gsttask.c
parent8ada09abac2e5972baabc15271fdd515f8496009 (diff)
downloadgstreamer-a8d2516fa6630a90811f6550f87416007c4aa4d1.tar.gz
Task: remember pool
Remember the pool we currently have our task running so that we can use it to join the task later on. Fix a leak of the taskpool.
Diffstat (limited to 'gst/gsttask.c')
-rw-r--r--gst/gsttask.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/gst/gsttask.c b/gst/gsttask.c
index a8caf43bd9..857c8673b5 100644
--- a/gst/gsttask.c
+++ b/gst/gsttask.c
@@ -80,8 +80,12 @@ struct _GstTaskPrivate
gboolean prio_set;
GThreadPriority priority;
+ /* configured pool */
GstTaskPool *pool;
+
+ /* remember the pool and id that is currently running. */
gpointer id;
+ GstTaskPool *pool_id;
};
static void gst_task_class_init (GstTaskClass * klass);
@@ -162,6 +166,8 @@ gst_task_finalize (GObject * object)
priv->thr_notify = NULL;
priv->thr_user_data = NULL;
+ gst_object_unref (priv->pool);
+
/* task thread cannot be running here since it holds a ref
* to the task so that the finalize could not have happened */
g_cond_free (task->cond);
@@ -488,8 +494,10 @@ start_task (GstTask * task)
tclass = GST_TASK_GET_CLASS (task);
- /* push on the thread pool */
- priv->id = gst_task_pool_push (priv->pool, task, &error);
+ /* push on the thread pool, we remember the original pool because the user
+ * could change it later on and then we join to the wrong pool. */
+ priv->pool_id = gst_object_ref (priv->pool);
+ priv->id = gst_task_pool_push (priv->pool_id, task, &error);
if (error != NULL) {
g_warning ("failed to create thread: %s", error->message);
@@ -671,8 +679,9 @@ gst_task_join (GstTask * task)
task->abidata.ABI.thread = NULL;
/* get the id and pool to join */
if ((id = priv->id)) {
- if ((pool = priv->pool))
+ if ((pool = priv->pool_id))
gst_object_ref (pool);
+ priv->pool_id = NULL;
priv->id = NULL;
}
GST_OBJECT_UNLOCK (task);