pipewire: use newly added function for deferred module destroy

Use the newly introduced `pw_impl_module_schedule_destroy()`
for deferred module destroy in all modules except
module-example-{sink,source}.
This commit is contained in:
Barnabás Pőcze 2022-02-17 03:34:05 +01:00
parent a13e7ef091
commit 45bd8532eb
9 changed files with 25 additions and 203 deletions

View file

@ -81,7 +81,6 @@ struct impl {
struct pw_context *context;
struct pw_impl_module *module;
struct pw_work_queue *work;
struct spa_hook module_listener;
@ -100,22 +99,8 @@ struct impl {
struct spa_audio_info_raw playback_info;
unsigned int do_disconnect:1;
unsigned int unloading:1;
};
static void do_unload_module(void *obj, void *data, int res, uint32_t id)
{
struct impl *impl = data;
pw_impl_module_destroy(impl->module);
}
static void unload_module(struct impl *impl)
{
if (!impl->unloading) {
impl->unloading = true;
pw_work_queue_add(impl->work, impl, 0, do_unload_module, impl);
}
}
static void capture_destroy(void *d)
{
struct impl *impl = d;
@ -312,7 +297,7 @@ static void core_error(void *data, uint32_t id, int seq, int res, const char *me
id, seq, res, spa_strerror(res), message);
if (id == PW_ID_CORE && res == -EPIPE)
unload_module(impl);
pw_impl_module_schedule_destroy(impl->module);
}
static const struct pw_core_events core_events = {
@ -325,7 +310,7 @@ static void core_destroy(void *d)
struct impl *impl = d;
spa_hook_remove(&impl->core_listener);
impl->core = NULL;
unload_module(impl);
pw_impl_module_schedule_destroy(impl->module);
}
static const struct pw_proxy_events core_proxy_events = {
@ -342,15 +327,12 @@ static void impl_destroy(struct impl *impl)
pw_core_disconnect(impl->core);
pw_properties_free(impl->capture_props);
pw_properties_free(impl->playback_props);
if (impl->work)
pw_work_queue_cancel(impl->work, impl, SPA_ID_INVALID);
free(impl);
}
static void module_destroy(void *data)
{
struct impl *impl = data;
impl->unloading = true;
spa_hook_remove(&impl->module_listener);
impl_destroy(impl);
}
@ -447,7 +429,6 @@ 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 (pw_properties_get(props, PW_KEY_NODE_GROUP) == NULL)
pw_properties_setf(props, PW_KEY_NODE_GROUP, "loopback-%u", id);