mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-13 13:30:05 -05:00
improve error reporting
Move signals from core to the objects themselves Use per object info to track object signals Use periods in alsasink and source
This commit is contained in:
parent
fb69758251
commit
cae971e106
23 changed files with 573 additions and 384 deletions
|
|
@ -196,10 +196,11 @@ spa_proxy_node_send_command (SpaNode *node,
|
|||
/* send start */
|
||||
cnc.seq = this->seq++;
|
||||
cnc.command = command;
|
||||
pinos_resource_send_message (this->resource,
|
||||
PINOS_MESSAGE_NODE_COMMAND,
|
||||
&cnc,
|
||||
true);
|
||||
pinos_client_send_message (this->resource->client,
|
||||
this->resource,
|
||||
PINOS_MESSAGE_NODE_COMMAND,
|
||||
&cnc,
|
||||
true);
|
||||
if (command->type == SPA_NODE_COMMAND_START) {
|
||||
uint8_t cmd = PINOS_TRANSPORT_CMD_NEED_DATA;
|
||||
write (this->data_source.fd, &cmd, 1);
|
||||
|
|
@ -214,10 +215,11 @@ spa_proxy_node_send_command (SpaNode *node,
|
|||
|
||||
/* send start */
|
||||
cnc.command = command;
|
||||
pinos_resource_send_message (this->resource,
|
||||
PINOS_MESSAGE_NODE_COMMAND,
|
||||
&cnc,
|
||||
true);
|
||||
pinos_client_send_message (this->resource->client,
|
||||
this->resource,
|
||||
PINOS_MESSAGE_NODE_COMMAND,
|
||||
&cnc,
|
||||
true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -498,10 +500,11 @@ spa_proxy_node_port_set_format (SpaNode *node,
|
|||
sf.port_id = port_id;
|
||||
sf.flags = flags;
|
||||
sf.format = (SpaFormat *) format;
|
||||
pinos_resource_send_message (this->resource,
|
||||
PINOS_MESSAGE_SET_FORMAT,
|
||||
&sf,
|
||||
true);
|
||||
pinos_client_send_message (this->resource->client,
|
||||
this->resource,
|
||||
PINOS_MESSAGE_SET_FORMAT,
|
||||
&sf,
|
||||
true);
|
||||
return SPA_RESULT_RETURN_ASYNC (sf.seq);
|
||||
}
|
||||
|
||||
|
|
@ -680,10 +683,11 @@ spa_proxy_node_port_use_buffers (SpaNode *node,
|
|||
am.flags = msh->flags;
|
||||
am.offset = msh->offset;
|
||||
am.size = msh->size;
|
||||
pinos_resource_send_message (this->resource,
|
||||
PINOS_MESSAGE_ADD_MEM,
|
||||
&am,
|
||||
false);
|
||||
pinos_client_send_message (this->resource->client,
|
||||
this->resource,
|
||||
PINOS_MESSAGE_ADD_MEM,
|
||||
&am,
|
||||
false);
|
||||
|
||||
mb[i].buffer = &b->buffer;
|
||||
mb[i].mem_id = am.mem_id;
|
||||
|
|
@ -710,10 +714,11 @@ spa_proxy_node_port_use_buffers (SpaNode *node,
|
|||
am.flags = d->flags;
|
||||
am.offset = d->mapoffset;
|
||||
am.size = d->maxsize;
|
||||
pinos_resource_send_message (this->resource,
|
||||
PINOS_MESSAGE_ADD_MEM,
|
||||
&am,
|
||||
false);
|
||||
pinos_client_send_message (this->resource->client,
|
||||
this->resource,
|
||||
PINOS_MESSAGE_ADD_MEM,
|
||||
&am,
|
||||
false);
|
||||
b->buffer.datas[j].type = SPA_DATA_TYPE_ID;
|
||||
b->buffer.datas[j].data = SPA_UINT32_TO_PTR (n_mem);
|
||||
n_mem++;
|
||||
|
|
@ -736,10 +741,11 @@ spa_proxy_node_port_use_buffers (SpaNode *node,
|
|||
ub.port_id = port_id;
|
||||
ub.n_buffers = n_buffers;
|
||||
ub.buffers = mb;
|
||||
pinos_resource_send_message (this->resource,
|
||||
PINOS_MESSAGE_USE_BUFFERS,
|
||||
&ub,
|
||||
true);
|
||||
pinos_client_send_message (this->resource->client,
|
||||
this->resource,
|
||||
PINOS_MESSAGE_USE_BUFFERS,
|
||||
&ub,
|
||||
true);
|
||||
|
||||
return SPA_RESULT_RETURN_ASYNC (ub.seq);
|
||||
}
|
||||
|
|
@ -772,10 +778,10 @@ spa_proxy_node_port_alloc_buffers (SpaNode *node,
|
|||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void
|
||||
copy_meta_in (SpaProxy *this, SpaProxyPort *port, uint32_t buffer_id)
|
||||
{
|
||||
#if 0
|
||||
ProxyBuffer *b = &port->buffers[buffer_id];
|
||||
unsigned int i;
|
||||
|
||||
|
|
@ -791,13 +797,13 @@ copy_meta_in (SpaProxy *this, SpaProxyPort *port, uint32_t buffer_id)
|
|||
memcpy (b->outbuf->datas[i].data, b->datas[i].data, b->buffer.datas[i].size);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
static void
|
||||
copy_meta_out (SpaProxy *this, SpaProxyPort *port, uint32_t buffer_id)
|
||||
{
|
||||
#if 0
|
||||
ProxyBuffer *b = &port->buffers[buffer_id];
|
||||
unsigned int i;
|
||||
|
||||
|
|
@ -813,8 +819,8 @@ copy_meta_out (SpaProxy *this, SpaProxyPort *port, uint32_t buffer_id)
|
|||
memcpy (b->datas[i].data, b->outbuf->datas[i].data, b->outbuf->datas[i].size);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
static SpaResult
|
||||
spa_proxy_node_port_reuse_buffer (SpaNode *node,
|
||||
|
|
@ -840,6 +846,7 @@ spa_proxy_node_port_reuse_buffer (SpaNode *node,
|
|||
rb.port_id = port_id;
|
||||
rb.buffer_id = buffer_id;
|
||||
pinos_transport_add_event (pnode->transport, &rb.event);
|
||||
|
||||
cmd = PINOS_TRANSPORT_CMD_HAVE_EVENT;
|
||||
write (this->data_source.fd, &cmd, 1);
|
||||
|
||||
|
|
@ -1074,7 +1081,8 @@ proxy_on_data_fd_events (SpaSource *source)
|
|||
if (source->rmask & SPA_IO_IN) {
|
||||
uint8_t cmd;
|
||||
|
||||
read (this->data_source.fd, &cmd, 1);
|
||||
if (read (this->data_source.fd, &cmd, 1) < 1)
|
||||
return;
|
||||
|
||||
if (cmd & PINOS_TRANSPORT_CMD_HAVE_EVENT) {
|
||||
SpaNodeEvent event;
|
||||
|
|
@ -1086,17 +1094,6 @@ proxy_on_data_fd_events (SpaSource *source)
|
|||
}
|
||||
if (cmd & PINOS_TRANSPORT_CMD_HAVE_DATA) {
|
||||
SpaNodeEventHaveOutput ho;
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < this->n_outputs; i++) {
|
||||
SpaProxyPort *port = &this->out_ports[i];
|
||||
SpaPortOutput *output;
|
||||
|
||||
if ((output = port->io) == NULL)
|
||||
continue;
|
||||
|
||||
copy_meta_in (this, port, output->buffer_id);
|
||||
}
|
||||
ho.event.type = SPA_NODE_EVENT_TYPE_HAVE_OUTPUT;
|
||||
ho.event.size = sizeof (ho);
|
||||
ho.port_id = 0;
|
||||
|
|
@ -1191,10 +1188,11 @@ on_transport_changed (PinosListener *listener,
|
|||
tu.memfd = info.memfd;
|
||||
tu.offset = info.offset;
|
||||
tu.size = info.size;
|
||||
pinos_resource_send_message (this->resource,
|
||||
PINOS_MESSAGE_TRANSPORT_UPDATE,
|
||||
&tu,
|
||||
true);
|
||||
pinos_client_send_message (this->resource->client,
|
||||
this->resource,
|
||||
PINOS_MESSAGE_TRANSPORT_UPDATE,
|
||||
&tu,
|
||||
true);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -1379,7 +1377,7 @@ pinos_client_node_get_data_socket (PinosClientNode *this,
|
|||
if (impl->data_fd == -1) {
|
||||
int fd[2];
|
||||
|
||||
if (socketpair (AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0, fd) != 0)
|
||||
if (socketpair (AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC | SOCK_NONBLOCK, 0, fd) != 0)
|
||||
return SPA_RESULT_ERRNO;
|
||||
|
||||
impl->proxy.data_source.fd = fd[0];
|
||||
|
|
|
|||
|
|
@ -88,14 +88,16 @@ client_bind_func (PinosGlobal *global,
|
|||
info.change_mask = ~0;
|
||||
info.props = this->properties ? &this->properties->dict : NULL;
|
||||
|
||||
return pinos_resource_send_message (resource,
|
||||
PINOS_MESSAGE_CLIENT_INFO,
|
||||
&m,
|
||||
true);
|
||||
return pinos_client_send_message (client,
|
||||
resource,
|
||||
PINOS_MESSAGE_CLIENT_INFO,
|
||||
&m,
|
||||
true);
|
||||
no_mem:
|
||||
pinos_resource_send_error (client->core_resource,
|
||||
SPA_RESULT_NO_MEMORY,
|
||||
"no memory");
|
||||
pinos_client_send_error (client,
|
||||
client->core_resource,
|
||||
SPA_RESULT_NO_MEMORY,
|
||||
"no memory");
|
||||
return SPA_RESULT_NO_MEMORY;
|
||||
}
|
||||
|
||||
|
|
@ -129,6 +131,8 @@ pinos_client_new (PinosCore *core,
|
|||
this->properties = properties;
|
||||
|
||||
spa_list_init (&this->resource_list);
|
||||
pinos_signal_init (&this->resource_added);
|
||||
pinos_signal_init (&this->resource_removed);
|
||||
|
||||
pinos_map_init (&this->objects, 64);
|
||||
pinos_signal_init (&this->destroy_signal);
|
||||
|
|
@ -203,13 +207,15 @@ do_send_message (PinosAccessData *data)
|
|||
if (data->res == SPA_RESULT_SKIPPED) {
|
||||
data->res = SPA_RESULT_OK;
|
||||
} else if (data->res == SPA_RESULT_NO_PERMISSION) {
|
||||
pinos_resource_send_error (data->resource,
|
||||
data->res,
|
||||
"no permission");
|
||||
pinos_client_send_error (data->client,
|
||||
data->resource,
|
||||
data->res,
|
||||
"no permission");
|
||||
} else if (SPA_RESULT_IS_ERROR (data->res)) {
|
||||
pinos_resource_send_error (data->resource,
|
||||
data->res,
|
||||
"error %d", data->res);
|
||||
pinos_client_send_error (data->client,
|
||||
data->resource,
|
||||
data->res,
|
||||
"error %d", data->res);
|
||||
} else {
|
||||
data->res = impl->send_func (data->resource,
|
||||
data->resource->id,
|
||||
|
|
@ -255,6 +261,33 @@ pinos_client_send_message (PinosClient *client,
|
|||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
SpaResult
|
||||
pinos_client_send_error (PinosClient *client,
|
||||
PinosResource *resource,
|
||||
SpaResult res,
|
||||
const char *message,
|
||||
...)
|
||||
{
|
||||
PinosMessageError m;
|
||||
char buffer[128];
|
||||
va_list ap;
|
||||
|
||||
va_start (ap, message);
|
||||
vsnprintf (buffer, sizeof (buffer), message, ap);
|
||||
va_end (ap);
|
||||
|
||||
m.id = resource->id;
|
||||
m.res = res;
|
||||
m.error = buffer;
|
||||
|
||||
pinos_log_error ("client %p: %u send error %d (%s)", client, resource->id, res, buffer);
|
||||
|
||||
return pinos_client_send_message (client,
|
||||
client->core_resource,
|
||||
PINOS_MESSAGE_ERROR,
|
||||
&m,
|
||||
true);
|
||||
}
|
||||
|
||||
void
|
||||
pinos_client_update_properties (PinosClient *client,
|
||||
|
|
@ -282,9 +315,10 @@ pinos_client_update_properties (PinosClient *client,
|
|||
info.props = client->properties ? &client->properties->dict : NULL;
|
||||
|
||||
spa_list_for_each (resource, &client->resource_list, link) {
|
||||
pinos_resource_send_message (resource,
|
||||
PINOS_MESSAGE_CLIENT_INFO,
|
||||
&m,
|
||||
true);
|
||||
pinos_client_send_message (client,
|
||||
resource,
|
||||
PINOS_MESSAGE_CLIENT_INFO,
|
||||
&m,
|
||||
true);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,6 +60,12 @@ struct _PinosClient {
|
|||
PinosMap objects;
|
||||
|
||||
SpaList resource_list;
|
||||
PINOS_SIGNAL (resource_added, (PinosListener *listener,
|
||||
PinosClient *client,
|
||||
PinosResource *resource));
|
||||
PINOS_SIGNAL (resource_removed, (PinosListener *listener,
|
||||
PinosClient *client,
|
||||
PinosResource *resource));
|
||||
|
||||
PINOS_SIGNAL (destroy_signal, (PinosListener *listener,
|
||||
PinosClient *client));
|
||||
|
|
@ -80,6 +86,11 @@ SpaResult pinos_client_send_message (PinosClient *client,
|
|||
void *message,
|
||||
bool flush);
|
||||
|
||||
SpaResult pinos_client_send_error (PinosClient *client,
|
||||
PinosResource *resource,
|
||||
SpaResult res,
|
||||
const char *message, ...);
|
||||
|
||||
void pinos_client_update_properties (PinosClient *client,
|
||||
const SpaDict *dict);
|
||||
|
||||
|
|
|
|||
|
|
@ -57,9 +57,10 @@ registry_dispatch_func (void *object,
|
|||
break;
|
||||
|
||||
if (&global->link == &this->global_list) {
|
||||
pinos_resource_send_error (resource,
|
||||
SPA_RESULT_INVALID_OBJECT_ID,
|
||||
"unknown object id %u", m->id);
|
||||
pinos_client_send_error (client,
|
||||
resource,
|
||||
SPA_RESULT_INVALID_OBJECT_ID,
|
||||
"unknown object id %u", m->id);
|
||||
return SPA_RESULT_ERROR;
|
||||
}
|
||||
pinos_log_debug ("global %p: bind object id %d", global, m->id);
|
||||
|
|
@ -127,16 +128,18 @@ core_dispatch_func (void *object,
|
|||
|
||||
ng.id = global->id;
|
||||
ng.type = spa_id_map_get_uri (this->uri.map, global->type);
|
||||
pinos_resource_send_message (registry_resource,
|
||||
PINOS_MESSAGE_NOTIFY_GLOBAL,
|
||||
&ng,
|
||||
false);
|
||||
pinos_client_send_message (client,
|
||||
registry_resource,
|
||||
PINOS_MESSAGE_NOTIFY_GLOBAL,
|
||||
&ng,
|
||||
false);
|
||||
}
|
||||
nd.seq = m->seq;
|
||||
pinos_resource_send_message (client->core_resource,
|
||||
PINOS_MESSAGE_NOTIFY_DONE,
|
||||
&nd,
|
||||
true);
|
||||
pinos_client_send_message (client,
|
||||
client->core_resource,
|
||||
PINOS_MESSAGE_NOTIFY_DONE,
|
||||
&nd,
|
||||
true);
|
||||
break;
|
||||
}
|
||||
case PINOS_MESSAGE_CREATE_CLIENT_NODE:
|
||||
|
|
@ -165,18 +168,20 @@ core_dispatch_func (void *object,
|
|||
goto no_mem;
|
||||
|
||||
if ((res = pinos_client_node_get_data_socket (node, &data_fd)) < 0) {
|
||||
pinos_resource_send_error (resource,
|
||||
SPA_RESULT_ERROR,
|
||||
"can't get data fd");
|
||||
pinos_client_send_error (client,
|
||||
resource,
|
||||
SPA_RESULT_ERROR,
|
||||
"can't get data fd");
|
||||
break;
|
||||
}
|
||||
|
||||
r.seq = m->seq;
|
||||
r.datafd = data_fd;
|
||||
pinos_resource_send_message (node->resource,
|
||||
PINOS_MESSAGE_CREATE_CLIENT_NODE_DONE,
|
||||
&r,
|
||||
true);
|
||||
pinos_client_send_message (client,
|
||||
node->resource,
|
||||
PINOS_MESSAGE_CREATE_CLIENT_NODE_DONE,
|
||||
&r,
|
||||
true);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
|
@ -186,9 +191,10 @@ core_dispatch_func (void *object,
|
|||
return SPA_RESULT_OK;
|
||||
|
||||
no_mem:
|
||||
pinos_resource_send_error (resource,
|
||||
SPA_RESULT_NO_MEMORY,
|
||||
"no memory");
|
||||
pinos_client_send_error (client,
|
||||
resource,
|
||||
SPA_RESULT_NO_MEMORY,
|
||||
"no memory");
|
||||
return SPA_RESULT_NO_MEMORY;
|
||||
}
|
||||
|
||||
|
|
@ -237,10 +243,11 @@ core_bind_func (PinosGlobal *global,
|
|||
info.cookie = random ();
|
||||
info.props = NULL;
|
||||
|
||||
return pinos_resource_send_message (resource,
|
||||
PINOS_MESSAGE_CORE_INFO,
|
||||
&m,
|
||||
true);
|
||||
return pinos_client_send_message (resource->client,
|
||||
resource,
|
||||
PINOS_MESSAGE_CORE_INFO,
|
||||
&m,
|
||||
true);
|
||||
no_mem:
|
||||
pinos_log_error ("can't create core resource");
|
||||
return SPA_RESULT_NO_MEMORY;
|
||||
|
|
@ -289,14 +296,6 @@ pinos_core_new (PinosMainLoop *main_loop)
|
|||
pinos_signal_init (&this->destroy_signal);
|
||||
pinos_signal_init (&this->global_added);
|
||||
pinos_signal_init (&this->global_removed);
|
||||
pinos_signal_init (&this->node_state_request);
|
||||
pinos_signal_init (&this->node_state_changed);
|
||||
pinos_signal_init (&this->port_added);
|
||||
pinos_signal_init (&this->port_removed);
|
||||
pinos_signal_init (&this->port_unlinked);
|
||||
pinos_signal_init (&this->link_state_changed);
|
||||
pinos_signal_init (&this->node_unlink);
|
||||
pinos_signal_init (&this->node_unlink_done);
|
||||
|
||||
this->global = pinos_core_add_global (this,
|
||||
NULL,
|
||||
|
|
@ -367,10 +366,11 @@ pinos_core_add_global (PinosCore *core,
|
|||
pinos_log_debug ("global %p: new %u %s", this, ng.id, ng.type);
|
||||
|
||||
spa_list_for_each (registry, &core->registry_resource_list, link) {
|
||||
pinos_resource_send_message (registry,
|
||||
PINOS_MESSAGE_NOTIFY_GLOBAL,
|
||||
&ng,
|
||||
true);
|
||||
pinos_client_send_message (registry->client,
|
||||
registry,
|
||||
PINOS_MESSAGE_NOTIFY_GLOBAL,
|
||||
&ng,
|
||||
true);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
|
@ -389,9 +389,10 @@ pinos_global_bind (PinosGlobal *global,
|
|||
res = impl->bind (global, client, version, id);
|
||||
} else {
|
||||
res = SPA_RESULT_NOT_IMPLEMENTED;
|
||||
pinos_resource_send_error (client->core_resource,
|
||||
res,
|
||||
"can't bind object id %d", id);
|
||||
pinos_client_send_error (client,
|
||||
client->core_resource,
|
||||
res,
|
||||
"can't bind object id %d", id);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
|
@ -408,10 +409,11 @@ pinos_global_destroy (PinosGlobal *global)
|
|||
|
||||
ng.id = global->id;
|
||||
spa_list_for_each (registry, &core->registry_resource_list, link) {
|
||||
pinos_resource_send_message (registry,
|
||||
PINOS_MESSAGE_NOTIFY_GLOBAL_REMOVE,
|
||||
&ng,
|
||||
true);
|
||||
pinos_client_send_message (registry->client,
|
||||
registry,
|
||||
PINOS_MESSAGE_NOTIFY_GLOBAL_REMOVE,
|
||||
&ng,
|
||||
true);
|
||||
}
|
||||
|
||||
pinos_map_remove (&core->objects, global->id);
|
||||
|
|
|
|||
|
|
@ -91,30 +91,6 @@ struct _PinosCore {
|
|||
PINOS_SIGNAL (global_removed, (PinosListener *listener,
|
||||
PinosCore *core,
|
||||
PinosGlobal *global));
|
||||
|
||||
PINOS_SIGNAL (node_state_request, (PinosListener *listener,
|
||||
PinosNode *object,
|
||||
PinosNodeState state));
|
||||
PINOS_SIGNAL (node_state_changed, (PinosListener *listener,
|
||||
PinosNode *object,
|
||||
PinosNodeState old,
|
||||
PinosNodeState state));
|
||||
PINOS_SIGNAL (port_added, (PinosListener *listener,
|
||||
PinosNode *node,
|
||||
PinosPort *port));
|
||||
PINOS_SIGNAL (port_removed, (PinosListener *listener,
|
||||
PinosNode *node,
|
||||
PinosPort *port));
|
||||
|
||||
PINOS_SIGNAL (port_unlinked, (PinosListener *listener,
|
||||
PinosLink *link,
|
||||
PinosPort *port));
|
||||
PINOS_SIGNAL (link_state_changed, (PinosListener *listener,
|
||||
PinosLink *link));
|
||||
PINOS_SIGNAL (node_unlink, (PinosListener *listener,
|
||||
PinosNode *node));
|
||||
PINOS_SIGNAL (node_unlink_done, (PinosListener *listener,
|
||||
PinosNode *node));
|
||||
};
|
||||
|
||||
PinosCore * pinos_core_new (PinosMainLoop *main_loop);
|
||||
|
|
|
|||
|
|
@ -56,9 +56,11 @@ pinos_link_update_state (PinosLink *link,
|
|||
PinosLinkState state,
|
||||
char *error)
|
||||
{
|
||||
if (state != link->state) {
|
||||
PinosLinkState old = link->state;
|
||||
|
||||
if (state != old) {
|
||||
pinos_log_debug ("link %p: update state %s -> %s", link,
|
||||
pinos_link_state_as_string (link->state),
|
||||
pinos_link_state_as_string (old),
|
||||
pinos_link_state_as_string (state));
|
||||
|
||||
link->state = state;
|
||||
|
|
@ -66,7 +68,7 @@ pinos_link_update_state (PinosLink *link,
|
|||
free (link->error);
|
||||
link->error = error;
|
||||
|
||||
pinos_signal_emit (&link->core->link_state_changed, link);
|
||||
pinos_signal_emit (&link->state_changed, link, old, state);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -684,7 +686,7 @@ on_port_destroy (PinosLink *this,
|
|||
pinos_port_clear_buffers (other);
|
||||
}
|
||||
|
||||
pinos_signal_emit (&this->core->port_unlinked, this, port);
|
||||
pinos_signal_emit (&this->port_unlinked, this, port);
|
||||
|
||||
pinos_link_update_state (this, PINOS_LINK_STATE_UNLINKED, NULL);
|
||||
pinos_link_destroy (this);
|
||||
|
|
@ -811,14 +813,16 @@ link_bind_func (PinosGlobal *global,
|
|||
info.input_node_id = this->input ? this->input->node->global->id : -1;
|
||||
info.input_port_id = this->input ? this->input->port_id : -1;
|
||||
|
||||
return pinos_resource_send_message (resource,
|
||||
PINOS_MESSAGE_LINK_INFO,
|
||||
&m,
|
||||
true);
|
||||
return pinos_client_send_message (resource->client,
|
||||
resource,
|
||||
PINOS_MESSAGE_LINK_INFO,
|
||||
&m,
|
||||
true);
|
||||
no_mem:
|
||||
pinos_resource_send_error (client->core_resource,
|
||||
SPA_RESULT_NO_MEMORY,
|
||||
"no memory");
|
||||
pinos_client_send_error (client,
|
||||
client->core_resource,
|
||||
SPA_RESULT_NO_MEMORY,
|
||||
"no memory");
|
||||
return SPA_RESULT_NO_MEMORY;
|
||||
}
|
||||
|
||||
|
|
@ -850,6 +854,8 @@ pinos_link_new (PinosCore *core,
|
|||
this->output = output;
|
||||
|
||||
spa_list_init (&this->resource_list);
|
||||
pinos_signal_init (&this->port_unlinked);
|
||||
pinos_signal_init (&this->state_changed);
|
||||
pinos_signal_init (&this->destroy_signal);
|
||||
pinos_signal_init (&this->free_signal);
|
||||
|
||||
|
|
|
|||
|
|
@ -48,6 +48,10 @@ struct _PinosLink {
|
|||
|
||||
PinosLinkState state;
|
||||
char *error;
|
||||
PINOS_SIGNAL (state_changed, (PinosListener *listener,
|
||||
PinosLink *link,
|
||||
PinosLinkState old,
|
||||
PinosLinkState state));
|
||||
|
||||
PINOS_SIGNAL (destroy_signal, (PinosListener *,
|
||||
PinosLink *));
|
||||
|
|
@ -60,6 +64,9 @@ struct _PinosLink {
|
|||
SpaList output_link;
|
||||
PinosPort *input;
|
||||
SpaList input_link;
|
||||
PINOS_SIGNAL (port_unlinked, (PinosListener *listener,
|
||||
PinosLink *link,
|
||||
PinosPort *port));
|
||||
|
||||
uint32_t queue[64];
|
||||
SpaRingbuffer ringbuffer;
|
||||
|
|
|
|||
|
|
@ -140,14 +140,16 @@ module_bind_func (PinosGlobal *global,
|
|||
info.args = this->args;
|
||||
info.props = NULL;
|
||||
|
||||
return pinos_resource_send_message (resource,
|
||||
PINOS_MESSAGE_MODULE_INFO,
|
||||
&m,
|
||||
true);
|
||||
return pinos_client_send_message (client,
|
||||
resource,
|
||||
PINOS_MESSAGE_MODULE_INFO,
|
||||
&m,
|
||||
true);
|
||||
no_mem:
|
||||
pinos_resource_send_error (resource,
|
||||
SPA_RESULT_NO_MEMORY,
|
||||
"no memory");
|
||||
pinos_client_send_error (client,
|
||||
client->core_resource,
|
||||
SPA_RESULT_NO_MEMORY,
|
||||
"no memory");
|
||||
return SPA_RESULT_NO_MEMORY;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -92,13 +92,13 @@ update_port_ids (PinosNode *node, bool create)
|
|||
node->input_port_map[np->port_id] = np;
|
||||
|
||||
if (!impl->async_init)
|
||||
pinos_signal_emit (&node->core->port_added, node, np);
|
||||
pinos_signal_emit (&node->port_added, node, np);
|
||||
i++;
|
||||
} else if (p) {
|
||||
node->input_port_map[p->port_id] = NULL;
|
||||
ports = ports->next;
|
||||
if (!impl->async_init)
|
||||
pinos_signal_emit (&node->core->port_removed, node, p);
|
||||
pinos_signal_emit (&node->port_removed, node, p);
|
||||
pinos_log_debug ("node %p: input port removed %d", node, p->port_id);
|
||||
pinos_port_destroy (p);
|
||||
} else {
|
||||
|
|
@ -127,13 +127,13 @@ update_port_ids (PinosNode *node, bool create)
|
|||
node->output_port_map[np->port_id] = np;
|
||||
|
||||
if (!impl->async_init)
|
||||
pinos_signal_emit (&node->core->port_added, node, np);
|
||||
pinos_signal_emit (&node->port_added, node, np);
|
||||
i++;
|
||||
} else if (p) {
|
||||
node->output_port_map[p->port_id] = NULL;
|
||||
ports = ports->next;
|
||||
if (!impl->async_init)
|
||||
pinos_signal_emit (&node->core->port_removed, node, p);
|
||||
pinos_signal_emit (&node->port_removed, node, p);
|
||||
pinos_log_debug ("node %p: output port removed %d", node, p->port_id);
|
||||
pinos_port_destroy (p);
|
||||
} else {
|
||||
|
|
@ -443,14 +443,16 @@ node_bind_func (PinosGlobal *global,
|
|||
info.error = this->error;
|
||||
info.props = this->properties ? &this->properties->dict : NULL;
|
||||
|
||||
return pinos_resource_send_message (resource,
|
||||
PINOS_MESSAGE_NODE_INFO,
|
||||
&m,
|
||||
true);
|
||||
return pinos_client_send_message (client,
|
||||
resource,
|
||||
PINOS_MESSAGE_NODE_INFO,
|
||||
&m,
|
||||
true);
|
||||
no_mem:
|
||||
pinos_resource_send_error (resource,
|
||||
SPA_RESULT_NO_MEMORY,
|
||||
"no memory");
|
||||
pinos_client_send_error (client,
|
||||
client->core_resource,
|
||||
SPA_RESULT_NO_MEMORY,
|
||||
"no memory");
|
||||
return SPA_RESULT_NO_MEMORY;
|
||||
}
|
||||
|
||||
|
|
@ -515,6 +517,10 @@ pinos_node_new (PinosCore *core,
|
|||
pinos_log_warn ("node %p: error setting callback", this);
|
||||
|
||||
pinos_signal_init (&this->destroy_signal);
|
||||
pinos_signal_init (&this->port_added);
|
||||
pinos_signal_init (&this->port_removed);
|
||||
pinos_signal_init (&this->state_request);
|
||||
pinos_signal_init (&this->state_changed);
|
||||
pinos_signal_init (&this->free_signal);
|
||||
pinos_signal_init (&this->async_complete);
|
||||
pinos_signal_init (&this->transport_changed);
|
||||
|
|
@ -747,7 +753,7 @@ pinos_node_set_state (PinosNode *node,
|
|||
SpaResult res = SPA_RESULT_OK;
|
||||
PinosNodeImpl *impl = SPA_CONTAINER_OF (node, PinosNodeImpl, this);
|
||||
|
||||
pinos_signal_emit (&node->core->node_state_request, node, state);
|
||||
pinos_signal_emit (&node->state_request, node, state);
|
||||
|
||||
pinos_log_debug ("node %p: set state %s", node, pinos_node_state_as_string (state));
|
||||
|
||||
|
|
@ -814,7 +820,7 @@ pinos_node_update_state (PinosNode *node,
|
|||
node->error = error;
|
||||
node->state = state;
|
||||
|
||||
pinos_signal_emit (&node->core->node_state_changed, node, old, state);
|
||||
pinos_signal_emit (&node->state_changed, node, old, state);
|
||||
|
||||
spa_zero (info);
|
||||
m.info = &info;
|
||||
|
|
@ -824,10 +830,11 @@ pinos_node_update_state (PinosNode *node,
|
|||
|
||||
spa_list_for_each (resource, &node->resource_list, link) {
|
||||
info.id = node->global->id;
|
||||
pinos_resource_send_message (resource,
|
||||
PINOS_MESSAGE_NODE_INFO,
|
||||
&m,
|
||||
true);
|
||||
pinos_client_send_message (resource->client,
|
||||
resource,
|
||||
PINOS_MESSAGE_NODE_INFO,
|
||||
&m,
|
||||
true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,6 +56,13 @@ struct _PinosNode {
|
|||
PinosProperties *properties;
|
||||
PinosNodeState state;
|
||||
char *error;
|
||||
PINOS_SIGNAL (state_request, (PinosListener *listener,
|
||||
PinosNode *object,
|
||||
PinosNodeState state));
|
||||
PINOS_SIGNAL (state_changed, (PinosListener *listener,
|
||||
PinosNode *object,
|
||||
PinosNodeState old,
|
||||
PinosNodeState state));
|
||||
|
||||
SpaHandle *handle;
|
||||
SpaNode *node;
|
||||
|
|
@ -66,6 +73,12 @@ struct _PinosNode {
|
|||
|
||||
SpaList input_ports;
|
||||
SpaList output_ports;
|
||||
PINOS_SIGNAL (port_added, (PinosListener *listener,
|
||||
PinosNode *node,
|
||||
PinosPort *port));
|
||||
PINOS_SIGNAL (port_removed, (PinosListener *listener,
|
||||
PinosNode *node,
|
||||
PinosPort *port));
|
||||
|
||||
PinosPort **input_port_map;
|
||||
PinosPort **output_port_map;
|
||||
|
|
|
|||
|
|
@ -46,7 +46,6 @@ pinos_resource_new (PinosClient *client,
|
|||
|
||||
this->core = client->core;
|
||||
this->client = client;
|
||||
this->id = id;
|
||||
this->type = type;
|
||||
this->object = object;
|
||||
this->destroy = destroy;
|
||||
|
|
@ -55,6 +54,7 @@ pinos_resource_new (PinosClient *client,
|
|||
|
||||
this->id = pinos_map_insert_new (&client->objects, this);
|
||||
pinos_log_debug ("resource %p: new for client %p id %u", this, client, this->id);
|
||||
pinos_signal_emit (&client->resource_added, client, this);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
|
@ -62,19 +62,23 @@ pinos_resource_new (PinosClient *client,
|
|||
void
|
||||
pinos_resource_destroy (PinosResource *resource)
|
||||
{
|
||||
PinosClient *client = resource->client;
|
||||
|
||||
pinos_log_debug ("resource %p: destroy", resource);
|
||||
pinos_signal_emit (&resource->destroy_signal, resource);
|
||||
|
||||
if (resource->client->core_resource) {
|
||||
if (client->core_resource) {
|
||||
PinosMessageRemoveId m;
|
||||
m.id = resource->id;
|
||||
pinos_resource_send_message (resource->client->core_resource,
|
||||
PINOS_MESSAGE_REMOVE_ID,
|
||||
&m,
|
||||
true);
|
||||
pinos_client_send_message (client,
|
||||
client->core_resource,
|
||||
PINOS_MESSAGE_REMOVE_ID,
|
||||
&m,
|
||||
true);
|
||||
}
|
||||
|
||||
pinos_map_remove (&resource->client->objects, resource->id);
|
||||
pinos_map_remove (&client->objects, resource->id);
|
||||
pinos_signal_emit (&client->resource_removed, client, resource);
|
||||
|
||||
if (resource->destroy)
|
||||
resource->destroy (resource);
|
||||
|
|
@ -100,13 +104,15 @@ do_dispatch_message (PinosAccessData *data)
|
|||
PinosResourceImpl *impl = SPA_CONTAINER_OF (data->resource, PinosResourceImpl, this);
|
||||
|
||||
if (data->res == SPA_RESULT_NO_PERMISSION) {
|
||||
pinos_resource_send_error (data->resource,
|
||||
data->res,
|
||||
"no permission");
|
||||
pinos_client_send_error (data->client,
|
||||
data->resource,
|
||||
data->res,
|
||||
"no permission");
|
||||
} else if (SPA_RESULT_IS_ERROR (data->res)) {
|
||||
pinos_resource_send_error (data->resource,
|
||||
data->res,
|
||||
"error %d", data->res);
|
||||
pinos_client_send_error (data->client,
|
||||
data->resource,
|
||||
data->res,
|
||||
"error %d", data->res);
|
||||
} else {
|
||||
data->res = impl->dispatch_func (data->resource,
|
||||
data->opcode,
|
||||
|
|
@ -147,43 +153,3 @@ pinos_resource_dispatch (PinosResource *resource,
|
|||
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
SpaResult
|
||||
pinos_resource_send_message (PinosResource *resource,
|
||||
uint32_t opcode,
|
||||
void *message,
|
||||
bool flush)
|
||||
{
|
||||
return pinos_client_send_message (resource->client,
|
||||
resource,
|
||||
opcode,
|
||||
message,
|
||||
flush);
|
||||
}
|
||||
|
||||
SpaResult
|
||||
pinos_resource_send_error (PinosResource *resource,
|
||||
SpaResult res,
|
||||
const char *message,
|
||||
...)
|
||||
{
|
||||
PinosClient *client = resource->client;
|
||||
PinosMessageError m;
|
||||
char buffer[128];
|
||||
va_list ap;
|
||||
|
||||
va_start (ap, message);
|
||||
vsnprintf (buffer, sizeof (buffer), message, ap);
|
||||
va_end (ap);
|
||||
|
||||
m.id = resource->id;
|
||||
m.res = res;
|
||||
m.error = buffer;
|
||||
|
||||
pinos_log_error ("resource %p: %u send error %d %s", resource, resource->id, res, buffer);
|
||||
|
||||
return pinos_resource_send_message (client->core_resource,
|
||||
PINOS_MESSAGE_ERROR,
|
||||
&m,
|
||||
true);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -72,14 +72,6 @@ SpaResult pinos_resource_dispatch (PinosResource *resource,
|
|||
uint32_t opcode,
|
||||
void *message);
|
||||
|
||||
SpaResult pinos_resource_send_message (PinosResource *resource,
|
||||
uint32_t opcode,
|
||||
void *message,
|
||||
bool flush);
|
||||
SpaResult pinos_resource_send_error (PinosResource *resource,
|
||||
SpaResult res,
|
||||
const char *message, ...);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue