thread: deprecate pw_thread_utils_set()

Setting a global thread-utils is not a good idea, especially
when multiple contexts will register their own interface.

Instead, set the thread-utils as a context object and use this to
configure the data loop in the context.

In JACK we need a per context implementation of the interface so that
we can find the context specific thread-utils.

See #2252
This commit is contained in:
Wim Taymans 2022-03-30 20:31:42 +02:00
parent f3466f8cd6
commit f0424c0b99
6 changed files with 59 additions and 33 deletions

View file

@ -464,8 +464,7 @@ finish:
static void module_destroy(void *data)
{
struct impl *impl = data;
pw_thread_utils_set(NULL);
pw_context_set_object(impl->context, SPA_TYPE_INTERFACE_ThreadUtils, NULL);
spa_hook_remove(&impl->module_listener);
#ifdef HAVE_DBUS
@ -931,7 +930,9 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
SPA_TYPE_INTERFACE_ThreadUtils,
SPA_VERSION_THREAD_UTILS,
&impl_thread_utils, impl);
pw_thread_utils_set(&impl->thread_utils);
pw_context_set_object(context, SPA_TYPE_INTERFACE_ThreadUtils,
&impl->thread_utils);
pw_impl_module_add_listener(module, &impl->module_listener, &module_events, impl);