mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-01 22:58:50 -04:00
factory: improve registration
This commit is contained in:
parent
0173180e78
commit
8c4bb3a104
2 changed files with 9 additions and 3 deletions
|
|
@ -60,8 +60,11 @@ void pw_factory_destroy(struct pw_factory *factory)
|
|||
pw_log_debug("factory %p: destroy", factory);
|
||||
spa_hook_list_call(&factory->listener_list, struct pw_factory_events, destroy);
|
||||
|
||||
if (factory->global) {
|
||||
if (factory->registered)
|
||||
spa_list_remove(&factory->link);
|
||||
|
||||
if (factory->global) {
|
||||
spa_hook_remove(&factory->global_listener);
|
||||
pw_global_destroy(factory->global);
|
||||
}
|
||||
if (factory->info.name)
|
||||
|
|
@ -137,8 +140,6 @@ int pw_factory_register(struct pw_factory *factory,
|
|||
{
|
||||
struct pw_core *core = factory->core;
|
||||
|
||||
spa_list_append(&core->factory_list, &factory->link);
|
||||
|
||||
if (properties == NULL)
|
||||
properties = pw_properties_new(NULL, NULL);
|
||||
if (properties == NULL)
|
||||
|
|
@ -149,6 +150,9 @@ int pw_factory_register(struct pw_factory *factory,
|
|||
spa_type_map_get_type(core->type.map, factory->info.type));
|
||||
pw_properties_setf(properties, "factory.type.version", "%d", factory->info.version);
|
||||
|
||||
spa_list_append(&core->factory_list, &factory->link);
|
||||
factory->registered = true;
|
||||
|
||||
factory->global = pw_global_new(core,
|
||||
core->type.factory, PW_VERSION_FACTORY,
|
||||
properties,
|
||||
|
|
@ -156,6 +160,7 @@ int pw_factory_register(struct pw_factory *factory,
|
|||
if (factory->global == NULL)
|
||||
return -ENOMEM;
|
||||
|
||||
|
||||
pw_global_add_listener(factory->global, &factory->global_listener, &global_events, factory);
|
||||
pw_global_register(factory->global, owner, parent);
|
||||
factory->info.id = factory->global->id;
|
||||
|
|
|
|||
|
|
@ -407,6 +407,7 @@ struct pw_factory {
|
|||
struct spa_list link; /**< link in core node_factory_list */
|
||||
struct pw_global *global; /**< global for this factory */
|
||||
struct spa_hook global_listener;
|
||||
bool registered;
|
||||
|
||||
struct pw_factory_info info; /**< introspectable factory info */
|
||||
struct pw_properties *properties; /**< properties of the factory */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue