mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-04 13:30:12 -05:00
pulse-server: handle if the module is destroyed while loading
Create a new event for modules ('destroy') which is emitted from
`module_free()`. It is used by the module loading logic, to handle
when a module is destroyed without properly loading first.
This commit is contained in:
parent
bd5a715200
commit
0e75b3fa0f
3 changed files with 10 additions and 0 deletions
|
|
@ -92,6 +92,8 @@ void module_free(struct module *module)
|
||||||
{
|
{
|
||||||
struct impl *impl = module->impl;
|
struct impl *impl = module->impl;
|
||||||
|
|
||||||
|
module_emit_destroy(module);
|
||||||
|
|
||||||
if (module->idx != SPA_ID_INVALID)
|
if (module->idx != SPA_ID_INVALID)
|
||||||
pw_map_remove(&impl->modules, module->idx & INDEX_MASK);
|
pw_map_remove(&impl->modules, module->idx & INDEX_MASK);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,7 @@ struct module_events {
|
||||||
uint32_t version;
|
uint32_t version;
|
||||||
|
|
||||||
void (*loaded) (void *data, int result);
|
void (*loaded) (void *data, int result);
|
||||||
|
void (*destroy) (void *data);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct module_methods {
|
struct module_methods {
|
||||||
|
|
@ -68,6 +69,7 @@ struct module {
|
||||||
};
|
};
|
||||||
|
|
||||||
#define module_emit_loaded(m,r) spa_hook_list_call(&m->listener_list, struct module_events, loaded, 0, r)
|
#define module_emit_loaded(m,r) spa_hook_list_call(&m->listener_list, struct module_events, loaded, 0, r)
|
||||||
|
#define module_emit_destroy(m) spa_hook_list_call(&(m)->listener_list, struct module_events, destroy, 0)
|
||||||
|
|
||||||
struct module *module_create(struct client *client, const char *name, const char *args);
|
struct module *module_create(struct client *client, const char *name, const char *args);
|
||||||
void module_free(struct module *module);
|
void module_free(struct module *module);
|
||||||
|
|
|
||||||
|
|
@ -4666,6 +4666,11 @@ static void on_module_loaded(void *data, int result)
|
||||||
free(pm);
|
free(pm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void on_module_destroy(void *data)
|
||||||
|
{
|
||||||
|
on_module_loaded(data, -ECANCELED);
|
||||||
|
}
|
||||||
|
|
||||||
static void on_client_disconnect(void *data)
|
static void on_client_disconnect(void *data)
|
||||||
{
|
{
|
||||||
struct pending_module *pm = data;
|
struct pending_module *pm = data;
|
||||||
|
|
@ -4679,6 +4684,7 @@ static int do_load_module(struct client *client, uint32_t command, uint32_t tag,
|
||||||
static const struct module_events module_events = {
|
static const struct module_events module_events = {
|
||||||
VERSION_MODULE_EVENTS,
|
VERSION_MODULE_EVENTS,
|
||||||
.loaded = on_module_loaded,
|
.loaded = on_module_loaded,
|
||||||
|
.destroy = on_module_destroy,
|
||||||
};
|
};
|
||||||
static const struct client_events client_events = {
|
static const struct client_events client_events = {
|
||||||
VERSION_CLIENT_EVENTS,
|
VERSION_CLIENT_EVENTS,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue