diff --git a/src/modules/module-protocol-native/protocol-native.c b/src/modules/module-protocol-native/protocol-native.c index 1492aa2e0..86f134aeb 100644 --- a/src/modules/module-protocol-native/protocol-native.c +++ b/src/modules/module-protocol-native/protocol-native.c @@ -292,7 +292,8 @@ static void core_marshal_info(void *object, struct pw_core_info *info) SPA_POD_TYPE_STRING, info->host_name, SPA_POD_TYPE_STRING, info->version, SPA_POD_TYPE_STRING, info->name, - SPA_POD_TYPE_INT, info->cookie, SPA_POD_TYPE_INT, n_items, 0); + SPA_POD_TYPE_INT, info->cookie, + SPA_POD_TYPE_INT, n_items, 0); for (i = 0; i < n_items; i++) { spa_pod_builder_add(b, @@ -779,16 +780,28 @@ static void link_marshal_info(void *object, struct pw_link_info *info) struct pw_resource *resource = object; struct spa_pod_builder *b; struct spa_pod_frame f; + uint32_t i, n_items; b = pw_protocol_native_begin_resource(resource, PW_LINK_PROXY_EVENT_INFO); - spa_pod_builder_struct(b, &f, - SPA_POD_TYPE_LONG, info->change_mask, - SPA_POD_TYPE_INT, info->output_node_id, - SPA_POD_TYPE_INT, info->output_port_id, - SPA_POD_TYPE_INT, info->input_node_id, - SPA_POD_TYPE_INT, info->input_port_id, - SPA_POD_TYPE_POD, info->format); + n_items = info->props ? info->props->n_items : 0; + + spa_pod_builder_add(b, + SPA_POD_TYPE_STRUCT, &f, + SPA_POD_TYPE_LONG, info->change_mask, + SPA_POD_TYPE_INT, info->output_node_id, + SPA_POD_TYPE_INT, info->output_port_id, + SPA_POD_TYPE_INT, info->input_node_id, + SPA_POD_TYPE_INT, info->input_port_id, + SPA_POD_TYPE_POD, info->format, + SPA_POD_TYPE_INT, n_items, 0); + + for (i = 0; i < n_items; i++) { + spa_pod_builder_add(b, + SPA_POD_TYPE_STRING, info->props->items[i].key, + SPA_POD_TYPE_STRING, info->props->items[i].value, 0); + } + spa_pod_builder_add(b, -SPA_POD_TYPE_STRUCT, &f, 0); pw_protocol_native_end_resource(resource, b); } @@ -797,7 +810,9 @@ static bool link_demarshal_info(void *object, void *data, size_t size) { struct pw_proxy *proxy = object; struct spa_pod_iter it; + struct spa_dict props; struct pw_link_info info = { 0, }; + int i; if (!spa_pod_iter_struct(&it, data, size) || !spa_pod_iter_get(&it, @@ -806,9 +821,18 @@ static bool link_demarshal_info(void *object, void *data, size_t size) SPA_POD_TYPE_INT, &info.output_port_id, SPA_POD_TYPE_INT, &info.input_node_id, SPA_POD_TYPE_INT, &info.input_port_id, - -SPA_POD_TYPE_OBJECT, &info.format, 0)) + -SPA_POD_TYPE_OBJECT, &info.format, + SPA_POD_TYPE_INT, &props.n_items, 0)) return false; + info.props = &props; + props.items = alloca(props.n_items * sizeof(struct spa_dict_item)); + for (i = 0; i < props.n_items; i++) { + if (!spa_pod_iter_get(&it, + SPA_POD_TYPE_STRING, &props.items[i].key, + SPA_POD_TYPE_STRING, &props.items[i].value, 0)) + return false; + } pw_proxy_notify(proxy, struct pw_link_proxy_events, info, &info); return true; } diff --git a/src/pipewire/client.c b/src/pipewire/client.c index c1ef95e48..16a8fe9d3 100644 --- a/src/pipewire/client.c +++ b/src/pipewire/client.c @@ -245,7 +245,7 @@ void pw_client_update_properties(struct pw_client *client, const struct spa_dict dict->items[i].key, dict->items[i].value); } - client->info.change_mask |= 1 << 0; + client->info.change_mask |= PW_CLIENT_CHANGE_MASK_PROPS; client->info.props = client->properties ? &client->properties->dict : NULL; spa_hook_list_call(&client->listener_list, struct pw_client_events, info_changed, &client->info); diff --git a/src/pipewire/introspect.c b/src/pipewire/introspect.c index 2a2fb2acd..54319c2cd 100644 --- a/src/pipewire/introspect.c +++ b/src/pipewire/introspect.c @@ -127,29 +127,29 @@ struct pw_core_info *pw_core_info_update(struct pw_core_info *info, } info->change_mask = update->change_mask; - if (update->change_mask & (1 << 0)) { + if (update->change_mask & PW_CORE_CHANGE_MASK_USER_NAME) { if (info->user_name) free((void *) info->user_name); info->user_name = update->user_name ? strdup(update->user_name) : NULL; } - if (update->change_mask & (1 << 1)) { + if (update->change_mask & PW_CORE_CHANGE_MASK_HOST_NAME) { if (info->host_name) free((void *) info->host_name); info->host_name = update->host_name ? strdup(update->host_name) : NULL; } - if (update->change_mask & (1 << 2)) { + if (update->change_mask & PW_CORE_CHANGE_MASK_VERSION) { if (info->version) free((void *) info->version); info->version = update->version ? strdup(update->version) : NULL; } - if (update->change_mask & (1 << 3)) { + if (update->change_mask & PW_CORE_CHANGE_MASK_NAME) { if (info->name) free((void *) info->name); info->name = update->name ? strdup(update->name) : NULL; } - if (update->change_mask & (1 << 4)) + if (update->change_mask & PW_CORE_CHANGE_MASK_COOKIE) info->cookie = update->cookie; - if (update->change_mask & (1 << 5)) { + if (update->change_mask & PW_CORE_CHANGE_MASK_PROPS) { if (info->props) pw_spa_dict_destroy(info->props); info->props = pw_spa_dict_copy(update->props); @@ -283,22 +283,22 @@ struct pw_module_info *pw_module_info_update(struct pw_module_info *info, } info->change_mask = update->change_mask; - if (update->change_mask & (1 << 0)) { + if (update->change_mask & PW_MODULE_CHANGE_MASK_NAME) { if (info->name) free((void *) info->name); info->name = update->name ? strdup(update->name) : NULL; } - if (update->change_mask & (1 << 1)) { + if (update->change_mask & PW_MODULE_CHANGE_MASK_FILENAME) { if (info->filename) free((void *) info->filename); info->filename = update->filename ? strdup(update->filename) : NULL; } - if (update->change_mask & (1 << 2)) { + if (update->change_mask & PW_MODULE_CHANGE_MASK_ARGS) { if (info->args) free((void *) info->args); info->args = update->args ? strdup(update->args) : NULL; } - if (update->change_mask & (1 << 3)) { + if (update->change_mask & PW_MODULE_CHANGE_MASK_PROPS) { if (info->props) pw_spa_dict_destroy(info->props); info->props = pw_spa_dict_copy(update->props); @@ -333,7 +333,7 @@ struct pw_client_info *pw_client_info_update(struct pw_client_info *info, } info->change_mask = update->change_mask; - if (update->change_mask & (1 << 0)) { + if (update->change_mask & PW_CLIENT_CHANGE_MASK_PROPS) { if (info->props) pw_spa_dict_destroy(info->props); info->props = pw_spa_dict_copy(update->props); @@ -361,15 +361,15 @@ struct pw_link_info *pw_link_info_update(struct pw_link_info *info, } info->change_mask = update->change_mask; - if (update->change_mask & (1 << 0)) + if (update->change_mask & PW_LINK_CHANGE_MASK_OUTPUT) { info->output_node_id = update->output_node_id; - if (update->change_mask & (1 << 1)) info->output_port_id = update->output_port_id; - if (update->change_mask & (1 << 2)) + } + if (update->change_mask & PW_LINK_CHANGE_MASK_INPUT) { info->input_node_id = update->input_node_id; - if (update->change_mask & (1 << 3)) info->input_port_id = update->input_port_id; - if (update->change_mask & (1 << 4)) { + } + if (update->change_mask & PW_LINK_CHANGE_MASK_FORMAT) { if (info->format) free(info->format); info->format = spa_format_copy(update->format); diff --git a/src/pipewire/introspect.h b/src/pipewire/introspect.h index fa41353fc..841382a4f 100644 --- a/src/pipewire/introspect.h +++ b/src/pipewire/introspect.h @@ -100,6 +100,10 @@ void pw_core_info_free(struct pw_core_info *info); /** The module information. Extra information can be added in later versions \memberof pw_introspect */ struct pw_module_info { +#define PW_MODULE_CHANGE_MASK_NAME (1 << 0) +#define PW_MODULE_CHANGE_MASK_FILENAME (1 << 1) +#define PW_MODULE_CHANGE_MASK_ARGS (1 << 2) +#define PW_MODULE_CHANGE_MASK_PROPS (1 << 3) uint64_t change_mask; /**< bitfield of changed fields since last call */ const char *name; /**< name of the module */ const char *filename; /**< filename of the module */ diff --git a/src/pipewire/link.c b/src/pipewire/link.c index fa3510299..7cc473a1c 100644 --- a/src/pipewire/link.c +++ b/src/pipewire/link.c @@ -1120,6 +1120,7 @@ struct pw_link *pw_link_new(struct pw_core *core, this->info.input_node_id = input_node->global->id; this->info.input_port_id = input->port_id; this->info.format = NULL; + this->info.props = this->properties ? &this->properties->dict : NULL; spa_graph_port_init(&this->rt.out_port, PW_DIRECTION_OUTPUT, diff --git a/src/pipewire/node.c b/src/pipewire/node.c index a87093b43..aa373b06e 100644 --- a/src/pipewire/node.c +++ b/src/pipewire/node.c @@ -315,6 +315,7 @@ struct pw_node *pw_node_new(struct pw_core *core, spa_hook_list_init(&this->listener_list); this->info.state = PW_NODE_STATE_CREATING; + this->info.props = &this->properties->dict; spa_list_init(&this->input_ports); pw_map_init(&this->input_port_map, 64, 64); diff --git a/src/pipewire/port.c b/src/pipewire/port.c index 95abdb532..ee1b975bd 100644 --- a/src/pipewire/port.c +++ b/src/pipewire/port.c @@ -268,13 +268,13 @@ bool pw_port_add(struct pw_port *port, struct pw_node *node) spa_list_insert(&node->input_ports, &port->link); pw_map_insert_at(&node->input_port_map, port_id, port); node->info.n_input_ports++; - node->info.change_mask |= 1 << 1; + node->info.change_mask |= PW_NODE_CHANGE_MASK_INPUT_PORTS; } else { spa_list_insert(&node->output_ports, &port->link); pw_map_insert_at(&node->output_port_map, port_id, port); node->info.n_output_ports++; - node->info.change_mask |= 1 << 3; + node->info.change_mask |= PW_NODE_CHANGE_MASK_OUTPUT_PORTS; } spa_node_port_set_io(node->node, port->direction, port_id, &port->io); diff --git a/src/tools/pipewire-monitor.c b/src/tools/pipewire-monitor.c index d6f6becac..543885389 100644 --- a/src/tools/pipewire-monitor.c +++ b/src/tools/pipewire-monitor.c @@ -56,10 +56,12 @@ static void print_properties(struct spa_dict *props, char mark) { struct spa_dict_item *item; - if (props == NULL) - return; - printf("%c\tproperties:\n", mark); + if (props == NULL || props->n_items == 0) { + printf("\t\tnone\n"); + return; + } + spa_dict_for_each(item, props) { printf("%c\t\t%s = \"%s\"\n", mark, item->key, item->value); } @@ -238,7 +240,7 @@ static void link_event_info(void *object, struct pw_link_info *info) if (info->format) spa_debug_format(info->format); else - printf("\t none\n"); + printf("\t\tnone\n"); print_properties(info->props, MARK_CHANGE(3)); } }