From eae6517c84fe5963e92f4d982d3181cc0c25611e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A1s=20P=C5=91cze?= Date: Thu, 17 Feb 2022 03:06:28 +0100 Subject: [PATCH] pipewire: context: create work queue immediately Many modules cannot load without a work queue, neither links nor nodes can be created without it. It's probably better to try to create it immediately when the context is created. This elliminates the need for checking whether `pw_context_get_work_queue` succeeded or not. --- src/pipewire/context.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/pipewire/context.c b/src/pipewire/context.c index d9bde8503..0e136bbce 100644 --- a/src/pipewire/context.c +++ b/src/pipewire/context.c @@ -330,6 +330,12 @@ struct pw_context *pw_context_new(struct pw_loop *main_loop, this->data_system = this->data_loop->system; this->main_loop = main_loop; + this->work_queue = pw_work_queue_new(this->main_loop); + if (this->work_queue == NULL) { + res = -errno; + goto error_free; + } + init_plugin_loader(impl); this->support[n_support++] = SPA_SUPPORT_INIT(SPA_TYPE_INTERFACE_System, this->main_loop->system); @@ -520,8 +526,6 @@ struct pw_loop *pw_context_get_main_loop(struct pw_context *context) SPA_EXPORT struct pw_work_queue *pw_context_get_work_queue(struct pw_context *context) { - if (context->work_queue == NULL) - context->work_queue = pw_work_queue_new(context->main_loop); return context->work_queue; }