introspect: improve node introspection

This commit is contained in:
Wim Taymans 2017-07-04 11:08:40 +02:00
parent 7cccede185
commit 4558073da6
3 changed files with 15 additions and 6 deletions

View file

@ -33,7 +33,7 @@
/** \cond */ /** \cond */
#define MAX_BUFFER_SIZE 4096 #define MAX_BUFFER_SIZE (1024 * 32)
#define MAX_FDS 28 #define MAX_FDS 28
static bool debug_messages = 0; static bool debug_messages = 0;

View file

@ -204,8 +204,10 @@ struct pw_node_info *pw_node_info_update(struct pw_node_info *info,
free((void *) info->name); free((void *) info->name);
info->name = update->name ? strdup(update->name) : NULL; info->name = update->name ? strdup(update->name) : NULL;
} }
if (update->change_mask & (1 << 1)) if (update->change_mask & (1 << 1)) {
info->max_input_ports = update->max_input_ports; info->max_input_ports = update->max_input_ports;
info->n_input_ports = update->n_input_ports;
}
if (update->change_mask & (1 << 2)) { if (update->change_mask & (1 << 2)) {
for (i = 0; i < info->n_input_formats; i++) for (i = 0; i < info->n_input_formats; i++)
free(info->input_formats[i]); free(info->input_formats[i]);
@ -222,8 +224,10 @@ struct pw_node_info *pw_node_info_update(struct pw_node_info *info,
info->input_formats[i] = spa_format_copy(update->input_formats[i]); info->input_formats[i] = spa_format_copy(update->input_formats[i]);
} }
} }
if (update->change_mask & (1 << 3)) if (update->change_mask & (1 << 3)) {
info->max_output_ports = update->max_output_ports; info->max_output_ports = update->max_output_ports;
info->n_output_ports = update->n_output_ports;
}
if (update->change_mask & (1 << 4)) { if (update->change_mask & (1 << 4)) {
for (i = 0; i < info->n_output_formats; i++) for (i = 0; i < info->n_output_formats; i++)
free(info->output_formats[i]); free(info->output_formats[i]);

View file

@ -383,6 +383,7 @@ node_bind_func(struct pw_global *global, struct pw_client *client, uint32_t vers
this->info.change_mask = ~0; this->info.change_mask = ~0;
pw_node_notify_info(resource, &this->info); pw_node_notify_info(resource, &this->info);
this->info.change_mask = 0;
return SPA_RESULT_OK; return SPA_RESULT_OK;
@ -592,6 +593,7 @@ void pw_node_destroy(struct pw_node *node)
struct pw_port *pw_node_get_free_port(struct pw_node *node, enum pw_direction direction) struct pw_port *pw_node_get_free_port(struct pw_node *node, enum pw_direction direction)
{ {
uint32_t *n_ports, max_ports; uint32_t *n_ports, max_ports;
uint64_t change_mask;
struct spa_list *ports; struct spa_list *ports;
struct pw_port *port = NULL, *p, **portmap; struct pw_port *port = NULL, *p, **portmap;
int res; int res;
@ -602,11 +604,13 @@ struct pw_port *pw_node_get_free_port(struct pw_node *node, enum pw_direction di
n_ports = &node->info.n_input_ports; n_ports = &node->info.n_input_ports;
ports = &node->input_ports; ports = &node->input_ports;
portmap = node->input_port_map; portmap = node->input_port_map;
change_mask = 1 << 1;
} else { } else {
max_ports = node->info.max_output_ports; max_ports = node->info.max_output_ports;
n_ports = &node->info.n_output_ports; n_ports = &node->info.n_output_ports;
ports = &node->output_ports; ports = &node->output_ports;
portmap = node->output_port_map; portmap = node->output_port_map;
change_mask = 1 << 3;
} }
pw_log_debug("node %p: direction %d max %u, n %u", node, direction, max_ports, *n_ports); pw_log_debug("node %p: direction %d max %u, n %u", node, direction, max_ports, *n_ports);
@ -637,6 +641,7 @@ struct pw_port *pw_node_get_free_port(struct pw_node *node, enum pw_direction di
spa_node_port_set_io(node->node, direction, i, &port->io); spa_node_port_set_io(node->node, direction, i, &port->io);
} }
(*n_ports)++; (*n_ports)++;
node->info.change_mask |= change_mask;
portmap[i] = port; portmap[i] = port;
break; break;
} }
@ -783,9 +788,9 @@ void pw_node_update_state(struct pw_node *node, enum pw_node_state state, char *
pw_signal_emit(&node->state_changed, node, old, state); pw_signal_emit(&node->state_changed, node, old, state);
node->info.change_mask = 1 << 5; node->info.change_mask |= 1 << 5;
spa_list_for_each(resource, &node->resource_list, link) { spa_list_for_each(resource, &node->resource_list, link)
pw_node_notify_info(resource, &node->info); pw_node_notify_info(resource, &node->info);
} node->info.change_mask = 0;
} }
} }