X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;ds=sidebyside;f=gst%2Fgsttaskpool.c;h=89c8905e5f2fb102a2f1244b985d636739f43587;hb=0c6f5b3e4c3dc55e684bca1e3fc9a2a9b74407b9;hp=d7ff3449c0e72f3588e9637f100fa99511a82a5b;hpb=e10266e3f3cf9b05b69198b1ac6faa9a62840e30;p=platform%2Fupstream%2Fgstreamer.git diff --git a/gst/gsttaskpool.c b/gst/gsttaskpool.c index d7ff344..89c8905 100644 --- a/gst/gsttaskpool.c +++ b/gst/gsttaskpool.c @@ -21,6 +21,7 @@ /** * SECTION:gsttaskpool + * @title: GstTaskPool * @short_description: Pool of GStreamer streaming threads * @see_also: #GstTask, #GstPad * @@ -34,6 +35,7 @@ #include "gstinfo.h" #include "gsttaskpool.h" +#include "gsterror.h" GST_DEBUG_CATEGORY_STATIC (taskpool_debug); #define GST_CAT_DEFAULT (taskpool_debug) @@ -72,22 +74,26 @@ static void default_prepare (GstTaskPool * pool, GError ** error) { GST_OBJECT_LOCK (pool); - pool->pool = g_thread_pool_new ((GFunc) default_func, pool, -1, FALSE, NULL); + pool->pool = g_thread_pool_new ((GFunc) default_func, pool, -1, FALSE, error); GST_OBJECT_UNLOCK (pool); } static void default_cleanup (GstTaskPool * pool) { + GThreadPool *pool_; + GST_OBJECT_LOCK (pool); - if (pool->pool) { + pool_ = pool->pool; + pool->pool = NULL; + GST_OBJECT_UNLOCK (pool); + + if (pool_) { /* Shut down all the threads, we still process the ones scheduled * because the unref happens in the thread function. * Also wait for currently running ones to finish. */ - g_thread_pool_free (pool->pool, FALSE, TRUE); - pool->pool = NULL; + g_thread_pool_free (pool_, FALSE, TRUE); } - GST_OBJECT_UNLOCK (pool); } static gpointer @@ -105,6 +111,9 @@ default_push (GstTaskPool * pool, GstTaskPoolFunction func, g_thread_pool_push (pool->pool, tdata, error); else { g_slice_free (TaskData, tdata); + g_set_error_literal (error, GST_CORE_ERROR, GST_CORE_ERROR_FAILED, + "No thread pool"); + } GST_OBJECT_UNLOCK (pool); @@ -139,8 +148,6 @@ gst_task_pool_class_init (GstTaskPoolClass * klass) static void gst_task_pool_init (GstTaskPool * pool) { - /* clear floating flag */ - gst_object_ref_sink (pool); } #ifndef GST_DISABLE_GST_DEBUG @@ -165,7 +172,10 @@ gst_task_pool_new (void) { GstTaskPool *pool; - pool = g_object_newv (GST_TYPE_TASK_POOL, 0, NULL); + pool = g_object_new (GST_TYPE_TASK_POOL, NULL); + + /* clear floating flag */ + gst_object_ref_sink (pool); return pool; } @@ -223,9 +233,9 @@ gst_task_pool_cleanup (GstTaskPool * pool) * * Start the execution of a new thread from @pool. * - * Returns: (transfer none): a pointer that should be used for the - * gst_task_pool_join function. This pointer can be %NULL, you must - * check @error to detect errors. + * Returns: (transfer none) (nullable): a pointer that should be used + * for the gst_task_pool_join function. This pointer can be %NULL, you + * must check @error to detect errors. */ gpointer gst_task_pool_push (GstTaskPool * pool, GstTaskPoolFunction func, @@ -255,7 +265,7 @@ not_supported: * @pool: a #GstTaskPool * @id: the id * - * Join a task and/or return it to the pool. @id is the id obtained from + * Join a task and/or return it to the pool. @id is the id obtained from * gst_task_pool_push(). */ void