mixer: remove nodes we created

This commit is contained in:
Wim Taymans 2017-10-17 16:57:26 +02:00
parent c818ab78cf
commit 5a9c4981d8
3 changed files with 33 additions and 1 deletions

View file

@ -42,6 +42,13 @@ struct impl {
void *hnd;
const struct spa_handle_factory *factory;
struct spa_list node_list;
};
struct node_data {
struct spa_list link;
struct pw_node *node;
};
static const struct spa_handle_factory *find_factory(struct impl *impl)
@ -97,6 +104,7 @@ static struct pw_node *make_node(struct impl *impl)
struct pw_node *node;
const struct spa_support *support;
uint32_t n_support;
struct node_data *nd;
support = pw_core_get_support(impl->core, &n_support);
@ -114,7 +122,12 @@ static struct pw_node *make_node(struct impl *impl)
spa_node = iface;
node = pw_spa_node_new(impl->core, NULL, pw_module_get_global(impl->module),
"audiomixer", PW_SPA_NODE_FLAG_ACTIVATE, spa_node, handle, NULL, 0);
"audiomixer", PW_SPA_NODE_FLAG_ACTIVATE, spa_node, handle, NULL,
sizeof(struct node_data));
nd = pw_spa_node_get_user_data(node);
nd->node = node;
spa_list_append(&impl->node_list, &nd->link);
return node;
@ -169,9 +182,13 @@ static bool on_global(void *data, struct pw_global *global)
static void module_destroy(void *data)
{
struct impl *impl = data;
struct node_data *nd, *t;
spa_hook_remove(&impl->module_listener);
spa_list_for_each_safe(nd, t, &impl->node_list, link)
pw_node_destroy(nd->node);
if (impl->properties)
pw_properties_free(impl->properties);
@ -198,6 +215,8 @@ static bool module_init(struct pw_module *module, struct pw_properties *properti
impl->factory = find_factory(impl);
spa_list_init(&impl->node_list);
pw_core_for_each_global(core, on_global, impl);
pw_module_add_listener(module, &impl->module_listener, &module_events, impl);

View file

@ -50,6 +50,8 @@ struct impl {
char *factory_name;
struct spa_hook node_listener;
void *user_data;
};
static void pw_spa_node_destroy(void *data)
@ -130,6 +132,9 @@ pw_spa_node_new(struct pw_core *core,
impl->flags = flags;
impl->async_init = flags & PW_SPA_NODE_FLAG_ASYNC;
if (user_data_size > 0)
impl->user_data = SPA_MEMBER(impl, sizeof(struct impl), void);
pw_node_add_listener(this, &impl->node_listener, &node_events, impl);
pw_node_set_implementation(this, impl->node);
@ -139,6 +144,12 @@ pw_spa_node_new(struct pw_core *core,
return this;
}
void *pw_spa_node_get_user_data(struct pw_node *node)
{
struct impl *impl = node->user_data;
return impl->user_data;
}
static int
setup_props(struct pw_core *core, struct spa_node *spa_node, struct pw_properties *pw_props)
{

View file

@ -57,6 +57,8 @@ pw_spa_node_load(struct pw_core *core,
struct pw_properties *properties,
size_t user_data_size);
void *pw_spa_node_get_user_data(struct pw_node *node);
#ifdef __cplusplus
}
#endif