mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
module: handle work queue create errors
Handle NULL when creating a work queue instead of crashing. The create can fail when we run out of fds.
This commit is contained in:
parent
bbbc79647f
commit
1f04e911c5
7 changed files with 49 additions and 8 deletions
|
|
@ -671,7 +671,8 @@ static void impl_destroy(struct impl *impl)
|
|||
pw_properties_free(impl->source_props);
|
||||
pw_properties_free(impl->sink_props);
|
||||
|
||||
pw_work_queue_cancel(impl->work, impl, SPA_ID_INVALID);
|
||||
if (impl->work)
|
||||
pw_work_queue_cancel(impl->work, impl, SPA_ID_INVALID);
|
||||
|
||||
for (i = 0; i < impl->info.channels; i++) {
|
||||
if (impl->rec_buffer[i])
|
||||
|
|
@ -787,6 +788,11 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
|
|||
impl->module = module;
|
||||
impl->context = context;
|
||||
impl->work = pw_context_get_work_queue(context);
|
||||
if (impl->work == NULL) {
|
||||
res = -errno;
|
||||
pw_log_error( "can't create work queue: %m");
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (pw_properties_get(props, PW_KEY_NODE_GROUP) == NULL)
|
||||
pw_properties_setf(props, PW_KEY_NODE_GROUP, "echo-cancel-%u", id);
|
||||
|
|
|
|||
|
|
@ -1635,7 +1635,8 @@ static void impl_destroy(struct impl *impl)
|
|||
pw_core_disconnect(impl->core);
|
||||
pw_properties_free(impl->capture_props);
|
||||
pw_properties_free(impl->playback_props);
|
||||
pw_work_queue_cancel(impl->work, impl, SPA_ID_INVALID);
|
||||
if (impl->work)
|
||||
pw_work_queue_cancel(impl->work, impl, SPA_ID_INVALID);
|
||||
graph_free(&impl->graph);
|
||||
free(impl);
|
||||
}
|
||||
|
|
@ -1742,11 +1743,15 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
|
|||
impl->module = module;
|
||||
impl->context = context;
|
||||
impl->work = pw_context_get_work_queue(context);
|
||||
if (impl->work == NULL) {
|
||||
res = -errno;
|
||||
pw_log_error( "can't create work queue: %m");
|
||||
goto error;
|
||||
}
|
||||
impl->rate = 48000;
|
||||
impl->graph.impl = impl;
|
||||
spa_list_init(&impl->ladspa_handle_list);
|
||||
|
||||
|
||||
if (pw_properties_get(props, PW_KEY_NODE_GROUP) == NULL)
|
||||
pw_properties_setf(props, PW_KEY_NODE_GROUP, "filter-chain-%u", id);
|
||||
if (pw_properties_get(props, PW_KEY_NODE_VIRTUAL) == NULL)
|
||||
|
|
|
|||
|
|
@ -500,6 +500,7 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
|
|||
struct pw_context *context = pw_impl_module_get_context(module);
|
||||
struct pw_impl_factory *factory;
|
||||
struct factory_data *data;
|
||||
int res;
|
||||
|
||||
factory = pw_context_create_factory(context,
|
||||
"link-factory",
|
||||
|
|
@ -516,6 +517,13 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
|
|||
data->this = factory;
|
||||
data->module = module;
|
||||
data->work = pw_context_get_work_queue(context);
|
||||
if (data->work == NULL) {
|
||||
res = -errno;
|
||||
pw_log_error( "can't get work queue: %m");
|
||||
pw_impl_factory_destroy(factory);
|
||||
return res;
|
||||
}
|
||||
|
||||
spa_list_init(&data->link_list);
|
||||
|
||||
pw_log_debug("module %p: new", module);
|
||||
|
|
|
|||
|
|
@ -309,7 +309,8 @@ static void impl_destroy(struct impl *impl)
|
|||
pw_core_disconnect(impl->core);
|
||||
pw_properties_free(impl->capture_props);
|
||||
pw_properties_free(impl->playback_props);
|
||||
pw_work_queue_cancel(impl->work, impl, SPA_ID_INVALID);
|
||||
if (impl->work)
|
||||
pw_work_queue_cancel(impl->work, impl, SPA_ID_INVALID);
|
||||
free(impl);
|
||||
}
|
||||
|
||||
|
|
@ -414,6 +415,11 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
|
|||
impl->module = module;
|
||||
impl->context = context;
|
||||
impl->work = pw_context_get_work_queue(context);
|
||||
if (impl->work == NULL) {
|
||||
res = -errno;
|
||||
pw_log_error( "can't get work queue: %m");
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (pw_properties_get(props, PW_KEY_NODE_GROUP) == NULL)
|
||||
pw_properties_setf(props, PW_KEY_NODE_GROUP, "loopback-%u", id);
|
||||
|
|
|
|||
|
|
@ -649,7 +649,8 @@ static void impl_destroy(struct impl *impl)
|
|||
pw_properties_free(impl->stream_props);
|
||||
pw_properties_free(impl->props);
|
||||
|
||||
pw_work_queue_cancel(impl->work, impl, SPA_ID_INVALID);
|
||||
if (impl->work)
|
||||
pw_work_queue_cancel(impl->work, impl, SPA_ID_INVALID);
|
||||
free(impl->buffer);
|
||||
free(impl);
|
||||
}
|
||||
|
|
@ -752,6 +753,11 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
|
|||
impl->module = module;
|
||||
impl->context = context;
|
||||
impl->work = pw_context_get_work_queue(context);
|
||||
if (impl->work == NULL) {
|
||||
res = -errno;
|
||||
pw_log_error( "can't get work queue: %m");
|
||||
goto error;
|
||||
}
|
||||
|
||||
spa_ringbuffer_init(&impl->ring);
|
||||
impl->buffer = calloc(1, RINGBUFFER_SIZE);
|
||||
|
|
|
|||
|
|
@ -172,7 +172,8 @@ static void impl_free(struct impl *impl)
|
|||
if (impl->avahi_poll)
|
||||
pw_avahi_poll_free(impl->avahi_poll);
|
||||
pw_properties_free(impl->properties);
|
||||
pw_work_queue_cancel(impl->work, impl, SPA_ID_INVALID);
|
||||
if (impl->work)
|
||||
pw_work_queue_cancel(impl->work, impl, SPA_ID_INVALID);
|
||||
free(impl);
|
||||
}
|
||||
|
||||
|
|
@ -490,9 +491,12 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
|
|||
|
||||
impl->module = module;
|
||||
impl->context = context;
|
||||
impl->work = pw_context_get_work_queue(context);
|
||||
impl->properties = props;
|
||||
|
||||
impl->work = pw_context_get_work_queue(context);
|
||||
if (impl->work == NULL)
|
||||
goto error_errno;
|
||||
|
||||
pw_impl_module_add_listener(module, &impl->module_listener, &module_events, impl);
|
||||
|
||||
pw_impl_module_update_properties(module, &SPA_DICT_INIT_ARRAY(module_props));
|
||||
|
|
@ -503,6 +507,6 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
|
|||
|
||||
error_errno:
|
||||
res = -errno;
|
||||
free(impl);
|
||||
impl_free(impl);
|
||||
return res;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1098,6 +1098,8 @@ struct pw_impl_link *pw_context_create_link(struct pw_context *context,
|
|||
this->user_data = SPA_PTROFF(impl, sizeof(struct impl), void);
|
||||
|
||||
impl->work = pw_work_queue_new(context->main_loop);
|
||||
if (impl->work == NULL)
|
||||
goto error_work_queue;
|
||||
|
||||
this->context = context;
|
||||
this->properties = properties;
|
||||
|
|
@ -1194,6 +1196,10 @@ error_no_mem:
|
|||
res = -errno;
|
||||
pw_log_debug("alloc failed: %m");
|
||||
goto error_exit;
|
||||
error_work_queue:
|
||||
res = -errno;
|
||||
pw_log_debug("work queue failed: %m");
|
||||
goto error_free;
|
||||
error_no_io:
|
||||
pw_log_debug(NAME" %p: can't set io %d (%s)", this, res, spa_strerror(res));
|
||||
goto error_free;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue