From 7a0f4422fa1692dfdd8df9580676c8125be4280b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim-Philipp=20M=C3=BCller?= Date: Fri, 8 Jul 2016 17:46:06 +0100 Subject: [PATCH] element: re-create threadpool after cleaning up tasks We don't free this from gst_deinit() but from gst_task_cleanup_all(), so more GStreamer API may be called. In particular makes unit tests work again with CK_FORK=no. https://bugzilla.gnome.org/show_bug.cgi?id=768577 --- gst/gstelement.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/gst/gstelement.c b/gst/gstelement.c index 761627b..4333d53 100644 --- a/gst/gstelement.c +++ b/gst/gstelement.c @@ -187,10 +187,24 @@ gst_element_get_type (void) } static void +gst_element_setup_thread_pool (void) +{ + GError *err = NULL; + + GST_DEBUG ("creating element thread pool"); + gst_element_pool = + g_thread_pool_new ((GFunc) gst_element_call_async_func, NULL, -1, FALSE, + &err); + if (err != NULL) { + g_critical ("could not alloc threadpool %s", err->message); + g_clear_error (&err); + } +} + +static void gst_element_class_init (GstElementClass * klass) { GObjectClass *gobject_class; - GError *err = NULL; gobject_class = (GObjectClass *) klass; @@ -252,14 +266,7 @@ gst_element_class_init (GstElementClass * klass) klass->elementfactory = NULL; - GST_DEBUG ("creating element thread pool"); - gst_element_pool = - g_thread_pool_new ((GFunc) gst_element_call_async_func, NULL, -1, FALSE, - &err); - if (err != NULL) { - g_critical ("could not alloc threadpool %s", err->message); - g_clear_error (&err); - } + gst_element_setup_thread_pool (); } static void @@ -3429,6 +3436,6 @@ _priv_gst_element_cleanup (void) { if (gst_element_pool) { g_thread_pool_free (gst_element_pool, FALSE, TRUE); - gst_element_pool = NULL; + gst_element_setup_thread_pool (); } } -- 2.7.4