mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-02 09:01:50 -05:00
global: add properties
Add properties to global objects to make it easier to select what nodes and objects to bind too. They can also be used to implement permissions on the globals based on properties. Add more error handling in _register. Make more functions return a result code. Make a separate pw_module_register, like all other objects.
This commit is contained in:
parent
47dd97049c
commit
c593d868fb
45 changed files with 295 additions and 149 deletions
|
|
@ -536,7 +536,7 @@ static void make_node(struct data *data)
|
|||
data->node = pw_node_new(data->core, "SDL-sink", props, 0);
|
||||
data->impl_node = impl_node;
|
||||
pw_node_set_implementation(data->node, &data->impl_node);
|
||||
pw_node_register(data->node, NULL, NULL);
|
||||
pw_node_register(data->node, NULL, NULL, NULL);
|
||||
pw_node_set_active(data->node, true);
|
||||
|
||||
pw_remote_export(data->remote, data->node);
|
||||
|
|
|
|||
|
|
@ -516,7 +516,7 @@ static void make_node(struct data *data)
|
|||
data->impl_node = impl_node;
|
||||
pw_node_set_implementation(data->node, &data->impl_node);
|
||||
|
||||
pw_node_register(data->node, NULL, NULL);
|
||||
pw_node_register(data->node, NULL, NULL, NULL);
|
||||
pw_node_set_active(data->node, true);
|
||||
|
||||
pw_remote_export(data->remote, data->node);
|
||||
|
|
|
|||
|
|
@ -480,7 +480,7 @@ static void make_nodes(struct data *data)
|
|||
data->impl_node = impl_node;
|
||||
pw_node_set_implementation(data->node, &data->impl_node);
|
||||
|
||||
pw_node_register(data->node, NULL, NULL);
|
||||
pw_node_register(data->node, NULL, NULL, NULL);
|
||||
|
||||
factory = pw_core_find_factory(data->core, "spa-node-factory");
|
||||
props = pw_properties_new("spa.library.name", "v4l2/libspa-v4l2",
|
||||
|
|
@ -498,7 +498,7 @@ static void make_nodes(struct data *data)
|
|||
NULL,
|
||||
NULL,
|
||||
0);
|
||||
pw_link_register(data->link, NULL, NULL);
|
||||
pw_link_register(data->link, NULL, NULL, NULL);
|
||||
|
||||
pw_node_set_active(data->node, true);
|
||||
pw_node_set_active(data->v4l2, true);
|
||||
|
|
|
|||
|
|
@ -366,7 +366,8 @@ static const struct pw_node_proxy_events node_events = {
|
|||
|
||||
|
||||
static void registry_event_global(void *data, uint32_t id, uint32_t parent_id, uint32_t permissions,
|
||||
uint32_t type, uint32_t version)
|
||||
uint32_t type, uint32_t version,
|
||||
const struct spa_dict *props)
|
||||
{
|
||||
struct registry_data *rd = data;
|
||||
GstPipeWireDeviceProvider *self = rd->self;
|
||||
|
|
|
|||
|
|
@ -226,7 +226,7 @@ static void try_link_port(struct pw_node *node, struct pw_port *port, struct nod
|
|||
pw_link_add_listener(link, &ld->link_listener, &link_events, ld);
|
||||
|
||||
spa_list_append(&info->links, &ld->l);
|
||||
pw_link_register(link, NULL, pw_module_get_global(impl->module));
|
||||
pw_link_register(link, NULL, pw_module_get_global(impl->module), NULL);
|
||||
|
||||
try_link_controls(impl, port, target);
|
||||
|
||||
|
|
|
|||
|
|
@ -133,7 +133,7 @@ static int module_init(struct pw_module *module, struct pw_properties *propertie
|
|||
|
||||
pw_protocol_native_ext_client_node_init(core);
|
||||
|
||||
pw_factory_register(factory, NULL, pw_module_get_global(module));
|
||||
pw_factory_register(factory, NULL, pw_module_get_global(module), NULL);
|
||||
|
||||
pw_module_add_listener(module, &data->module_listener, &module_events, data);
|
||||
|
||||
|
|
|
|||
|
|
@ -813,7 +813,7 @@ handle_connect_name_ports(struct client *client)
|
|||
ld->in_port = in_port;
|
||||
spa_list_append(&impl->link_list, &ld->link_link);
|
||||
pw_link_add_listener(link, &ld->link_listener, &link_events, ld);
|
||||
pw_link_register(link, NULL, pw_module_get_global(impl->module));
|
||||
pw_link_register(link, NULL, pw_module_get_global(impl->module), NULL);
|
||||
|
||||
notify_clients(impl, jack_notify_PortConnectCallback, false, "", src_id, dst_id);
|
||||
|
||||
|
|
@ -1060,7 +1060,7 @@ static struct client *client_new(struct impl *impl, int fd)
|
|||
|
||||
pw_client_add_listener(client, &this->client_listener, &client_events, this);
|
||||
|
||||
pw_client_register(client, NULL, pw_module_get_global(impl->module));
|
||||
pw_client_register(client, NULL, pw_module_get_global(impl->module), NULL);
|
||||
|
||||
pw_log_debug("module-jack %p: added new client", impl);
|
||||
|
||||
|
|
@ -1339,7 +1339,7 @@ static int on_global(void *data, struct pw_global *global)
|
|||
pw_log_debug("module-jack %p: using buffer_size %d", impl,
|
||||
impl->server.engine_control->buffer_size);
|
||||
|
||||
pw_link_register(impl->sink_link, NULL, pw_module_get_global(impl->module));
|
||||
pw_link_register(impl->sink_link, NULL, pw_module_get_global(impl->module), NULL);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -944,7 +944,7 @@ struct pw_jack_node *pw_jack_node_new(struct pw_core *core,
|
|||
jack_connection_manager_init_ref_num(conn, ref_num);
|
||||
jack_graph_manager_next_stop(mgr);
|
||||
|
||||
pw_node_register(node, NULL, parent);
|
||||
pw_node_register(node, NULL, parent, NULL);
|
||||
pw_node_set_active(node, true);
|
||||
|
||||
return this;
|
||||
|
|
@ -1041,7 +1041,7 @@ pw_jack_driver_new(struct pw_core *core,
|
|||
this->driver_out = alloc_port(this, PW_DIRECTION_OUTPUT, 0);
|
||||
pw_port_add(this->driver_out->port, node);
|
||||
}
|
||||
pw_node_register(node, NULL, parent);
|
||||
pw_node_register(node, NULL, parent, NULL);
|
||||
pw_node_set_active(node, true);
|
||||
|
||||
return this;
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ static void *create_object(void *_data,
|
|||
if (link == NULL)
|
||||
goto no_mem;
|
||||
|
||||
pw_link_register(link, client, pw_client_get_global(client));
|
||||
pw_link_register(link, client, pw_client_get_global(client), NULL);
|
||||
|
||||
res = pw_global_bind(pw_link_get_global(link), client, PW_PERM_RWX, PW_VERSION_LINK, new_id);
|
||||
if (res < 0)
|
||||
|
|
@ -206,7 +206,7 @@ static int module_init(struct pw_module *module, struct pw_properties *propertie
|
|||
&impl_factory,
|
||||
data);
|
||||
|
||||
pw_factory_register(factory, NULL, pw_module_get_global(module));
|
||||
pw_factory_register(factory, NULL, pw_module_get_global(module), NULL);
|
||||
|
||||
pw_module_add_listener(module, &data->module_listener, &module_events, data);
|
||||
|
||||
|
|
|
|||
|
|
@ -175,7 +175,7 @@ static int on_global(void *data, struct pw_global *global)
|
|||
NULL,
|
||||
pw_properties_new(PW_LINK_PROP_PASSIVE, "true", NULL),
|
||||
&error, 0);
|
||||
pw_link_register(link, NULL, pw_module_get_global(impl->module));
|
||||
pw_link_register(link, NULL, pw_module_get_global(impl->module), NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -334,7 +334,7 @@ static struct pw_client *client_new(struct server *s, int fd)
|
|||
spa_list_append(&s->this.client_list, &client->protocol_link);
|
||||
|
||||
pw_client_add_listener(client, &this->client_listener, &client_events, this);
|
||||
pw_client_register(client, NULL, pw_module_get_global(pd->module));
|
||||
pw_client_register(client, NULL, pw_module_get_global(pd->module), NULL);
|
||||
|
||||
pw_global_bind(pw_core_get_global(core), client, PW_PERM_RWX, PW_VERSION_CORE, 0);
|
||||
|
||||
|
|
|
|||
|
|
@ -488,19 +488,31 @@ static int core_demarshal_update_types_server(void *object, void *data, size_t s
|
|||
}
|
||||
|
||||
static void registry_marshal_global(void *object, uint32_t id, uint32_t parent_id, uint32_t permissions,
|
||||
uint32_t type, uint32_t version)
|
||||
uint32_t type, uint32_t version, const struct spa_dict *props)
|
||||
{
|
||||
struct pw_resource *resource = object;
|
||||
struct spa_pod_builder *b;
|
||||
uint32_t i, n_items;
|
||||
|
||||
b = pw_protocol_native_begin_resource(resource, PW_REGISTRY_PROXY_EVENT_GLOBAL);
|
||||
|
||||
spa_pod_builder_struct(b,
|
||||
"i", id,
|
||||
"i", parent_id,
|
||||
"i", permissions,
|
||||
"I", type,
|
||||
"i", version);
|
||||
n_items = props ? props->n_items : 0;
|
||||
|
||||
spa_pod_builder_add(b,
|
||||
"[",
|
||||
"i", id,
|
||||
"i", parent_id,
|
||||
"i", permissions,
|
||||
"I", type,
|
||||
"i", version,
|
||||
"i", n_items, NULL);
|
||||
|
||||
for (i = 0; i < n_items; i++) {
|
||||
spa_pod_builder_add(b,
|
||||
"s", props->items[i].key,
|
||||
"s", props->items[i].value, NULL);
|
||||
}
|
||||
spa_pod_builder_add(b, "]", NULL);
|
||||
|
||||
pw_protocol_native_end_resource(resource, b);
|
||||
}
|
||||
|
|
@ -874,7 +886,8 @@ static int registry_demarshal_global(void *object, void *data, size_t size)
|
|||
{
|
||||
struct pw_proxy *proxy = object;
|
||||
struct spa_pod_parser prs;
|
||||
uint32_t id, parent_id, permissions, type, version;
|
||||
uint32_t id, parent_id, permissions, type, version, i;
|
||||
struct spa_dict props;
|
||||
|
||||
spa_pod_parser_init(&prs, data, size, 0);
|
||||
if (spa_pod_parser_get(&prs,
|
||||
|
|
@ -883,10 +896,21 @@ static int registry_demarshal_global(void *object, void *data, size_t size)
|
|||
"i", &parent_id,
|
||||
"i", &permissions,
|
||||
"I", &type,
|
||||
"i", &version, NULL) < 0)
|
||||
"i", &version,
|
||||
"i", &props.n_items, NULL) < 0)
|
||||
return -EINVAL;
|
||||
|
||||
pw_proxy_notify(proxy, struct pw_registry_proxy_events, global, id, parent_id, permissions, type, version);
|
||||
props.items = alloca(props.n_items * sizeof(struct spa_dict_item));
|
||||
for (i = 0; i < props.n_items; i++) {
|
||||
if (spa_pod_parser_get(&prs,
|
||||
"s", &props.items[i].key,
|
||||
"s", &props.items[i].value, NULL) < 0)
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
pw_proxy_notify(proxy, struct pw_registry_proxy_events,
|
||||
global, id, parent_id, permissions, type, version,
|
||||
props.n_items > 0 ? &props : NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -176,7 +176,7 @@ static int module_init(struct pw_module *module, struct pw_properties *propertie
|
|||
pw_log_debug("module %p: new", module);
|
||||
pw_module_add_listener(module, &data->module_listener, &module_events, data);
|
||||
|
||||
pw_factory_register(factory, NULL, pw_module_get_global(module));
|
||||
pw_factory_register(factory, NULL, pw_module_get_global(module), NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ static void pw_spa_node_destroy(void *data)
|
|||
static void complete_init(struct impl *impl)
|
||||
{
|
||||
struct pw_node *this = impl->this;
|
||||
pw_node_register(this, impl->owner, impl->parent);
|
||||
pw_node_register(this, impl->owner, impl->parent, NULL);
|
||||
if (impl->flags & PW_SPA_NODE_FLAG_ACTIVATE)
|
||||
pw_node_set_active(this, true);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -201,21 +201,28 @@ struct pw_client *pw_client_new(struct pw_core *core,
|
|||
return this;
|
||||
}
|
||||
|
||||
void pw_client_register(struct pw_client *client,
|
||||
struct pw_client *owner,
|
||||
struct pw_global *parent)
|
||||
int pw_client_register(struct pw_client *client,
|
||||
struct pw_client *owner,
|
||||
struct pw_global *parent,
|
||||
struct pw_properties *properties)
|
||||
{
|
||||
struct pw_core *core = client->core;
|
||||
|
||||
pw_log_debug("client %p: register parent %d", client, parent ? parent->id : SPA_ID_INVALID);
|
||||
|
||||
spa_list_append(&core->client_list, &client->link);
|
||||
|
||||
client->global = pw_global_new(core, core->type.client, PW_VERSION_CLIENT,
|
||||
client_bind_func, client);
|
||||
if (client->global != NULL) {
|
||||
pw_global_register(client->global, owner, parent);
|
||||
client->info.id = client->global->id;
|
||||
}
|
||||
client->global = pw_global_new(core,
|
||||
core->type.client, PW_VERSION_CLIENT,
|
||||
properties,
|
||||
client_bind_func, client);
|
||||
if (client->global == NULL)
|
||||
return -ENOMEM;
|
||||
|
||||
pw_global_register(client->global, owner, parent);
|
||||
client->info.id = client->global->id;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct pw_core *pw_client_get_core(struct pw_client *client)
|
||||
|
|
@ -325,7 +332,7 @@ const struct pw_client_info *pw_client_get_info(struct pw_client *client)
|
|||
*
|
||||
* \memberof pw_client
|
||||
*/
|
||||
void pw_client_update_properties(struct pw_client *client, const struct spa_dict *dict)
|
||||
int pw_client_update_properties(struct pw_client *client, const struct spa_dict *dict)
|
||||
{
|
||||
struct pw_resource *resource;
|
||||
|
||||
|
|
@ -350,6 +357,8 @@ void pw_client_update_properties(struct pw_client *client, const struct spa_dict
|
|||
pw_client_resource_info(resource, &client->info);
|
||||
|
||||
client->info.change_mask = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct permissions_update {
|
||||
|
|
@ -410,7 +419,7 @@ static uint32_t parse_mask(const char *str)
|
|||
return mask;
|
||||
}
|
||||
|
||||
void pw_client_update_permissions(struct pw_client *client, const struct spa_dict *dict)
|
||||
int pw_client_update_permissions(struct pw_client *client, const struct spa_dict *dict)
|
||||
{
|
||||
struct impl *impl = SPA_CONTAINER_OF(client, struct impl, this);
|
||||
int i;
|
||||
|
|
@ -452,6 +461,7 @@ void pw_client_update_permissions(struct pw_client *client, const struct spa_dic
|
|||
pw_core_for_each_global(client->core, do_permissions, &update);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void pw_client_set_busy(struct pw_client *client, bool busy)
|
||||
|
|
|
|||
|
|
@ -131,9 +131,10 @@ pw_client_new(struct pw_core *core, /**< the core object */
|
|||
void pw_client_destroy(struct pw_client *client);
|
||||
|
||||
/** Finish configuration and register a client */
|
||||
void pw_client_register(struct pw_client *client, /**< the client to register */
|
||||
struct pw_client *owner, /**< optional owner */
|
||||
struct pw_global *parent /**< the client parent */);
|
||||
int pw_client_register(struct pw_client *client, /**< the client to register */
|
||||
struct pw_client *owner, /**< optional owner */
|
||||
struct pw_global *parent, /**< the client parent */
|
||||
struct pw_properties *properties/**< extra properties */);
|
||||
|
||||
/** Get the client user data */
|
||||
void *pw_client_get_user_data(struct pw_client *client);
|
||||
|
|
@ -142,10 +143,10 @@ void *pw_client_get_user_data(struct pw_client *client);
|
|||
const struct pw_client_info *pw_client_get_info(struct pw_client *client);
|
||||
|
||||
/** Update the client properties */
|
||||
void pw_client_update_properties(struct pw_client *client, const struct spa_dict *dict);
|
||||
int pw_client_update_properties(struct pw_client *client, const struct spa_dict *dict);
|
||||
|
||||
/** Update the client permissions */
|
||||
void pw_client_update_permissions(struct pw_client *client, const struct spa_dict *dict);
|
||||
int pw_client_update_permissions(struct pw_client *client, const struct spa_dict *dict);
|
||||
|
||||
/** Get the client properties */
|
||||
const struct pw_properties *pw_client_get_properties(struct pw_client *client);
|
||||
|
|
|
|||
|
|
@ -97,6 +97,7 @@ execute_command_module_load(struct pw_command *command, struct pw_core *core, ch
|
|||
asprintf(err, "could not load module \"%s\"", command->args[1]);
|
||||
return -ENOMEM;
|
||||
}
|
||||
pw_module_register(module, NULL, NULL, NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -157,7 +157,9 @@ static void core_get_registry(void *object, uint32_t version, uint32_t new_id)
|
|||
global->parent->id,
|
||||
permissions,
|
||||
global->type,
|
||||
global->version);
|
||||
global->version,
|
||||
global->properties ?
|
||||
&global->properties->dict : NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -391,6 +393,7 @@ struct pw_core *pw_core_new(struct pw_loop *main_loop, struct pw_properties *pro
|
|||
this->global = pw_global_new(this,
|
||||
this->type.core,
|
||||
PW_VERSION_CORE,
|
||||
NULL,
|
||||
core_bind_func,
|
||||
this);
|
||||
if (this->global != NULL) {
|
||||
|
|
@ -502,7 +505,7 @@ const struct pw_properties *pw_core_get_properties(struct pw_core *core)
|
|||
*
|
||||
* \memberof pw_core
|
||||
*/
|
||||
void pw_core_update_properties(struct pw_core *core, const struct spa_dict *dict)
|
||||
int pw_core_update_properties(struct pw_core *core, const struct spa_dict *dict)
|
||||
{
|
||||
struct pw_resource *resource;
|
||||
uint32_t i;
|
||||
|
|
@ -520,6 +523,8 @@ void pw_core_update_properties(struct pw_core *core, const struct spa_dict *dict
|
|||
pw_core_resource_info(resource, &core->info);
|
||||
|
||||
core->info.change_mask = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pw_core_for_each_global(struct pw_core *core,
|
||||
|
|
|
|||
|
|
@ -143,7 +143,7 @@ struct pw_global *pw_core_get_global(struct pw_core *core);
|
|||
const struct pw_properties *pw_core_get_properties(struct pw_core *core);
|
||||
|
||||
/** Update the core properties */
|
||||
void pw_core_update_properties(struct pw_core *core, const struct spa_dict *dict);
|
||||
int pw_core_update_properties(struct pw_core *core, const struct spa_dict *dict);
|
||||
|
||||
/** Get the core support objects */
|
||||
const struct spa_support *pw_core_get_support(struct pw_core *core, uint32_t *n_support);
|
||||
|
|
|
|||
|
|
@ -116,18 +116,26 @@ factory_bind_func(struct pw_global *global,
|
|||
return -ENOMEM;
|
||||
}
|
||||
|
||||
void pw_factory_register(struct pw_factory *factory,
|
||||
int pw_factory_register(struct pw_factory *factory,
|
||||
struct pw_client *owner,
|
||||
struct pw_global *parent)
|
||||
struct pw_global *parent,
|
||||
struct pw_properties *properties)
|
||||
{
|
||||
struct pw_core *core = factory->core;
|
||||
|
||||
spa_list_append(&core->factory_list, &factory->link);
|
||||
|
||||
factory->global = pw_global_new(core,
|
||||
core->type.factory, 0, factory_bind_func, factory);
|
||||
if (factory->global != NULL) {
|
||||
pw_global_register(factory->global, owner, parent);
|
||||
factory->info.id = factory->global->id;
|
||||
}
|
||||
core->type.factory, PW_VERSION_FACTORY,
|
||||
properties,
|
||||
factory_bind_func, factory);
|
||||
if (factory->global == NULL)
|
||||
return -ENOMEM;
|
||||
|
||||
pw_global_register(factory->global, owner, parent);
|
||||
factory->info.id = factory->global->id;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void *pw_factory_get_user_data(struct pw_factory *factory)
|
||||
|
|
|
|||
|
|
@ -70,9 +70,10 @@ struct pw_factory *pw_factory_new(struct pw_core *core,
|
|||
struct pw_properties *properties,
|
||||
size_t user_data_size);
|
||||
|
||||
void pw_factory_register(struct pw_factory *factory,
|
||||
struct pw_client *owner,
|
||||
struct pw_global *parent);
|
||||
int pw_factory_register(struct pw_factory *factory,
|
||||
struct pw_client *owner,
|
||||
struct pw_global *parent,
|
||||
struct pw_properties *properties);
|
||||
|
||||
void pw_factory_destroy(struct pw_factory *factory);
|
||||
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ uint32_t pw_global_get_permissions(struct pw_global *global, struct pw_client *c
|
|||
* \param core a core object
|
||||
* \param type the type of the global
|
||||
* \param version the version of the type
|
||||
* \param properties extra properties
|
||||
* \param bind a function to bind to this global
|
||||
* \param object the associated object
|
||||
* \return a result global
|
||||
|
|
@ -63,6 +64,7 @@ struct pw_global *
|
|||
pw_global_new(struct pw_core *core,
|
||||
uint32_t type,
|
||||
uint32_t version,
|
||||
struct pw_properties *properties,
|
||||
pw_bind_func_t bind,
|
||||
void *object)
|
||||
{
|
||||
|
|
@ -80,6 +82,7 @@ pw_global_new(struct pw_core *core,
|
|||
this->version = version;
|
||||
this->bind = bind;
|
||||
this->object = object;
|
||||
this->properties = properties;
|
||||
|
||||
pw_log_debug("global %p: new %s", this,
|
||||
spa_type_map_get_type(core->type.map, this->type));
|
||||
|
|
@ -129,7 +132,9 @@ pw_global_register(struct pw_global *global,
|
|||
global->parent->id,
|
||||
permissions,
|
||||
global->type,
|
||||
global->version);
|
||||
global->version,
|
||||
global->properties ?
|
||||
&global->properties->dict : NULL);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -159,6 +164,11 @@ uint32_t pw_global_get_version(struct pw_global *global)
|
|||
return global->version;
|
||||
}
|
||||
|
||||
const struct pw_properties *pw_global_get_properties(struct pw_global *global)
|
||||
{
|
||||
return global->properties;
|
||||
}
|
||||
|
||||
void * pw_global_get_object(struct pw_global *global)
|
||||
{
|
||||
return global->object;
|
||||
|
|
@ -237,6 +247,9 @@ void pw_global_destroy(struct pw_global *global)
|
|||
spa_list_remove(&global->link);
|
||||
spa_hook_list_call(&core->listener_list, struct pw_core_events, global_removed, global);
|
||||
|
||||
if (global->properties)
|
||||
pw_properties_free(global->properties);
|
||||
|
||||
pw_log_debug("global %p: free", global);
|
||||
free(global);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ struct pw_global;
|
|||
|
||||
#include <pipewire/core.h>
|
||||
#include <pipewire/client.h>
|
||||
#include <pipewire/properties.h>
|
||||
|
||||
/** The function to let a client bind to a global */
|
||||
typedef int (*pw_bind_func_t) (struct pw_global *global, /**< the global to bind */
|
||||
|
|
@ -63,11 +64,12 @@ typedef int (*pw_bind_func_t) (struct pw_global *global, /**< the global to bind
|
|||
|
||||
/** Create a new global object */
|
||||
struct pw_global *
|
||||
pw_global_new(struct pw_core *core,
|
||||
uint32_t type,
|
||||
uint32_t version,
|
||||
pw_bind_func_t bind,
|
||||
void *object);
|
||||
pw_global_new(struct pw_core *core, /**< the core */
|
||||
uint32_t type, /**< the interface type of the global */
|
||||
uint32_t version, /**< the interface version of the global */
|
||||
struct pw_properties *properties, /**< extra properties */
|
||||
pw_bind_func_t bind, /**< function to bind to the global */
|
||||
void *object /**< global object */);
|
||||
|
||||
/** Register a global object to the core registry */
|
||||
int pw_global_register(struct pw_global *global,
|
||||
|
|
@ -92,6 +94,9 @@ uint32_t pw_global_get_type(struct pw_global *global);
|
|||
/** Get the global version */
|
||||
uint32_t pw_global_get_version(struct pw_global *global);
|
||||
|
||||
/** Get the global properties */
|
||||
const struct pw_properties *pw_global_get_properties(struct pw_global *global);
|
||||
|
||||
/** Get the object associated with the global. This depends on the type of the
|
||||
* global */
|
||||
void *pw_global_get_object(struct pw_global *global);
|
||||
|
|
|
|||
|
|
@ -395,9 +395,11 @@ struct pw_registry_proxy_events {
|
|||
* \param permissions the permissions of the object
|
||||
* \param type the type of the interface
|
||||
* \param version the version of the interface
|
||||
* \param props extra properties of the global
|
||||
*/
|
||||
void (*global) (void *object, uint32_t id, uint32_t parent_id,
|
||||
uint32_t permissions, uint32_t type, uint32_t version);
|
||||
uint32_t permissions, uint32_t type, uint32_t version,
|
||||
const struct spa_dict *props);
|
||||
/**
|
||||
* Notify of a global object removal
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1201,21 +1201,25 @@ struct pw_link *pw_link_new(struct pw_core *core,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
void pw_link_register(struct pw_link *link,
|
||||
struct pw_client *owner,
|
||||
struct pw_global *parent)
|
||||
int pw_link_register(struct pw_link *link,
|
||||
struct pw_client *owner,
|
||||
struct pw_global *parent,
|
||||
struct pw_properties *properties)
|
||||
{
|
||||
struct pw_core *core = link->core;
|
||||
struct pw_node *input_node, *output_node;
|
||||
|
||||
spa_list_append(&core->link_list, &link->link);
|
||||
|
||||
link->global = pw_global_new(core, core->type.link, PW_VERSION_LINK,
|
||||
link_bind_func, link);
|
||||
if (link->global != NULL) {
|
||||
pw_global_register(link->global, owner, parent);
|
||||
link->info.id = link->global->id;
|
||||
}
|
||||
link->global = pw_global_new(core,
|
||||
core->type.link, PW_VERSION_LINK,
|
||||
properties,
|
||||
link_bind_func, link);
|
||||
if (link->global == NULL)
|
||||
return -ENOMEM;
|
||||
|
||||
pw_global_register(link->global, owner, parent);
|
||||
link->info.id = link->global->id;
|
||||
|
||||
input_node = link->input->node;
|
||||
output_node = link->output->node;
|
||||
|
|
@ -1234,8 +1238,9 @@ void pw_link_register(struct pw_link *link,
|
|||
output_node->n_used_output_links + 1 > output_node->idle_used_output_links) &&
|
||||
input_node->active && output_node->active)
|
||||
pw_link_activate(link);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void pw_link_destroy(struct pw_link *link)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -96,9 +96,10 @@ void pw_link_add_listener(struct pw_link *link,
|
|||
void *data);
|
||||
|
||||
/** Finish link configuration and register */
|
||||
void pw_link_register(struct pw_link *link, /**< the link to register */
|
||||
struct pw_client *owner, /**< optional link owner */
|
||||
struct pw_global *parent /**< parent global */);
|
||||
int pw_link_register(struct pw_link *link, /**< the link to register */
|
||||
struct pw_client *owner, /**< optional link owner */
|
||||
struct pw_global *parent, /**< parent global */
|
||||
struct pw_properties *properties /**< extra properties */);
|
||||
|
||||
/** Get the core of a link */
|
||||
struct pw_core *pw_link_get_core(struct pw_link *link);
|
||||
|
|
|
|||
|
|
@ -218,15 +218,6 @@ struct pw_module *pw_module_load(struct pw_core *core, const char *name, const c
|
|||
this->info.args = args ? strdup(args) : NULL;
|
||||
this->info.props = NULL;
|
||||
|
||||
spa_list_append(&core->module_list, &this->link);
|
||||
this->global = pw_global_new(core, core->type.module, PW_VERSION_MODULE,
|
||||
module_bind_func, this);
|
||||
|
||||
if (this->global != NULL) {
|
||||
pw_global_register(this->global, NULL, core->global);
|
||||
this->info.id = this->global->id;
|
||||
}
|
||||
|
||||
if ((res = init_func(this, args)) < 0)
|
||||
goto init_failed;
|
||||
|
||||
|
|
@ -253,6 +244,30 @@ struct pw_module *pw_module_load(struct pw_core *core, const char *name, const c
|
|||
return NULL;
|
||||
}
|
||||
|
||||
int pw_module_register(struct pw_module *module,
|
||||
struct pw_client *owner,
|
||||
struct pw_global *parent,
|
||||
struct pw_properties *properties)
|
||||
{
|
||||
struct pw_core *core = module->core;
|
||||
|
||||
spa_list_append(&core->module_list, &module->link);
|
||||
|
||||
module->global = pw_global_new(core,
|
||||
core->type.module, PW_VERSION_MODULE,
|
||||
properties,
|
||||
module_bind_func, module);
|
||||
|
||||
if (module->global == NULL)
|
||||
return -ENOMEM;
|
||||
|
||||
pw_global_register(module->global, owner, parent);
|
||||
|
||||
module->info.id = module->global->id;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Destroy a module
|
||||
* \param module the module to destroy
|
||||
* \memberof pw_module
|
||||
|
|
|
|||
|
|
@ -66,6 +66,12 @@ struct pw_module_events {
|
|||
struct pw_module *
|
||||
pw_module_load(struct pw_core *core, const char *name, const char *args);
|
||||
|
||||
/** Finish module configuration and register */
|
||||
int pw_module_register(struct pw_module *module, /**< the module to register */
|
||||
struct pw_client *owner, /**< optional owner */
|
||||
struct pw_global *parent, /**< parent global */
|
||||
struct pw_properties *properties /**< extra global properties */);
|
||||
|
||||
/** Get the core of a module */
|
||||
struct pw_core * pw_module_get_core(struct pw_module *module);
|
||||
|
||||
|
|
|
|||
|
|
@ -329,11 +329,13 @@ do_node_add(struct spa_loop *loop,
|
|||
return 0;
|
||||
}
|
||||
|
||||
void pw_node_register(struct pw_node *this,
|
||||
struct pw_client *owner,
|
||||
struct pw_global *parent)
|
||||
int pw_node_register(struct pw_node *this,
|
||||
struct pw_client *owner,
|
||||
struct pw_global *parent,
|
||||
struct pw_properties *properties)
|
||||
{
|
||||
struct pw_core *core = this->core;
|
||||
const char *str;
|
||||
|
||||
pw_log_debug("node %p: register", this);
|
||||
|
||||
|
|
@ -342,17 +344,30 @@ void pw_node_register(struct pw_node *this,
|
|||
|
||||
pw_loop_invoke(this->data_loop, do_node_add, 1, NULL, 0, false, this);
|
||||
|
||||
if (properties == NULL)
|
||||
properties = pw_properties_new(NULL, NULL);
|
||||
if (properties == NULL)
|
||||
return -ENOMEM;
|
||||
|
||||
if ((str = pw_properties_get(this->properties, "media.class")) != NULL)
|
||||
pw_properties_set(properties, "media.class", str);
|
||||
|
||||
spa_list_append(&core->node_list, &this->link);
|
||||
this->global = pw_global_new(core, core->type.node, PW_VERSION_NODE,
|
||||
node_bind_func, this);
|
||||
if (this->global != NULL) {
|
||||
pw_global_register(this->global, owner, parent);
|
||||
this->info.id = this->global->id;
|
||||
}
|
||||
this->global = pw_global_new(core,
|
||||
core->type.node, PW_VERSION_NODE,
|
||||
properties,
|
||||
node_bind_func, this);
|
||||
if (this->global == NULL)
|
||||
return -ENOMEM;
|
||||
|
||||
pw_global_register(this->global, owner, parent);
|
||||
this->info.id = this->global->id;
|
||||
|
||||
spa_hook_list_call(&this->listener_list, struct pw_node_events, initialized);
|
||||
|
||||
pw_node_update_state(this, PW_NODE_STATE_SUSPENDED, NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct pw_node *pw_node_new(struct pw_core *core,
|
||||
|
|
@ -434,7 +449,7 @@ const struct pw_properties *pw_node_get_properties(struct pw_node *node)
|
|||
return node->properties;
|
||||
}
|
||||
|
||||
void pw_node_update_properties(struct pw_node *node, const struct spa_dict *dict)
|
||||
int pw_node_update_properties(struct pw_node *node, const struct spa_dict *dict)
|
||||
{
|
||||
struct pw_resource *resource;
|
||||
uint32_t i;
|
||||
|
|
@ -452,6 +467,8 @@ void pw_node_update_properties(struct pw_node *node, const struct spa_dict *dict
|
|||
pw_node_resource_info(resource, &node->info);
|
||||
|
||||
node->info.change_mask = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void node_done(void *data, int seq, int res)
|
||||
|
|
|
|||
|
|
@ -102,9 +102,10 @@ pw_node_new(struct pw_core *core, /**< the core */
|
|||
size_t user_data_size /**< user data size */);
|
||||
|
||||
/** Complete initialization of the node and register */
|
||||
void pw_node_register(struct pw_node *node, /**< node to register */
|
||||
struct pw_client *owner, /**< optional owner */
|
||||
struct pw_global *parent /**< optional parent */);
|
||||
int pw_node_register(struct pw_node *node, /**< node to register */
|
||||
struct pw_client *owner, /**< optional owner */
|
||||
struct pw_global *parent, /**< optional parent */
|
||||
struct pw_properties *properties /**< extra properties */);
|
||||
|
||||
/** Destroy a node */
|
||||
void pw_node_destroy(struct pw_node *node);
|
||||
|
|
@ -125,7 +126,7 @@ struct pw_global *pw_node_get_global(struct pw_node *node);
|
|||
const struct pw_properties *pw_node_get_properties(struct pw_node *node);
|
||||
|
||||
/** Update the node properties */
|
||||
void pw_node_update_properties(struct pw_node *node, const struct spa_dict *dict);
|
||||
int pw_node_update_properties(struct pw_node *node, const struct spa_dict *dict);
|
||||
|
||||
/** Set the node implementation */
|
||||
void pw_node_set_implementation(struct pw_node *node, struct spa_node *spa_node);
|
||||
|
|
|
|||
|
|
@ -233,7 +233,7 @@ const struct pw_properties *pw_port_get_properties(struct pw_port *port)
|
|||
return port->properties;
|
||||
}
|
||||
|
||||
void pw_port_update_properties(struct pw_port *port, const struct spa_dict *dict)
|
||||
int pw_port_update_properties(struct pw_port *port, const struct spa_dict *dict)
|
||||
{
|
||||
uint32_t i;
|
||||
for (i = 0; i < dict->n_items; i++)
|
||||
|
|
@ -241,6 +241,8 @@ void pw_port_update_properties(struct pw_port *port, const struct spa_dict *dict
|
|||
|
||||
spa_hook_list_call(&port->listener_list, struct pw_port_events,
|
||||
properties_changed, port->properties);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct pw_node *pw_port_get_node(struct pw_port *port)
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ enum pw_direction pw_port_get_direction(struct pw_port *port);
|
|||
const struct pw_properties *pw_port_get_properties(struct pw_port *port);
|
||||
|
||||
/** Update the port properties */
|
||||
void pw_port_update_properties(struct pw_port *port, const struct spa_dict *dict);
|
||||
int pw_port_update_properties(struct pw_port *port, const struct spa_dict *dict);
|
||||
|
||||
/** Get the port id */
|
||||
uint32_t pw_port_get_id(struct pw_port *port);
|
||||
|
|
|
|||
|
|
@ -109,6 +109,8 @@ struct pw_global {
|
|||
uint32_t id; /**< server id of the object */
|
||||
struct pw_global *parent; /**< parent global */
|
||||
|
||||
struct pw_properties *properties; /**< properties of the global */
|
||||
|
||||
uint32_t type; /**< type of interface */
|
||||
uint32_t version; /**< version of interface */
|
||||
pw_bind_func_t bind; /**< function to bind to the interface */
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ struct properties {
|
|||
};
|
||||
/** \endcond */
|
||||
|
||||
static void add_func(struct pw_properties *this, char *key, char *value)
|
||||
static int add_func(struct pw_properties *this, char *key, char *value)
|
||||
{
|
||||
struct spa_dict_item *item;
|
||||
struct properties *impl = SPA_CONTAINER_OF(this, struct properties, this);
|
||||
|
|
@ -41,6 +41,7 @@ static void add_func(struct pw_properties *this, char *key, char *value)
|
|||
|
||||
this->dict.items = impl->items.data;
|
||||
this->dict.n_items = pw_array_get_len(&impl->items, struct spa_dict_item);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void clear_item(struct spa_dict_item *item)
|
||||
|
|
@ -200,7 +201,7 @@ void pw_properties_free(struct pw_properties *properties)
|
|||
free(impl);
|
||||
}
|
||||
|
||||
static void do_replace(struct pw_properties *properties, char *key, char *value)
|
||||
static int do_replace(struct pw_properties *properties, char *key, char *value)
|
||||
{
|
||||
struct properties *impl = SPA_CONTAINER_OF(properties, struct properties, this);
|
||||
int index = find_index(properties, key);
|
||||
|
|
@ -224,6 +225,7 @@ static void do_replace(struct pw_properties *properties, char *key, char *value)
|
|||
item->value = value;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Set a property value
|
||||
|
|
@ -238,9 +240,9 @@ static void do_replace(struct pw_properties *properties, char *key, char *value)
|
|||
*
|
||||
* \memberof pw_properties
|
||||
*/
|
||||
void pw_properties_set(struct pw_properties *properties, const char *key, const char *value)
|
||||
int pw_properties_set(struct pw_properties *properties, const char *key, const char *value)
|
||||
{
|
||||
do_replace(properties, strdup(key), value ? strdup(value) : NULL);
|
||||
return do_replace(properties, strdup(key), value ? strdup(value) : NULL);
|
||||
}
|
||||
|
||||
/** Set a property value by format
|
||||
|
|
@ -255,7 +257,7 @@ void pw_properties_set(struct pw_properties *properties, const char *key, const
|
|||
*
|
||||
* \memberof pw_properties
|
||||
*/
|
||||
void pw_properties_setf(struct pw_properties *properties, const char *key, const char *format, ...)
|
||||
int pw_properties_setf(struct pw_properties *properties, const char *key, const char *format, ...)
|
||||
{
|
||||
va_list varargs;
|
||||
char *value;
|
||||
|
|
@ -264,7 +266,7 @@ void pw_properties_setf(struct pw_properties *properties, const char *key, const
|
|||
vasprintf(&value, format, varargs);
|
||||
va_end(varargs);
|
||||
|
||||
do_replace(properties, strdup(key), value);
|
||||
return do_replace(properties, strdup(key), value);
|
||||
}
|
||||
|
||||
/** Get a property
|
||||
|
|
|
|||
|
|
@ -55,10 +55,10 @@ pw_properties_merge(const struct pw_properties *oldprops,
|
|||
void
|
||||
pw_properties_free(struct pw_properties *properties);
|
||||
|
||||
void
|
||||
int
|
||||
pw_properties_set(struct pw_properties *properties, const char *key, const char *value);
|
||||
|
||||
void
|
||||
int
|
||||
pw_properties_setf(struct pw_properties *properties,
|
||||
const char *key, const char *format, ...) SPA_PRINTF_FUNC(3, 4);
|
||||
const char *
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@
|
|||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#include <pipewire/protocol.h>
|
||||
#include <pipewire/private.h>
|
||||
|
||||
|
|
@ -111,13 +113,16 @@ void pw_protocol_add_listener(struct pw_protocol *protocol,
|
|||
spa_hook_list_append(&protocol->listener_list, listener, events, data);
|
||||
}
|
||||
|
||||
void
|
||||
int
|
||||
pw_protocol_add_marshal(struct pw_protocol *protocol,
|
||||
const struct pw_protocol_marshal *marshal)
|
||||
{
|
||||
struct marshal *impl;
|
||||
|
||||
impl = calloc(1, sizeof(struct marshal));
|
||||
if (impl == NULL)
|
||||
return -ENOMEM;
|
||||
|
||||
impl->marshal = marshal;
|
||||
impl->type = spa_type_map_get_id (protocol->core->type.map, marshal->type);
|
||||
|
||||
|
|
@ -125,6 +130,8 @@ pw_protocol_add_marshal(struct pw_protocol *protocol,
|
|||
|
||||
pw_log_info("Add marshal %s:%d to protocol %s", marshal->type, marshal->version,
|
||||
protocol->name);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
const struct pw_protocol_marshal *
|
||||
|
|
|
|||
|
|
@ -119,8 +119,8 @@ void pw_protocol_add_listener(struct pw_protocol *protocol,
|
|||
*
|
||||
* \brief Manages protocols and their implementation
|
||||
*/
|
||||
void pw_protocol_add_marshal(struct pw_protocol *protocol,
|
||||
const struct pw_protocol_marshal *marshal);
|
||||
int pw_protocol_add_marshal(struct pw_protocol *protocol,
|
||||
const struct pw_protocol_marshal *marshal);
|
||||
|
||||
const struct pw_protocol_marshal *
|
||||
pw_protocol_get_marshal(struct pw_protocol *protocol, uint32_t type);
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ const char *pw_remote_state_as_string(enum pw_remote_state state)
|
|||
return "invalid-state";
|
||||
}
|
||||
|
||||
void
|
||||
int
|
||||
pw_remote_update_state(struct pw_remote *remote, enum pw_remote_state state, const char *fmt, ...)
|
||||
{
|
||||
enum pw_remote_state old = remote->state;
|
||||
|
|
@ -146,6 +146,7 @@ pw_remote_update_state(struct pw_remote *remote, enum pw_remote_state state, con
|
|||
spa_hook_list_call(&remote->listener_list, struct pw_remote_events, state_changed,
|
||||
old, state, remote->error);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void core_event_info(void *data, struct pw_core_info *info)
|
||||
|
|
@ -403,14 +404,14 @@ int pw_remote_connect_fd(struct pw_remote *remote, int fd)
|
|||
return do_connect(remote);
|
||||
}
|
||||
|
||||
void pw_remote_disconnect(struct pw_remote *remote)
|
||||
int pw_remote_disconnect(struct pw_remote *remote)
|
||||
{
|
||||
struct pw_proxy *proxy, *t2;
|
||||
struct pw_stream *stream, *s2;
|
||||
|
||||
pw_log_debug("remote %p: disconnect", remote);
|
||||
spa_list_for_each_safe(stream, s2, &remote->stream_list, link)
|
||||
pw_stream_disconnect(stream);
|
||||
pw_stream_disconnect(stream);
|
||||
|
||||
pw_protocol_client_disconnect (remote->conn);
|
||||
|
||||
|
|
@ -427,6 +428,8 @@ void pw_remote_disconnect(struct pw_remote *remote)
|
|||
remote->info = NULL;
|
||||
}
|
||||
pw_remote_update_state(remote, PW_REMOTE_STATE_UNCONNECTED, NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
|
|||
|
|
@ -188,10 +188,10 @@ const struct pw_core_info *pw_remote_get_core_info(struct pw_remote *remote);
|
|||
struct pw_proxy *pw_remote_find_proxy(struct pw_remote *remote, uint32_t id);
|
||||
|
||||
/** Disconnect from the remote PipeWire. \memberof pw_remote */
|
||||
void pw_remote_disconnect(struct pw_remote *remote);
|
||||
int pw_remote_disconnect(struct pw_remote *remote);
|
||||
|
||||
/** Update the state of the remote, mostly used by protocols */
|
||||
void pw_remote_update_state(struct pw_remote *remote, enum pw_remote_state state, const char *fmt, ...);
|
||||
int pw_remote_update_state(struct pw_remote *remote, enum pw_remote_state state, const char *fmt, ...);
|
||||
|
||||
/** run a local node in a remote graph */
|
||||
struct pw_proxy *pw_remote_export(struct pw_remote *remote, struct pw_node *node);
|
||||
|
|
|
|||
|
|
@ -1081,7 +1081,7 @@ pw_stream_finish_format(struct pw_stream *stream,
|
|||
impl->pending_seq = SPA_ID_INVALID;
|
||||
}
|
||||
|
||||
void pw_stream_disconnect(struct pw_stream *stream)
|
||||
int pw_stream_disconnect(struct pw_stream *stream)
|
||||
{
|
||||
struct stream *impl = SPA_CONTAINER_OF(stream, struct stream, this);
|
||||
|
||||
|
|
@ -1097,12 +1097,14 @@ void pw_stream_disconnect(struct pw_stream *stream)
|
|||
pw_client_node_transport_destroy(impl->trans);
|
||||
impl->trans = NULL;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void pw_stream_set_active(struct pw_stream *stream, bool active)
|
||||
int pw_stream_set_active(struct pw_stream *stream, bool active)
|
||||
{
|
||||
struct stream *impl = SPA_CONTAINER_OF(stream, struct stream, this);
|
||||
pw_client_node_proxy_set_active(impl->node_proxy, active);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pw_stream_get_time(struct pw_stream *stream, struct pw_time *time)
|
||||
|
|
|
|||
|
|
@ -275,7 +275,7 @@ uint32_t
|
|||
pw_stream_get_node_id(struct pw_stream *stream);
|
||||
|
||||
/** Disconnect \a stream \memberof pw_stream */
|
||||
void pw_stream_disconnect(struct pw_stream *stream);
|
||||
int pw_stream_disconnect(struct pw_stream *stream);
|
||||
|
||||
/** Complete the negotiation process with result code \a res \memberof pw_stream
|
||||
*
|
||||
|
|
@ -292,7 +292,7 @@ pw_stream_finish_format(struct pw_stream *stream, /**< a \ref pw_stream */
|
|||
uint32_t n_params /**< number of elements in \a params */);
|
||||
|
||||
/** Activate or deactivate the stream \memberof pw_stream */
|
||||
void pw_stream_set_active(struct pw_stream *stream, bool active);
|
||||
int pw_stream_set_active(struct pw_stream *stream, bool active);
|
||||
|
||||
/** Query the time on the stream \memberof pw_stream */
|
||||
int pw_stream_get_time(struct pw_stream *stream, struct pw_time *time);
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@
|
|||
* \param type a type structure
|
||||
* \memberof pw_type
|
||||
*/
|
||||
void pw_type_init(struct pw_type *type)
|
||||
int pw_type_init(struct pw_type *type)
|
||||
{
|
||||
type->map = pw_get_support_interface(SPA_TYPE__TypeMap);
|
||||
|
||||
|
|
@ -64,4 +64,5 @@ void pw_type_init(struct pw_type *type)
|
|||
spa_type_param_buffers_map(type->map, &type->param_buffers);
|
||||
spa_type_param_meta_map(type->map, &type->param_meta);
|
||||
spa_type_param_io_map(type->map, &type->param_io);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,8 +78,7 @@ struct pw_type {
|
|||
struct spa_type_param_io param_io;
|
||||
};
|
||||
|
||||
void
|
||||
pw_type_init(struct pw_type *type);
|
||||
int pw_type_init(struct pw_type *type);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@ struct global {
|
|||
uint32_t version;
|
||||
struct pw_proxy *proxy;
|
||||
bool info_pending;
|
||||
struct pw_properties *properties;
|
||||
};
|
||||
|
||||
struct remote_data {
|
||||
|
|
@ -139,6 +140,23 @@ static struct pw_properties *parse_props(char *str)
|
|||
return props;
|
||||
}
|
||||
|
||||
static void print_properties(struct spa_dict *props, char mark, bool header)
|
||||
{
|
||||
const struct spa_dict_item *item;
|
||||
|
||||
if (header)
|
||||
fprintf(stdout, "%c\tproperties:\n", mark);
|
||||
if (props == NULL || props->n_items == 0) {
|
||||
if (header)
|
||||
fprintf(stdout, "\t\tnone\n");
|
||||
return;
|
||||
}
|
||||
|
||||
spa_dict_for_each(item, props) {
|
||||
fprintf(stdout, "%c\t\t%s = \"%s\"\n", mark, item->key, item->value);
|
||||
}
|
||||
}
|
||||
|
||||
static bool do_not_implemented(struct data *data, const char *cmd, char *args, char **error)
|
||||
{
|
||||
asprintf(error, "Command \"%s\" not yet implemented", cmd);
|
||||
|
|
@ -251,10 +269,14 @@ static void print_global(void *obj, void *data)
|
|||
fprintf(stdout, "\tid %d, parent %d, type %s/%d\n", global->id, global->parent_id,
|
||||
spa_type_map_get_type(t->map, global->type),
|
||||
global->version);
|
||||
if (global->properties)
|
||||
print_properties(&global->properties->dict, ' ', false);
|
||||
|
||||
}
|
||||
|
||||
static void registry_event_global(void *data, uint32_t id, uint32_t parent_id,
|
||||
uint32_t permissions, uint32_t type, uint32_t version)
|
||||
uint32_t permissions, uint32_t type, uint32_t version,
|
||||
const struct spa_dict *props)
|
||||
{
|
||||
struct remote_data *rd = data;
|
||||
struct global *global;
|
||||
|
|
@ -267,6 +289,7 @@ static void registry_event_global(void *data, uint32_t id, uint32_t parent_id,
|
|||
global->permissions = permissions;
|
||||
global->type = type;
|
||||
global->version = version;
|
||||
global->properties = props ? pw_properties_new_dict(props) : NULL;
|
||||
|
||||
fprintf(stdout, "remote %d added global: ", rd->id);
|
||||
print_global(global, NULL);
|
||||
|
|
@ -285,6 +308,8 @@ static void destroy_global(void *obj, void *data)
|
|||
return;
|
||||
|
||||
pw_map_remove(&global->rd->globals, global->id);
|
||||
if (global->properties)
|
||||
pw_properties_free(global->properties);
|
||||
free(global);
|
||||
}
|
||||
|
||||
|
|
@ -462,21 +487,6 @@ static bool do_switch_remote(struct data *data, const char *cmd, char *args, cha
|
|||
return false;
|
||||
}
|
||||
|
||||
static void print_properties(struct spa_dict *props, char mark)
|
||||
{
|
||||
const struct spa_dict_item *item;
|
||||
|
||||
fprintf(stdout, "%c\tproperties:\n", mark);
|
||||
if (props == NULL || props->n_items == 0) {
|
||||
fprintf(stdout, "\t\tnone\n");
|
||||
return;
|
||||
}
|
||||
|
||||
spa_dict_for_each(item, props) {
|
||||
fprintf(stdout, "%c\t\t%s = \"%s\"\n", mark, item->key, item->value);
|
||||
}
|
||||
}
|
||||
|
||||
#define MARK_CHANGE(f) ((((info)->change_mask & (1 << (f)))) ? '*' : ' ')
|
||||
|
||||
static void info_global(struct proxy_data *pd)
|
||||
|
|
@ -505,7 +515,7 @@ static void info_core(struct proxy_data *pd)
|
|||
fprintf(stdout, "%c\tversion: \"%s\"\n", MARK_CHANGE(2), info->version);
|
||||
fprintf(stdout, "%c\tname: \"%s\"\n", MARK_CHANGE(3), info->name);
|
||||
fprintf(stdout, "%c\tcookie: %u\n", MARK_CHANGE(4), info->cookie);
|
||||
print_properties(info->props, MARK_CHANGE(5));
|
||||
print_properties(info->props, MARK_CHANGE(5), true);
|
||||
info->change_mask = 0;
|
||||
}
|
||||
|
||||
|
|
@ -517,7 +527,7 @@ static void info_module(struct proxy_data *pd)
|
|||
fprintf(stdout, "%c\tname: \"%s\"\n", MARK_CHANGE(0), info->name);
|
||||
fprintf(stdout, "%c\tfilename: \"%s\"\n", MARK_CHANGE(1), info->filename);
|
||||
fprintf(stdout, "%c\targs: \"%s\"\n", MARK_CHANGE(2), info->args);
|
||||
print_properties(info->props, MARK_CHANGE(3));
|
||||
print_properties(info->props, MARK_CHANGE(3), true);
|
||||
info->change_mask = 0;
|
||||
}
|
||||
|
||||
|
|
@ -551,7 +561,7 @@ static void info_node(struct proxy_data *pd)
|
|||
fprintf(stdout, " \"%s\"\n", info->error);
|
||||
else
|
||||
fprintf(stdout, "\n");
|
||||
print_properties(info->props, MARK_CHANGE(6));
|
||||
print_properties(info->props, MARK_CHANGE(6), true);
|
||||
info->change_mask = 0;
|
||||
}
|
||||
|
||||
|
|
@ -563,7 +573,7 @@ static void info_factory(struct proxy_data *pd)
|
|||
info_global(pd);
|
||||
fprintf(stdout, "\tname: \"%s\"\n", info->name);
|
||||
fprintf(stdout, "\tobject-type: %s/%d\n", spa_type_map_get_type(t->map, info->type), info->version);
|
||||
print_properties(info->props, MARK_CHANGE(0));
|
||||
print_properties(info->props, MARK_CHANGE(0), true);
|
||||
info->change_mask = 0;
|
||||
}
|
||||
|
||||
|
|
@ -572,7 +582,7 @@ static void info_client(struct proxy_data *pd)
|
|||
struct pw_client_info *info = pd->info;
|
||||
|
||||
info_global(pd);
|
||||
print_properties(info->props, MARK_CHANGE(0));
|
||||
print_properties(info->props, MARK_CHANGE(0), true);
|
||||
info->change_mask = 0;
|
||||
}
|
||||
|
||||
|
|
@ -590,7 +600,7 @@ static void info_link(struct proxy_data *pd)
|
|||
spa_debug_pod(info->format, SPA_DEBUG_FLAG_FORMAT);
|
||||
else
|
||||
fprintf(stdout, "\t\tnone\n");
|
||||
print_properties(info->props, MARK_CHANGE(3));
|
||||
print_properties(info->props, MARK_CHANGE(3), true);
|
||||
info->change_mask = 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ struct proxy_data {
|
|||
struct spa_hook proxy_proxy_listener;
|
||||
};
|
||||
|
||||
static void print_properties(struct spa_dict *props, char mark)
|
||||
static void print_properties(const struct spa_dict *props, char mark)
|
||||
{
|
||||
const struct spa_dict_item *item;
|
||||
|
||||
|
|
@ -314,7 +314,8 @@ static const struct pw_proxy_events proxy_events = {
|
|||
};
|
||||
|
||||
static void registry_event_global(void *data, uint32_t id, uint32_t parent_id,
|
||||
uint32_t permissions, uint32_t type, uint32_t version)
|
||||
uint32_t permissions, uint32_t type, uint32_t version,
|
||||
const struct spa_dict *props)
|
||||
{
|
||||
struct data *d = data;
|
||||
struct pw_proxy *proxy;
|
||||
|
|
@ -358,6 +359,7 @@ static void registry_event_global(void *data, uint32_t id, uint32_t parent_id,
|
|||
permissions & PW_PERM_W ? 'w' : '-',
|
||||
permissions & PW_PERM_X ? 'x' : '-');
|
||||
printf("\ttype: %s (version %d)\n", spa_type_map_get_type(t->map, type), version);
|
||||
print_properties(props, ' ');
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue