Add parent_id

Add parent_id to globals to make hierarchy of interfaces. We can use
this to group interfaces or to describe the owner.
This commit is contained in:
Wim Taymans 2017-07-18 14:58:14 +02:00
parent 1acba78234
commit a003d1a39f
27 changed files with 151 additions and 99 deletions

View file

@ -49,7 +49,7 @@ bool pipewire__module_init(struct pw_module *module, const char *args)
if ((dir = getenv("SPA_PLUGIN_DIR")) == NULL)
dir = PLUGINDIR;
pw_spa_monitor_load(module->core, dir, argv[0], argv[1], argv[2]);
pw_spa_monitor_load(module->core, module->global, dir, argv[0], argv[1], argv[2]);
pw_free_strv(argv);

View file

@ -53,6 +53,7 @@ static struct pw_node *create_node(struct pw_node_factory *factory,
goto no_properties;
node = pw_spa_node_load(factory->core,
NULL,
NULL,
lib,
factory_name,
@ -81,11 +82,15 @@ static struct pw_node *create_node(struct pw_node_factory *factory,
return NULL;
}
static struct impl *module_new(struct pw_core *core, struct pw_properties *properties)
static bool module_init(struct pw_module *module, struct pw_properties *properties)
{
struct pw_core *core = module->core;
struct impl *impl;
impl = calloc(1, sizeof(struct impl));
if (impl == NULL)
return false;
pw_log_debug("module %p: new", impl);
impl->properties = properties;
@ -97,10 +102,10 @@ static struct impl *module_new(struct pw_core *core, struct pw_properties *prope
spa_list_insert(core->node_factory_list.prev, &impl->this.link);
pw_core_add_global(core, NULL, core->type.node_factory, 0,
NULL, impl, &impl->this.global);
impl->this.global = pw_core_add_global(core, NULL, module->global, core->type.node_factory, 0,
NULL, impl);
return impl;
return true;
}
#if 0
@ -114,6 +119,5 @@ static void module_destroy(struct impl *impl)
bool pipewire__module_init(struct pw_module *module, const char *args)
{
module_new(module->core, NULL);
return true;
return module_init(module, NULL);
}

View file

@ -60,7 +60,7 @@ bool pipewire__module_init(struct pw_module *module, const char *args)
pw_free_strv(prop);
}
pw_spa_node_load(module->core, NULL, argv[0], argv[1], argv[2], props);
pw_spa_node_load(module->core, NULL, module->global, argv[0], argv[1], argv[2], props);
pw_free_strv(argv);

View file

@ -47,6 +47,7 @@ struct impl {
struct pw_spa_monitor this;
struct pw_core *core;
struct pw_global *parent;
void *hnd;
@ -110,7 +111,8 @@ static void add_item(struct pw_spa_monitor *this, struct spa_monitor_item *item)
mitem = calloc(1, sizeof(struct monitor_item));
mitem->id = strdup(id);
mitem->node = pw_spa_node_new(impl->core, NULL, name, false, node_iface, clock_iface, props);
mitem->node = pw_spa_node_new(impl->core, NULL, impl->parent, name,
false, node_iface, clock_iface, props);
spa_list_insert(impl->item_list.prev, &mitem->link);
}
@ -203,6 +205,7 @@ static const struct spa_monitor_callbacks callbacks = {
};
struct pw_spa_monitor *pw_spa_monitor_load(struct pw_core *core,
struct pw_global *parent,
const char *dir,
const char *lib,
const char *factory_name, const char *system_name)
@ -252,6 +255,7 @@ struct pw_spa_monitor *pw_spa_monitor_load(struct pw_core *core,
impl = calloc(1, sizeof(struct impl));
impl->core = core;
impl->parent = parent;
impl->hnd = hnd;
this = &impl->this;

View file

@ -41,6 +41,7 @@ struct pw_spa_monitor {
struct pw_spa_monitor *
pw_spa_monitor_load(struct pw_core *core,
struct pw_global *parent,
const char *dir,
const char *lib,
const char *factory_name, const char *system_name);

View file

@ -387,6 +387,7 @@ static const struct spa_node_callbacks node_callbacks = {
struct pw_node *
pw_spa_node_new(struct pw_core *core,
struct pw_resource *owner,
struct pw_global *parent,
const char *name,
bool async,
struct spa_node *node,
@ -411,7 +412,7 @@ pw_spa_node_new(struct pw_core *core,
node->info->items[i].value);
}
this = pw_node_new(core, owner, name, properties, sizeof(struct impl));
this = pw_node_new(core, owner, parent, name, properties, sizeof(struct impl));
if (this == NULL)
return NULL;
@ -498,6 +499,7 @@ setup_props(struct pw_core *core, struct spa_node *spa_node, struct pw_propertie
struct pw_node *pw_spa_node_load(struct pw_core *core,
struct pw_resource *owner,
struct pw_global *parent,
const char *lib,
const char *factory_name,
const char *name,
@ -567,7 +569,7 @@ struct pw_node *pw_spa_node_load(struct pw_core *core,
}
}
this = pw_spa_node_new(core, owner, name, async, spa_node, spa_clock, properties);
this = pw_spa_node_new(core, owner, parent, name, async, spa_node, spa_clock, properties);
impl->hnd = hnd;
impl->handle = handle;
impl->lib = filename;

View file

@ -30,6 +30,7 @@ extern "C" {
struct pw_node *
pw_spa_node_new(struct pw_core *core,
struct pw_resource *owner, /**< optional owner */
struct pw_global *parent, /**< optional parent */
const char *name,
bool async,
struct spa_node *node,
@ -39,6 +40,7 @@ pw_spa_node_new(struct pw_core *core,
struct pw_node *
pw_spa_node_load(struct pw_core *core,
struct pw_resource *owner, /**< optional owner */
struct pw_global *parent, /**< optional parent */
const char *lib,
const char *factory_name,
const char *name,