mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-02 09:01:50 -05:00
Add core introspection
Use global ids in info messages to refer to global objects.
This commit is contained in:
parent
0d0385b881
commit
8ce3f949e2
10 changed files with 102 additions and 9 deletions
|
|
@ -103,8 +103,31 @@ core_dispatch_func (void *object,
|
|||
{
|
||||
PinosContextImpl *impl = data;
|
||||
PinosContext *this = &impl->this;
|
||||
PinosProxy *proxy = object;
|
||||
|
||||
switch (type) {
|
||||
case PINOS_MESSAGE_CORE_INFO:
|
||||
{
|
||||
PinosMessageCoreInfo *m = message;
|
||||
PinosSubscriptionEvent event;
|
||||
|
||||
pinos_log_debug ("got core info %d", type);
|
||||
if (proxy->user_data == NULL)
|
||||
event = PINOS_SUBSCRIPTION_EVENT_NEW;
|
||||
else
|
||||
event = PINOS_SUBSCRIPTION_EVENT_CHANGE;
|
||||
|
||||
proxy->user_data = pinos_core_info_update (proxy->user_data, m->info);
|
||||
|
||||
if (impl->subscribe_func) {
|
||||
impl->subscribe_func (this,
|
||||
event,
|
||||
proxy->type,
|
||||
proxy->id,
|
||||
impl->subscribe_data);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case PINOS_MESSAGE_NOTIFY_DONE:
|
||||
{
|
||||
PinosMessageNotifyDone *nd = message;
|
||||
|
|
|
|||
|
|
@ -137,6 +137,73 @@ pinos_spa_dict_copy (SpaDict *dict)
|
|||
return copy;
|
||||
}
|
||||
|
||||
PinosCoreInfo *
|
||||
pinos_core_info_update (PinosCoreInfo *info,
|
||||
const PinosCoreInfo *update)
|
||||
{
|
||||
uint64_t change_mask;
|
||||
|
||||
if (update == NULL)
|
||||
return info;
|
||||
|
||||
if (info == NULL) {
|
||||
info = calloc (1, sizeof (PinosCoreInfo));
|
||||
change_mask = ~0;
|
||||
} else {
|
||||
change_mask = info->change_mask | update->change_mask;
|
||||
}
|
||||
info->id = update->id;
|
||||
info->change_mask = change_mask;
|
||||
|
||||
if (update->change_mask & (1 << 0)) {
|
||||
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 (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 (info->version)
|
||||
free ((void*)info->version);
|
||||
info->version = update->version ? strdup (update->version) : NULL;
|
||||
}
|
||||
if (update->change_mask & (1 << 3)) {
|
||||
if (info->name)
|
||||
free ((void*)info->name);
|
||||
info->name = update->name ? strdup (update->name) : NULL;
|
||||
}
|
||||
if (update->change_mask & (1 << 4))
|
||||
info->cookie = update->cookie;
|
||||
if (update->change_mask & (1 << 5)) {
|
||||
if (info->props)
|
||||
pinos_spa_dict_destroy (info->props);
|
||||
info->props = pinos_spa_dict_copy (update->props);
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
void
|
||||
pinos_core_info_free (PinosCoreInfo *info)
|
||||
{
|
||||
if (info == NULL)
|
||||
return;
|
||||
|
||||
if (info->user_name)
|
||||
free ((void*)info->user_name);
|
||||
if (info->host_name)
|
||||
free ((void*)info->host_name);
|
||||
if (info->version)
|
||||
free ((void*)info->version);
|
||||
if (info->name)
|
||||
free ((void*)info->name);
|
||||
if (info->props)
|
||||
pinos_spa_dict_destroy (info->props);
|
||||
free (info);
|
||||
}
|
||||
|
||||
PinosNodeInfo *
|
||||
pinos_node_info_update (PinosNodeInfo *info,
|
||||
const PinosNodeInfo *update)
|
||||
|
|
@ -225,7 +292,7 @@ pinos_module_info_update (PinosModuleInfo *info,
|
|||
}
|
||||
|
||||
void
|
||||
pinos_module_info_free (PinosModuleInfo *info)
|
||||
pinos_module_info_free (PinosModuleInfo *info)
|
||||
{
|
||||
if (info == NULL)
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -69,7 +69,6 @@ SpaBuffer *
|
|||
pinos_serialize_buffer_deserialize (void *src, off_t offset)
|
||||
{
|
||||
SpaBuffer *b;
|
||||
unsigned int i;
|
||||
|
||||
b = SPA_MEMBER (src, offset, SpaBuffer);
|
||||
if (b->metas)
|
||||
|
|
|
|||
|
|
@ -1080,7 +1080,6 @@ pinos_stream_send_buffer (PinosStream *stream,
|
|||
{
|
||||
PinosStreamImpl *impl = SPA_CONTAINER_OF (stream, PinosStreamImpl, this);
|
||||
BufferId *bid;
|
||||
unsigned int i;
|
||||
|
||||
if ((bid = find_buffer (stream, id))) {
|
||||
uint8_t cmd = PINOS_TRANSPORT_CMD_HAVE_DATA;
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ client_bind_func (PinosGlobal *global,
|
|||
spa_list_insert (this->resource_list.prev, &resource->link);
|
||||
|
||||
m.info = &info;
|
||||
info.id = resource->id;
|
||||
info.id = global->id;
|
||||
info.change_mask = ~0;
|
||||
info.props = this->properties ? &this->properties->dict : NULL;
|
||||
|
||||
|
|
|
|||
|
|
@ -187,7 +187,7 @@ core_bind_func (PinosGlobal *global,
|
|||
pinos_log_debug ("core %p: bound to %d", global->object, resource->id);
|
||||
|
||||
m.info = &info;
|
||||
info.id = resource->id;
|
||||
info.id = global->id;
|
||||
info.change_mask = ~0;
|
||||
info.user_name = "wim";
|
||||
info.host_name = "wtay";
|
||||
|
|
|
|||
|
|
@ -775,7 +775,7 @@ link_bind_func (PinosGlobal *global,
|
|||
spa_list_insert (this->resource_list.prev, &resource->link);
|
||||
|
||||
m.info = &info;
|
||||
info.id = resource->id;
|
||||
info.id = global->id;
|
||||
info.change_mask = ~0;
|
||||
info.output_node_id = this->output ? this->output->node->global->id : -1;
|
||||
info.output_port_id = this->output ? this->output->port_id : -1;
|
||||
|
|
|
|||
|
|
@ -130,7 +130,7 @@ module_bind_func (PinosGlobal *global,
|
|||
pinos_log_debug ("module %p: bound to %d", global->object, resource->id);
|
||||
|
||||
m.info = &info;
|
||||
info.id = resource->id;
|
||||
info.id = global->id;
|
||||
info.change_mask = ~0;
|
||||
info.name = this->name;
|
||||
info.filename = this->filename;
|
||||
|
|
|
|||
|
|
@ -432,7 +432,7 @@ node_bind_func (PinosGlobal *global,
|
|||
spa_list_insert (this->resource_list.prev, &resource->link);
|
||||
|
||||
m.info = &info;
|
||||
info.id = resource->id;
|
||||
info.id = global->id;
|
||||
info.change_mask = ~0;
|
||||
info.name = this->name;
|
||||
info.state = this->state;
|
||||
|
|
@ -817,7 +817,7 @@ pinos_node_update_state (PinosNode *node,
|
|||
info.state = node->state;
|
||||
|
||||
spa_list_for_each (resource, &node->resource_list, link) {
|
||||
info.id = resource->id;
|
||||
info.id = node->global->id;
|
||||
pinos_resource_send_message (resource,
|
||||
PINOS_MESSAGE_NODE_INFO,
|
||||
&m,
|
||||
|
|
|
|||
|
|
@ -169,6 +169,11 @@ dump_object (PinosContext *context,
|
|||
uint32_t id,
|
||||
DumpData *data)
|
||||
{
|
||||
if (type == context->uri.core) {
|
||||
pinos_context_get_core_info (context,
|
||||
dump_core_info,
|
||||
data);
|
||||
}
|
||||
if (type == context->uri.node) {
|
||||
pinos_context_get_node_info_by_id (context,
|
||||
id,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue