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

@ -96,7 +96,6 @@ PW_LOG_TOPIC_STATIC(mod_topic, "mod." NAME);
struct module_roc_sink_data {
struct pw_impl_module *module;
struct pw_work_queue *work;
struct spa_hook module_listener;
struct pw_properties *props;
struct pw_context *module_context;
@ -110,7 +109,6 @@ struct module_roc_sink_data {
struct pw_properties *capture_props;
unsigned int do_disconnect:1;
unsigned int unloading:1;
roc_address local_addr;
roc_address remote_source_addr;
@ -124,20 +122,6 @@ struct module_roc_sink_data {
int remote_repair_port;
};
static void do_unload_module(void *obj, void *d, int res, uint32_t id)
{
struct module_roc_sink_data *data = d;
pw_impl_module_destroy(data->module);
}
static void unload_module(struct module_roc_sink_data *data)
{
if (!data->unloading) {
data->unloading = true;
pw_work_queue_add(data->work, data, 0, do_unload_module, data);
}
}
static void stream_destroy(void *d)
{
struct module_roc_sink_data *data = d;
@ -189,7 +173,7 @@ static void on_core_error(void *d, 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(data);
pw_impl_module_schedule_destroy(data->module);
}
static const struct pw_core_events core_events = {
@ -205,7 +189,7 @@ static void on_stream_state_changed(void *d, enum pw_stream_state old,
switch (state) {
case PW_STREAM_STATE_UNCONNECTED:
pw_log_info("stream disconnected, unloading");
unload_module(data);
pw_impl_module_schedule_destroy(data->module);
break;
case PW_STREAM_STATE_ERROR:
pw_log_error("stream error: %s", error);
@ -227,7 +211,7 @@ static void core_destroy(void *d)
struct module_roc_sink_data *data = d;
spa_hook_remove(&data->core_listener);
data->core = NULL;
unload_module(data);
pw_impl_module_schedule_destroy(data->module);
}
static const struct pw_proxy_events core_proxy_events = {
@ -244,8 +228,6 @@ static void impl_destroy(struct module_roc_sink_data *data)
pw_properties_free(data->capture_props);
pw_properties_free(data->props);
if (data->work)
pw_work_queue_cancel(data->work, data, SPA_ID_INVALID);
if (data->sender)
roc_sender_close(data->sender);
if (data->context)
@ -259,7 +241,6 @@ static void impl_destroy(struct module_roc_sink_data *data)
static void module_destroy(void *d)
{
struct module_roc_sink_data *data = d;
data->unloading = true;
spa_hook_remove(&data->module_listener);
impl_destroy(data);
}
@ -416,7 +397,6 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
data->module = module;
data->module_context = context;
data->work = pw_context_get_work_queue(context);
if ((str = pw_properties_get(props, "sink.name")) != NULL) {
pw_properties_set(capture_props, PW_KEY_NODE_NAME, str);