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:
Wim Taymans 2021-06-18 16:29:23 +02:00
parent bbbc79647f
commit 1f04e911c5
7 changed files with 49 additions and 8 deletions

View file

@ -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);