mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-19 07:00:10 -05:00
More hacking
Move array and map to pinos Move more things to spa lib ControlCmd -> Message Make pinos log, use for plugins as well work on ringbuffer in alsa and nodes work on making registry with all objects
This commit is contained in:
parent
a1c0bef2ed
commit
7e46f9e3ad
81 changed files with 1831 additions and 1030 deletions
|
|
@ -164,7 +164,7 @@ static SpaResult
|
|||
clear_buffers (SpaProxy *this, SpaProxyPort *port)
|
||||
{
|
||||
if (port->n_buffers) {
|
||||
spa_log_info (this->log, "proxy %p: clear buffers\n", this);
|
||||
spa_log_info (this->log, "proxy %p: clear buffers", this);
|
||||
|
||||
munmap (port->buffer_mem_ptr, port->buffer_mem_size);
|
||||
close (port->buffer_mem_fd);
|
||||
|
|
@ -211,15 +211,15 @@ spa_proxy_node_send_command (SpaNode *node,
|
|||
case SPA_NODE_COMMAND_DRAIN:
|
||||
case SPA_NODE_COMMAND_MARKER:
|
||||
{
|
||||
PinosControlCmdNodeCommand cnc;
|
||||
PinosMessageNodeCommand cnc;
|
||||
|
||||
/* send start */
|
||||
cnc.seq = this->seq++;
|
||||
cnc.command = command;
|
||||
pinos_connection_add_cmd (this->conn, PINOS_CONTROL_CMD_NODE_COMMAND, &cnc);
|
||||
pinos_connection_add_message (this->conn, PINOS_MESSAGE_NODE_COMMAND, &cnc);
|
||||
|
||||
if (!pinos_connection_flush (this->conn)) {
|
||||
spa_log_error (this->log, "proxy %p: error writing connection\n", this);
|
||||
spa_log_error (this->log, "proxy %p: error writing connection", this);
|
||||
res = SPA_RESULT_ERROR;
|
||||
} else
|
||||
res = SPA_RESULT_RETURN_ASYNC (cnc.seq);
|
||||
|
|
@ -228,14 +228,14 @@ spa_proxy_node_send_command (SpaNode *node,
|
|||
|
||||
case SPA_NODE_COMMAND_CLOCK_UPDATE:
|
||||
{
|
||||
PinosControlCmdNodeCommand cnc;
|
||||
PinosMessageNodeCommand cnc;
|
||||
|
||||
/* send start */
|
||||
cnc.command = command;
|
||||
pinos_connection_add_cmd (this->conn, PINOS_CONTROL_CMD_NODE_COMMAND, &cnc);
|
||||
pinos_connection_add_message (this->conn, PINOS_MESSAGE_NODE_COMMAND, &cnc);
|
||||
|
||||
if (!pinos_connection_flush (this->conn)) {
|
||||
spa_log_error (this->log, "proxy %p: error writing connection\n", this);
|
||||
spa_log_error (this->log, "proxy %p: error writing connection", this);
|
||||
res = SPA_RESULT_ERROR;
|
||||
}
|
||||
break;
|
||||
|
|
@ -319,7 +319,7 @@ spa_proxy_node_get_port_ids (SpaNode *node,
|
|||
|
||||
static void
|
||||
do_update_port (SpaProxy *this,
|
||||
PinosControlCmdPortUpdate *pu)
|
||||
PinosMessagePortUpdate *pu)
|
||||
{
|
||||
SpaProxyPort *port;
|
||||
unsigned int i;
|
||||
|
|
@ -331,7 +331,7 @@ do_update_port (SpaProxy *this,
|
|||
port = &this->out_ports[pu->port_id];
|
||||
}
|
||||
|
||||
if (pu->change_mask & PINOS_CONTROL_CMD_PORT_UPDATE_POSSIBLE_FORMATS) {
|
||||
if (pu->change_mask & PINOS_MESSAGE_PORT_UPDATE_POSSIBLE_FORMATS) {
|
||||
for (i = 0; i < port->n_formats; i++)
|
||||
free (port->formats[i]);
|
||||
port->n_formats = pu->n_possible_formats;
|
||||
|
|
@ -341,17 +341,17 @@ do_update_port (SpaProxy *this,
|
|||
port->formats[i] = pinos_serialize_format_copy_into (malloc (size), pu->possible_formats[i]);
|
||||
}
|
||||
}
|
||||
if (pu->change_mask & PINOS_CONTROL_CMD_PORT_UPDATE_FORMAT) {
|
||||
if (pu->change_mask & PINOS_MESSAGE_PORT_UPDATE_FORMAT) {
|
||||
if (port->format)
|
||||
free (port->format);
|
||||
size = pinos_serialize_format_get_size (pu->format);
|
||||
port->format = pinos_serialize_format_copy_into (malloc (size), pu->format);
|
||||
}
|
||||
|
||||
if (pu->change_mask & PINOS_CONTROL_CMD_PORT_UPDATE_PROPS) {
|
||||
if (pu->change_mask & PINOS_MESSAGE_PORT_UPDATE_PROPS) {
|
||||
}
|
||||
|
||||
if (pu->change_mask & PINOS_CONTROL_CMD_PORT_UPDATE_INFO && pu->info) {
|
||||
if (pu->change_mask & PINOS_MESSAGE_PORT_UPDATE_INFO && pu->info) {
|
||||
if (port->info)
|
||||
free (port->info);
|
||||
size = pinos_serialize_port_info_get_size (pu->info);
|
||||
|
|
@ -359,7 +359,7 @@ do_update_port (SpaProxy *this,
|
|||
}
|
||||
|
||||
if (!port->valid) {
|
||||
spa_log_info (this->log, "proxy %p: adding port %d\n", this, pu->port_id);
|
||||
spa_log_info (this->log, "proxy %p: adding port %d", this, pu->port_id);
|
||||
port->format = NULL;
|
||||
port->valid = true;
|
||||
|
||||
|
|
@ -376,12 +376,12 @@ clear_port (SpaProxy *this,
|
|||
SpaDirection direction,
|
||||
uint32_t port_id)
|
||||
{
|
||||
PinosControlCmdPortUpdate pu;
|
||||
PinosMessagePortUpdate pu;
|
||||
|
||||
pu.change_mask = PINOS_CONTROL_CMD_PORT_UPDATE_POSSIBLE_FORMATS |
|
||||
PINOS_CONTROL_CMD_PORT_UPDATE_FORMAT |
|
||||
PINOS_CONTROL_CMD_PORT_UPDATE_PROPS |
|
||||
PINOS_CONTROL_CMD_PORT_UPDATE_INFO;
|
||||
pu.change_mask = PINOS_MESSAGE_PORT_UPDATE_POSSIBLE_FORMATS |
|
||||
PINOS_MESSAGE_PORT_UPDATE_FORMAT |
|
||||
PINOS_MESSAGE_PORT_UPDATE_PROPS |
|
||||
PINOS_MESSAGE_PORT_UPDATE_INFO;
|
||||
pu.direction = direction;
|
||||
pu.port_id = port_id;
|
||||
pu.n_possible_formats = 0;
|
||||
|
|
@ -400,7 +400,7 @@ do_uninit_port (SpaProxy *this,
|
|||
{
|
||||
SpaProxyPort *port;
|
||||
|
||||
spa_log_info (this->log, "proxy %p: removing port %d\n", this, port_id);
|
||||
spa_log_info (this->log, "proxy %p: removing port %d", this, port_id);
|
||||
if (direction == SPA_DIRECTION_INPUT) {
|
||||
port = &this->in_ports[port_id];
|
||||
this->n_inputs--;
|
||||
|
|
@ -495,7 +495,7 @@ spa_proxy_node_port_set_format (SpaNode *node,
|
|||
const SpaFormat *format)
|
||||
{
|
||||
SpaProxy *this;
|
||||
PinosControlCmdSetFormat sf;
|
||||
PinosMessageSetFormat sf;
|
||||
|
||||
if (node == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
|
@ -510,10 +510,10 @@ spa_proxy_node_port_set_format (SpaNode *node,
|
|||
sf.port_id = port_id;
|
||||
sf.flags = flags;
|
||||
sf.format = (SpaFormat *) format;
|
||||
pinos_connection_add_cmd (this->conn, PINOS_CONTROL_CMD_SET_FORMAT, &sf);
|
||||
pinos_connection_add_message (this->conn, PINOS_MESSAGE_SET_FORMAT, &sf);
|
||||
|
||||
if (!pinos_connection_flush (this->conn))
|
||||
spa_log_error (this->log, "proxy %p: error writing connection\n", this);
|
||||
spa_log_error (this->log, "proxy %p: error writing connection", this);
|
||||
|
||||
return SPA_RESULT_RETURN_ASYNC (sf.seq);
|
||||
}
|
||||
|
|
@ -624,17 +624,17 @@ spa_proxy_node_port_use_buffers (SpaNode *node,
|
|||
SpaProxy *this;
|
||||
SpaProxyPort *port;
|
||||
unsigned int i, j;
|
||||
PinosControlCmdAddMem am;
|
||||
PinosControlCmdUseBuffers ub;
|
||||
PinosMessageAddMem am;
|
||||
PinosMessageUseBuffers ub;
|
||||
size_t size, n_mem;
|
||||
PinosControlMemRef *memref;
|
||||
PinosMessageMemRef *memref;
|
||||
void *p;
|
||||
|
||||
if (node == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
this = SPA_CONTAINER_OF (node, SpaProxy, node);
|
||||
spa_log_info (this->log, "proxy %p: use buffers %p %u\n", this, buffers, n_buffers);
|
||||
spa_log_info (this->log, "proxy %p: use buffers %p %u", this, buffers, n_buffers);
|
||||
|
||||
if (!CHECK_PORT (this, direction, port_id))
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
|
|
@ -680,7 +680,7 @@ spa_proxy_node_port_use_buffers (SpaNode *node,
|
|||
am.flags = d->flags;
|
||||
am.offset = d->offset;
|
||||
am.size = d->maxsize;
|
||||
pinos_connection_add_cmd (this->conn, PINOS_CONTROL_CMD_ADD_MEM, &am);
|
||||
pinos_connection_add_message (this->conn, PINOS_MESSAGE_ADD_MEM, &am);
|
||||
|
||||
b->buffer.datas[j].type = SPA_DATA_TYPE_ID;
|
||||
b->buffer.datas[j].data = SPA_UINT32_TO_PTR (n_mem);
|
||||
|
|
@ -693,7 +693,7 @@ spa_proxy_node_port_use_buffers (SpaNode *node,
|
|||
default:
|
||||
b->buffer.datas[j].type = SPA_DATA_TYPE_INVALID;
|
||||
b->buffer.datas[j].data = 0;
|
||||
spa_log_error (this->log, "invalid memory type %d\n", d->type);
|
||||
spa_log_error (this->log, "invalid memory type %d", d->type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -707,7 +707,7 @@ spa_proxy_node_port_use_buffers (SpaNode *node,
|
|||
port->buffer_mem_fd = memfd_create ("spa-memfd", MFD_CLOEXEC | MFD_ALLOW_SEALING);
|
||||
|
||||
if (ftruncate (port->buffer_mem_fd, size) < 0) {
|
||||
spa_log_error (this->log, "Failed to truncate temporary file: %s\n", strerror (errno));
|
||||
spa_log_error (this->log, "Failed to truncate temporary file: %s", strerror (errno));
|
||||
close (port->buffer_mem_fd);
|
||||
return SPA_RESULT_ERROR;
|
||||
}
|
||||
|
|
@ -715,7 +715,7 @@ spa_proxy_node_port_use_buffers (SpaNode *node,
|
|||
{
|
||||
unsigned int seals = F_SEAL_GROW | F_SEAL_SHRINK | F_SEAL_SEAL;
|
||||
if (fcntl (port->buffer_mem_fd, F_ADD_SEALS, seals) == -1) {
|
||||
spa_log_error (this->log, "Failed to add seals: %s\n", strerror (errno));
|
||||
spa_log_error (this->log, "Failed to add seals: %s", strerror (errno));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
@ -752,9 +752,9 @@ spa_proxy_node_port_use_buffers (SpaNode *node,
|
|||
am.flags = 0;
|
||||
am.offset = 0;
|
||||
am.size = size;
|
||||
pinos_connection_add_cmd (this->conn, PINOS_CONTROL_CMD_ADD_MEM, &am);
|
||||
pinos_connection_add_message (this->conn, PINOS_MESSAGE_ADD_MEM, &am);
|
||||
|
||||
memref = alloca (n_buffers * sizeof (PinosControlMemRef));
|
||||
memref = alloca (n_buffers * sizeof (PinosMessageMemRef));
|
||||
for (i = 0; i < n_buffers; i++) {
|
||||
memref[i].mem_id = port->buffer_mem_id;
|
||||
memref[i].offset = port->buffers[i].offset;
|
||||
|
|
@ -770,10 +770,10 @@ spa_proxy_node_port_use_buffers (SpaNode *node,
|
|||
ub.port_id = port_id;
|
||||
ub.n_buffers = n_buffers;
|
||||
ub.buffers = memref;
|
||||
pinos_connection_add_cmd (this->conn, PINOS_CONTROL_CMD_USE_BUFFERS, &ub);
|
||||
pinos_connection_add_message (this->conn, PINOS_MESSAGE_USE_BUFFERS, &ub);
|
||||
|
||||
if (!pinos_connection_flush (this->conn))
|
||||
spa_log_error (this->log, "proxy %p: error writing connection\n", this);
|
||||
spa_log_error (this->log, "proxy %p: error writing connection", this);
|
||||
|
||||
return SPA_RESULT_RETURN_ASYNC (ub.seq);
|
||||
}
|
||||
|
|
@ -820,7 +820,7 @@ copy_meta_in (SpaProxy *this, SpaProxyPort *port, uint32_t buffer_id)
|
|||
for (i = 0; i < b->outbuf->n_datas; i++) {
|
||||
b->outbuf->datas[i].size = b->buffer.datas[i].size;
|
||||
if (b->outbuf->datas[i].type == SPA_DATA_TYPE_MEMPTR) {
|
||||
spa_log_info (this->log, "memcpy in %zd\n", b->buffer.datas[i].size);
|
||||
spa_log_info (this->log, "memcpy in %zd", b->buffer.datas[i].size);
|
||||
memcpy (b->outbuf->datas[i].data, b->datas[i].data, b->buffer.datas[i].size);
|
||||
}
|
||||
}
|
||||
|
|
@ -840,7 +840,7 @@ copy_meta_out (SpaProxy *this, SpaProxyPort *port, uint32_t buffer_id)
|
|||
for (i = 0; i < b->outbuf->n_datas; i++) {
|
||||
b->buffer.datas[i].size = b->outbuf->datas[i].size;
|
||||
if (b->datas[i].type == SPA_DATA_TYPE_MEMPTR) {
|
||||
spa_log_info (this->log, "memcpy out %zd\n", b->outbuf->datas[i].size);
|
||||
spa_log_info (this->log, "memcpy out %zd", b->outbuf->datas[i].size);
|
||||
memcpy (b->datas[i].data, b->outbuf->datas[i].data, b->outbuf->datas[i].size);
|
||||
}
|
||||
}
|
||||
|
|
@ -855,7 +855,7 @@ spa_proxy_node_port_push_input (SpaNode *node,
|
|||
SpaProxyPort *port;
|
||||
unsigned int i;
|
||||
bool have_error = false;
|
||||
PinosControlCmdProcessBuffer pb;
|
||||
PinosMessageProcessBuffer pb;
|
||||
|
||||
if (node == NULL || n_info == 0 || info == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
|
@ -864,7 +864,7 @@ spa_proxy_node_port_push_input (SpaNode *node,
|
|||
|
||||
for (i = 0; i < n_info; i++) {
|
||||
if (!CHECK_IN_PORT (this, SPA_DIRECTION_INPUT, info[i].port_id)) {
|
||||
spa_log_warn (this->log, "invalid port %d\n", info[i].port_id);
|
||||
spa_log_warn (this->log, "invalid port %d", info[i].port_id);
|
||||
info[i].status = SPA_RESULT_INVALID_PORT;
|
||||
have_error = true;
|
||||
continue;
|
||||
|
|
@ -890,7 +890,7 @@ spa_proxy_node_port_push_input (SpaNode *node,
|
|||
pb.direction = SPA_DIRECTION_INPUT;
|
||||
pb.port_id = info[i].port_id;
|
||||
pb.buffer_id = info[i].buffer_id;
|
||||
pinos_connection_add_cmd (this->rtconn, PINOS_CONTROL_CMD_PROCESS_BUFFER, &pb);
|
||||
pinos_connection_add_message (this->rtconn, PINOS_MESSAGE_PROCESS_BUFFER, &pb);
|
||||
|
||||
info[i].status = SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -899,7 +899,7 @@ spa_proxy_node_port_push_input (SpaNode *node,
|
|||
return SPA_RESULT_ERROR;
|
||||
|
||||
if (!pinos_connection_flush (this->rtconn))
|
||||
spa_log_error (this->log, "proxy %p: error writing connection\n", this);
|
||||
spa_log_error (this->log, "proxy %p: error writing connection", this);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -923,7 +923,7 @@ spa_proxy_node_port_pull_output (SpaNode *node,
|
|||
ProxyBuffer *b;
|
||||
|
||||
if (!CHECK_OUT_PORT (this, SPA_DIRECTION_OUTPUT, info[i].port_id)) {
|
||||
spa_log_warn (this->log, "invalid port %u\n", info[i].port_id);
|
||||
spa_log_warn (this->log, "invalid port %u", info[i].port_id);
|
||||
info[i].status = SPA_RESULT_INVALID_PORT;
|
||||
have_error = true;
|
||||
continue;
|
||||
|
|
@ -960,7 +960,7 @@ spa_proxy_node_port_reuse_buffer (SpaNode *node,
|
|||
uint32_t buffer_id)
|
||||
{
|
||||
SpaProxy *this;
|
||||
PinosControlCmdNodeEvent cne;
|
||||
PinosMessageNodeEvent cne;
|
||||
SpaNodeEventReuseBuffer rb;
|
||||
|
||||
if (node == NULL)
|
||||
|
|
@ -977,10 +977,10 @@ spa_proxy_node_port_reuse_buffer (SpaNode *node,
|
|||
rb.event.size = sizeof (rb);
|
||||
rb.port_id = port_id;
|
||||
rb.buffer_id = buffer_id;
|
||||
pinos_connection_add_cmd (this->rtconn, PINOS_CONTROL_CMD_NODE_EVENT, &cne);
|
||||
pinos_connection_add_message (this->rtconn, PINOS_MESSAGE_NODE_EVENT, &cne);
|
||||
|
||||
if (!pinos_connection_flush (this->rtconn))
|
||||
spa_log_error (this->log, "proxy %p: error writing connection\n", this);
|
||||
spa_log_error (this->log, "proxy %p: error writing connection", this);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -1009,21 +1009,21 @@ spa_proxy_node_port_send_command (SpaNode *node,
|
|||
case SPA_NODE_COMMAND_DRAIN:
|
||||
case SPA_NODE_COMMAND_MARKER:
|
||||
{
|
||||
PinosControlCmdPortCommand cpc;
|
||||
PinosMessagePortCommand cpc;
|
||||
|
||||
cpc.port_id = port_id;
|
||||
cpc.command = command;
|
||||
pinos_connection_add_cmd (this->rtconn, PINOS_CONTROL_CMD_PORT_COMMAND, &cpc);
|
||||
pinos_connection_add_message (this->rtconn, PINOS_MESSAGE_PORT_COMMAND, &cpc);
|
||||
|
||||
if (!pinos_connection_flush (this->rtconn)) {
|
||||
spa_log_error (this->log, "proxy %p: error writing connection\n", this);
|
||||
spa_log_error (this->log, "proxy %p: error writing connection", this);
|
||||
res = SPA_RESULT_ERROR;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
spa_log_warn (this->log, "unhandled command %d\n", command->type);
|
||||
spa_log_warn (this->log, "unhandled command %d", command->type);
|
||||
res = SPA_RESULT_NOT_IMPLEMENTED;
|
||||
break;
|
||||
}
|
||||
|
|
@ -1059,45 +1059,45 @@ parse_connection (SpaProxy *this)
|
|||
PinosConnection *conn = this->conn;
|
||||
|
||||
while (pinos_connection_has_next (conn)) {
|
||||
PinosControlCmd cmd = pinos_connection_get_cmd (conn);
|
||||
PinosMessageType type = pinos_connection_get_type (conn);
|
||||
|
||||
switch (cmd) {
|
||||
case PINOS_CONTROL_CMD_INVALID:
|
||||
case PINOS_CONTROL_CMD_ADD_PORT:
|
||||
case PINOS_CONTROL_CMD_REMOVE_PORT:
|
||||
case PINOS_CONTROL_CMD_SET_FORMAT:
|
||||
case PINOS_CONTROL_CMD_SET_PROPERTY:
|
||||
case PINOS_CONTROL_CMD_NODE_COMMAND:
|
||||
case PINOS_CONTROL_CMD_PORT_COMMAND:
|
||||
case PINOS_CONTROL_CMD_PROCESS_BUFFER:
|
||||
spa_log_error (this->log, "proxy %p: got unexpected command %d\n", this, cmd);
|
||||
switch (type) {
|
||||
case PINOS_MESSAGE_INVALID:
|
||||
case PINOS_MESSAGE_ADD_PORT:
|
||||
case PINOS_MESSAGE_REMOVE_PORT:
|
||||
case PINOS_MESSAGE_SET_FORMAT:
|
||||
case PINOS_MESSAGE_SET_PROPERTY:
|
||||
case PINOS_MESSAGE_NODE_COMMAND:
|
||||
case PINOS_MESSAGE_PORT_COMMAND:
|
||||
case PINOS_MESSAGE_PROCESS_BUFFER:
|
||||
spa_log_error (this->log, "proxy %p: got unexpected command %d", this, type);
|
||||
break;
|
||||
|
||||
case PINOS_CONTROL_CMD_NODE_UPDATE:
|
||||
case PINOS_MESSAGE_NODE_UPDATE:
|
||||
{
|
||||
PinosControlCmdNodeUpdate nu;
|
||||
PinosMessageNodeUpdate nu;
|
||||
|
||||
if (!pinos_connection_parse_cmd (conn, &nu))
|
||||
if (!pinos_connection_parse_message (conn, &nu))
|
||||
break;
|
||||
|
||||
if (nu.change_mask & PINOS_CONTROL_CMD_NODE_UPDATE_MAX_INPUTS)
|
||||
if (nu.change_mask & PINOS_MESSAGE_NODE_UPDATE_MAX_INPUTS)
|
||||
this->max_inputs = nu.max_input_ports;
|
||||
if (nu.change_mask & PINOS_CONTROL_CMD_NODE_UPDATE_MAX_OUTPUTS)
|
||||
if (nu.change_mask & PINOS_MESSAGE_NODE_UPDATE_MAX_OUTPUTS)
|
||||
this->max_outputs = nu.max_output_ports;
|
||||
|
||||
spa_log_info (this->log, "proxy %p: got node update %d, max_in %u, max_out %u\n", this, cmd,
|
||||
spa_log_info (this->log, "proxy %p: got node update %d, max_in %u, max_out %u", this, type,
|
||||
this->max_inputs, this->max_outputs);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case PINOS_CONTROL_CMD_PORT_UPDATE:
|
||||
case PINOS_MESSAGE_PORT_UPDATE:
|
||||
{
|
||||
PinosControlCmdPortUpdate pu;
|
||||
PinosMessagePortUpdate pu;
|
||||
bool remove;
|
||||
|
||||
spa_log_info (this->log, "proxy %p: got port update %d\n", this, cmd);
|
||||
if (!pinos_connection_parse_cmd (conn, &pu))
|
||||
spa_log_info (this->log, "proxy %p: got port update %d", this, type);
|
||||
if (!pinos_connection_parse_message (conn, &pu))
|
||||
break;
|
||||
|
||||
if (!CHECK_PORT_ID (this, pu.direction, pu.port_id))
|
||||
|
|
@ -1113,21 +1113,21 @@ parse_connection (SpaProxy *this)
|
|||
break;
|
||||
}
|
||||
|
||||
case PINOS_CONTROL_CMD_PORT_STATUS_CHANGE:
|
||||
case PINOS_MESSAGE_PORT_STATUS_CHANGE:
|
||||
{
|
||||
spa_log_warn (this->log, "proxy %p: command not implemented %d\n", this, cmd);
|
||||
spa_log_warn (this->log, "proxy %p: command not implemented %d", this, type);
|
||||
break;
|
||||
}
|
||||
|
||||
case PINOS_CONTROL_CMD_NODE_STATE_CHANGE:
|
||||
case PINOS_MESSAGE_NODE_STATE_CHANGE:
|
||||
{
|
||||
PinosControlCmdNodeStateChange sc;
|
||||
PinosMessageNodeStateChange sc;
|
||||
SpaNodeState old = this->node.state;
|
||||
|
||||
if (!pinos_connection_parse_cmd (conn, &sc))
|
||||
if (!pinos_connection_parse_message (conn, &sc))
|
||||
break;
|
||||
|
||||
spa_log_info (this->log, "proxy %p: got node state change %d -> %d\n", this, old, sc.state);
|
||||
spa_log_info (this->log, "proxy %p: got node state change %d -> %d", this, old, sc.state);
|
||||
this->node.state = sc.state;
|
||||
if (old == SPA_NODE_STATE_INIT)
|
||||
send_async_complete (this, 0, SPA_RESULT_OK);
|
||||
|
|
@ -1135,16 +1135,16 @@ parse_connection (SpaProxy *this)
|
|||
break;
|
||||
}
|
||||
|
||||
case PINOS_CONTROL_CMD_ADD_MEM:
|
||||
case PINOS_MESSAGE_ADD_MEM:
|
||||
break;
|
||||
case PINOS_CONTROL_CMD_USE_BUFFERS:
|
||||
case PINOS_MESSAGE_USE_BUFFERS:
|
||||
break;
|
||||
|
||||
case PINOS_CONTROL_CMD_NODE_EVENT:
|
||||
case PINOS_MESSAGE_NODE_EVENT:
|
||||
{
|
||||
PinosControlCmdNodeEvent cne;
|
||||
PinosMessageNodeEvent cne;
|
||||
|
||||
if (!pinos_connection_parse_cmd (conn, &cne))
|
||||
if (!pinos_connection_parse_message (conn, &cne))
|
||||
break;
|
||||
|
||||
handle_node_event (this, cne.event);
|
||||
|
|
@ -1162,63 +1162,63 @@ parse_rtconnection (SpaProxy *this)
|
|||
PinosConnection *conn = this->rtconn;
|
||||
|
||||
while (pinos_connection_has_next (conn)) {
|
||||
PinosControlCmd cmd = pinos_connection_get_cmd (conn);
|
||||
PinosMessageType type = pinos_connection_get_type (conn);
|
||||
|
||||
switch (cmd) {
|
||||
case PINOS_CONTROL_CMD_INVALID:
|
||||
case PINOS_CONTROL_CMD_NODE_UPDATE:
|
||||
case PINOS_CONTROL_CMD_PORT_UPDATE:
|
||||
case PINOS_CONTROL_CMD_NODE_STATE_CHANGE:
|
||||
case PINOS_CONTROL_CMD_PORT_STATUS_CHANGE:
|
||||
case PINOS_CONTROL_CMD_ADD_PORT:
|
||||
case PINOS_CONTROL_CMD_REMOVE_PORT:
|
||||
case PINOS_CONTROL_CMD_SET_FORMAT:
|
||||
case PINOS_CONTROL_CMD_SET_PROPERTY:
|
||||
case PINOS_CONTROL_CMD_NODE_COMMAND:
|
||||
case PINOS_CONTROL_CMD_ADD_MEM:
|
||||
case PINOS_CONTROL_CMD_USE_BUFFERS:
|
||||
spa_log_error (this->log, "proxy %p: got unexpected connection %d\n", this, cmd);
|
||||
switch (type) {
|
||||
case PINOS_MESSAGE_INVALID:
|
||||
case PINOS_MESSAGE_NODE_UPDATE:
|
||||
case PINOS_MESSAGE_PORT_UPDATE:
|
||||
case PINOS_MESSAGE_NODE_STATE_CHANGE:
|
||||
case PINOS_MESSAGE_PORT_STATUS_CHANGE:
|
||||
case PINOS_MESSAGE_ADD_PORT:
|
||||
case PINOS_MESSAGE_REMOVE_PORT:
|
||||
case PINOS_MESSAGE_SET_FORMAT:
|
||||
case PINOS_MESSAGE_SET_PROPERTY:
|
||||
case PINOS_MESSAGE_NODE_COMMAND:
|
||||
case PINOS_MESSAGE_ADD_MEM:
|
||||
case PINOS_MESSAGE_USE_BUFFERS:
|
||||
spa_log_error (this->log, "proxy %p: got unexpected message %d", this, type);
|
||||
break;
|
||||
|
||||
case PINOS_CONTROL_CMD_PROCESS_BUFFER:
|
||||
case PINOS_MESSAGE_PROCESS_BUFFER:
|
||||
{
|
||||
PinosControlCmdProcessBuffer cmd;
|
||||
PinosMessageProcessBuffer msg;
|
||||
SpaProxyPort *port;
|
||||
ProxyBuffer *b;
|
||||
|
||||
if (!pinos_connection_parse_cmd (conn, &cmd))
|
||||
if (!pinos_connection_parse_message (conn, &msg))
|
||||
break;
|
||||
|
||||
if (!CHECK_PORT (this, cmd.direction, cmd.port_id))
|
||||
if (!CHECK_PORT (this, msg.direction, msg.port_id))
|
||||
break;
|
||||
|
||||
port = cmd.direction == SPA_DIRECTION_INPUT ? &this->in_ports[cmd.port_id] : &this->out_ports[cmd.port_id];
|
||||
port = msg.direction == SPA_DIRECTION_INPUT ? &this->in_ports[msg.port_id] : &this->out_ports[msg.port_id];
|
||||
|
||||
if (!CHECK_PORT_BUFFER (this, cmd.buffer_id, port))
|
||||
if (!CHECK_PORT_BUFFER (this, msg.buffer_id, port))
|
||||
break;
|
||||
|
||||
copy_meta_in (this, port, cmd.buffer_id);
|
||||
copy_meta_in (this, port, msg.buffer_id);
|
||||
|
||||
b = &port->buffers[cmd.buffer_id];
|
||||
b = &port->buffers[msg.buffer_id];
|
||||
b->next = NULL;
|
||||
SPA_QUEUE_PUSH_TAIL (&port->ready, ProxyBuffer, next, b);
|
||||
break;
|
||||
}
|
||||
case PINOS_CONTROL_CMD_NODE_EVENT:
|
||||
case PINOS_MESSAGE_NODE_EVENT:
|
||||
{
|
||||
PinosControlCmdNodeEvent cne;
|
||||
PinosMessageNodeEvent cne;
|
||||
|
||||
if (!pinos_connection_parse_cmd (conn, &cne))
|
||||
if (!pinos_connection_parse_message (conn, &cne))
|
||||
break;
|
||||
|
||||
handle_node_event (this, cne.event);
|
||||
break;
|
||||
}
|
||||
case PINOS_CONTROL_CMD_PORT_COMMAND:
|
||||
case PINOS_MESSAGE_PORT_COMMAND:
|
||||
{
|
||||
PinosControlCmdPortCommand cm;
|
||||
PinosMessagePortCommand cm;
|
||||
|
||||
if (!pinos_connection_parse_cmd (conn, &cm))
|
||||
if (!pinos_connection_parse_message (conn, &cm))
|
||||
break;
|
||||
|
||||
break;
|
||||
|
|
@ -1387,7 +1387,7 @@ pinos_client_node_dispose (GObject * object)
|
|||
PinosClientNode *this = PINOS_CLIENT_NODE (object);
|
||||
PinosClientNodePrivate *priv = this->priv;
|
||||
|
||||
g_debug ("client-node %p: dispose", this);
|
||||
pinos_log_debug ("client-node %p: dispose", this);
|
||||
|
||||
proxy_clear (priv->proxy);
|
||||
|
||||
|
|
@ -1400,7 +1400,7 @@ pinos_client_node_finalize (GObject * object)
|
|||
PinosClientNode *this = PINOS_CLIENT_NODE (object);
|
||||
PinosClientNodePrivate *priv = this->priv;
|
||||
|
||||
g_debug ("client-node %p: finalize", this);
|
||||
pinos_log_debug ("client-node %p: finalize", this);
|
||||
|
||||
g_clear_object (&priv->sockets[0]);
|
||||
g_clear_object (&priv->sockets[1]);
|
||||
|
|
@ -1416,7 +1416,7 @@ pinos_client_node_constructed (GObject * object)
|
|||
PinosClientNode *this = PINOS_CLIENT_NODE (object);
|
||||
PinosClientNodePrivate *priv = this->priv;
|
||||
|
||||
g_debug ("client-node %p: constructed", this);
|
||||
pinos_log_debug ("client-node %p: constructed", this);
|
||||
|
||||
G_OBJECT_CLASS (pinos_client_node_parent_class)->constructed (object);
|
||||
|
||||
|
|
@ -1443,7 +1443,7 @@ pinos_client_node_init (PinosClientNode * node)
|
|||
{
|
||||
node->priv = PINOS_CLIENT_NODE_GET_PRIVATE (node);
|
||||
|
||||
g_debug ("client-node %p: new", node);
|
||||
pinos_log_debug ("client-node %p: new", node);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ client_name_appeared_handler (GDBusConnection *connection,
|
|||
{
|
||||
PinosClient *client = user_data;
|
||||
|
||||
g_debug ("client %p: appeared %s %s", client, name, name_owner);
|
||||
pinos_log_debug ("client %p: appeared %s %s", client, name, name_owner);
|
||||
|
||||
g_signal_emit (client, signals[SIGNAL_APPEARED], 0, NULL);
|
||||
}
|
||||
|
|
@ -83,7 +83,7 @@ client_name_vanished_handler (GDBusConnection *connection,
|
|||
PinosClient *client = user_data;
|
||||
PinosClientPrivate *priv = client->priv;
|
||||
|
||||
g_debug ("client %p: vanished %s", client, name);
|
||||
pinos_log_debug ("client %p: vanished %s", client, name);
|
||||
|
||||
g_signal_emit (client, signals[SIGNAL_VANISHED], 0, NULL);
|
||||
g_bus_unwatch_name (priv->id);
|
||||
|
|
@ -186,7 +186,9 @@ client_register_object (PinosClient *client)
|
|||
priv->object_path = pinos_daemon_export_uniquely (daemon, G_DBUS_OBJECT_SKELETON (skel));
|
||||
g_object_unref (skel);
|
||||
|
||||
g_debug ("client %p: register %s", client, priv->object_path);
|
||||
client->id = pinos_map_insert_new (&daemon->registry.clients, client);
|
||||
|
||||
pinos_log_debug ("client %p: register %s", client, priv->object_path);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -195,8 +197,9 @@ client_unregister_object (PinosClient *client)
|
|||
PinosClientPrivate *priv = client->priv;
|
||||
PinosDaemon *daemon = priv->daemon;
|
||||
|
||||
g_debug ("client %p: unregister", client);
|
||||
pinos_log_debug ("client %p: unregister", client);
|
||||
pinos_daemon_unexport (daemon, priv->object_path);
|
||||
pinos_map_remove (&daemon->registry.clients, client->id);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -206,7 +209,7 @@ pinos_client_dispose (GObject * object)
|
|||
PinosClientPrivate *priv = client->priv;
|
||||
GList *copy;
|
||||
|
||||
g_debug ("client %p: dispose", client);
|
||||
pinos_log_debug ("client %p: dispose", client);
|
||||
copy = g_list_copy (priv->objects);
|
||||
g_list_free_full (copy, g_object_unref);
|
||||
g_list_free (priv->objects);
|
||||
|
|
@ -222,7 +225,7 @@ pinos_client_finalize (GObject * object)
|
|||
PinosClient *client = PINOS_CLIENT (object);
|
||||
PinosClientPrivate *priv = client->priv;
|
||||
|
||||
g_debug ("client %p: finalize", client);
|
||||
pinos_log_debug ("client %p: finalize", client);
|
||||
g_clear_object (&priv->daemon);
|
||||
g_clear_object (&priv->iface);
|
||||
g_free (priv->sender);
|
||||
|
|
@ -238,7 +241,7 @@ pinos_client_constructed (GObject * object)
|
|||
{
|
||||
PinosClient *client = PINOS_CLIENT (object);
|
||||
|
||||
g_debug ("client %p: constructed", client);
|
||||
pinos_log_debug ("client %p: constructed", client);
|
||||
client_watch_name (client);
|
||||
client_register_object (client);
|
||||
|
||||
|
|
@ -335,7 +338,7 @@ pinos_client_init (PinosClient * client)
|
|||
PinosClientPrivate *priv = client->priv = PINOS_CLIENT_GET_PRIVATE (client);
|
||||
|
||||
priv->iface = pinos_client1_skeleton_new ();
|
||||
g_debug ("client %p: new", client);
|
||||
pinos_log_debug ("client %p: new", client);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -373,7 +376,7 @@ pinos_client_remove (PinosClient *client)
|
|||
{
|
||||
g_return_if_fail (PINOS_IS_CLIENT (client));
|
||||
|
||||
g_debug ("client %p: remove", client);
|
||||
pinos_log_debug ("client %p: remove", client);
|
||||
g_signal_emit (client, signals[SIGNAL_REMOVE], 0, NULL);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -47,6 +47,8 @@ typedef struct _PinosClientPrivate PinosClientPrivate;
|
|||
struct _PinosClient {
|
||||
GObject object;
|
||||
|
||||
uint32_t id;
|
||||
|
||||
PinosClientPrivate *priv;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@
|
|||
#include "config.h"
|
||||
|
||||
#include "pinos/client/pinos.h"
|
||||
#include "pinos/client/log.h"
|
||||
|
||||
#include "pinos/server/daemon.h"
|
||||
#include "pinos/server/node.h"
|
||||
|
|
@ -50,8 +51,6 @@ struct _PinosDaemonPrivate
|
|||
|
||||
gchar *object_path;
|
||||
|
||||
GList *nodes;
|
||||
|
||||
GHashTable *clients;
|
||||
PinosDataLoop *data_loop;
|
||||
PinosMainLoop *main_loop;
|
||||
|
|
@ -61,7 +60,6 @@ struct _PinosDaemonPrivate
|
|||
GHashTable *node_factories;
|
||||
|
||||
SpaSupport support[4];
|
||||
SpaLog log;
|
||||
};
|
||||
|
||||
enum
|
||||
|
|
@ -80,7 +78,7 @@ handle_client_appeared (PinosClient *client, gpointer user_data)
|
|||
PinosDaemon *daemon = user_data;
|
||||
PinosDaemonPrivate *priv = daemon->priv;
|
||||
|
||||
g_debug ("daemon %p: appeared %p", daemon, client);
|
||||
pinos_log_debug ("daemon %p: appeared %p", daemon, client);
|
||||
|
||||
g_hash_table_insert (priv->clients, (gpointer) pinos_client_get_sender (client), client);
|
||||
}
|
||||
|
|
@ -91,7 +89,7 @@ handle_client_vanished (PinosClient *client, gpointer user_data)
|
|||
PinosDaemon *daemon = user_data;
|
||||
PinosDaemonPrivate *priv = daemon->priv;
|
||||
|
||||
g_debug ("daemon %p: vanished %p", daemon, client);
|
||||
pinos_log_debug ("daemon %p: vanished %p", daemon, client);
|
||||
g_hash_table_remove (priv->clients, (gpointer) pinos_client_get_sender (client));
|
||||
}
|
||||
|
||||
|
|
@ -107,7 +105,7 @@ sender_get_client (PinosDaemon *daemon,
|
|||
if (client == NULL && create) {
|
||||
client = pinos_client_new (daemon, sender, NULL);
|
||||
|
||||
g_debug ("daemon %p: new client %p for %s", daemon, client, sender);
|
||||
pinos_log_debug ("daemon %p: new client %p for %s", daemon, client, sender);
|
||||
g_signal_connect (client,
|
||||
"appeared",
|
||||
(GCallback) handle_client_appeared,
|
||||
|
|
@ -126,7 +124,7 @@ handle_remove_node (PinosNode *node,
|
|||
{
|
||||
PinosClient *client = user_data;
|
||||
|
||||
g_debug ("client %p: node %p remove", daemon, node);
|
||||
pinos_log_debug ("client %p: node %p remove", daemon, node);
|
||||
pinos_client_remove_object (client, G_OBJECT (node));
|
||||
}
|
||||
|
||||
|
|
@ -149,7 +147,7 @@ handle_create_node (PinosDaemon1 *interface,
|
|||
sender = g_dbus_method_invocation_get_sender (invocation);
|
||||
client = sender_get_client (daemon, sender, TRUE);
|
||||
|
||||
g_debug ("daemon %p: create node: %s", daemon, sender);
|
||||
pinos_log_debug ("daemon %p: create node: %s", daemon, sender);
|
||||
|
||||
props = pinos_properties_from_variant (arg_properties);
|
||||
|
||||
|
|
@ -158,7 +156,6 @@ handle_create_node (PinosDaemon1 *interface,
|
|||
goto no_factory;
|
||||
|
||||
node = pinos_node_factory_create_node (factory,
|
||||
daemon,
|
||||
client,
|
||||
arg_name,
|
||||
props);
|
||||
|
|
@ -175,7 +172,7 @@ handle_create_node (PinosDaemon1 *interface,
|
|||
client);
|
||||
|
||||
object_path = pinos_node_get_object_path (node);
|
||||
g_debug ("daemon %p: added node %p with path %s", daemon, node, object_path);
|
||||
pinos_log_debug ("daemon %p: added node %p with path %s", daemon, node, object_path);
|
||||
g_dbus_method_invocation_return_value (invocation,
|
||||
g_variant_new ("(o)", object_path));
|
||||
g_object_unref (node);
|
||||
|
|
@ -185,14 +182,14 @@ handle_create_node (PinosDaemon1 *interface,
|
|||
/* ERRORS */
|
||||
no_factory:
|
||||
{
|
||||
g_debug ("daemon %p: could find factory named %s", daemon, arg_factory_name);
|
||||
pinos_log_debug ("daemon %p: could find factory named %s", daemon, arg_factory_name);
|
||||
g_dbus_method_invocation_return_dbus_error (invocation,
|
||||
"org.pinos.Error", "can't find factory");
|
||||
return TRUE;
|
||||
}
|
||||
no_node:
|
||||
{
|
||||
g_debug ("daemon %p: could create node named %s from factory %s", daemon, arg_name, arg_factory_name);
|
||||
pinos_log_debug ("daemon %p: could create node named %s from factory %s", daemon, arg_name, arg_factory_name);
|
||||
g_dbus_method_invocation_return_dbus_error (invocation,
|
||||
"org.pinos.Error", "can't create node");
|
||||
return TRUE;
|
||||
|
|
@ -205,7 +202,7 @@ on_link_port_unlinked (PinosLink *link,
|
|||
PinosPort *port,
|
||||
PinosDaemon *this)
|
||||
{
|
||||
g_debug ("daemon %p: link %p: port %p unlinked", this, link, port);
|
||||
pinos_log_debug ("daemon %p: link %p: port %p unlinked", this, link, port);
|
||||
|
||||
if (port->direction == PINOS_DIRECTION_OUTPUT && link->input)
|
||||
try_link_port (link->input->node, link->input, this);
|
||||
|
|
@ -224,7 +221,7 @@ on_link_state_notify (GObject *obj,
|
|||
switch (state) {
|
||||
case PINOS_LINK_STATE_ERROR:
|
||||
{
|
||||
g_debug ("daemon %p: link %p: state error: %s", daemon, link, error->message);
|
||||
pinos_log_debug ("daemon %p: link %p: state error: %s", daemon, link, error->message);
|
||||
|
||||
if (link->input && link->input->node)
|
||||
pinos_node_report_error (link->input->node, g_error_copy (error));
|
||||
|
|
@ -234,7 +231,7 @@ on_link_state_notify (GObject *obj,
|
|||
}
|
||||
|
||||
case PINOS_LINK_STATE_UNLINKED:
|
||||
g_debug ("daemon %p: link %p: unlinked", daemon, link);
|
||||
pinos_log_debug ("daemon %p: link %p: unlinked", daemon, link);
|
||||
|
||||
#if 0
|
||||
g_set_error (&error,
|
||||
|
|
@ -348,7 +345,7 @@ on_node_state_change (PinosNode *node,
|
|||
PinosNodeState state,
|
||||
PinosDaemon *this)
|
||||
{
|
||||
g_debug ("daemon %p: node %p state change %s -> %s", this, node,
|
||||
pinos_log_debug ("daemon %p: node %p state change %s -> %s", this, node,
|
||||
pinos_node_state_as_string (old),
|
||||
pinos_node_state_as_string (state));
|
||||
|
||||
|
|
@ -362,7 +359,7 @@ on_node_added (PinosDaemon *daemon, PinosNode *node)
|
|||
PinosNodeState state;
|
||||
PinosDaemonPrivate *priv = daemon->priv;
|
||||
|
||||
g_debug ("daemon %p: node %p added", daemon, node);
|
||||
pinos_log_debug ("daemon %p: node %p added", daemon, node);
|
||||
|
||||
g_object_set (node, "data-loop", priv->data_loop, NULL);
|
||||
|
||||
|
|
@ -377,7 +374,7 @@ on_node_added (PinosDaemon *daemon, PinosNode *node)
|
|||
static void
|
||||
on_node_removed (PinosDaemon *daemon, PinosNode *node)
|
||||
{
|
||||
g_debug ("daemon %p: node %p removed", daemon, node);
|
||||
pinos_log_debug ("daemon %p: node %p removed", daemon, node);
|
||||
g_signal_handlers_disconnect_by_data (node, daemon);
|
||||
}
|
||||
|
||||
|
|
@ -401,7 +398,7 @@ handle_create_client_node (PinosDaemon1 *interface,
|
|||
sender = g_dbus_method_invocation_get_sender (invocation);
|
||||
client = sender_get_client (daemon, sender, TRUE);
|
||||
|
||||
g_debug ("daemon %p: create client-node: %s", daemon, sender);
|
||||
pinos_log_debug ("daemon %p: create client-node: %s", daemon, sender);
|
||||
props = pinos_properties_from_variant (arg_properties);
|
||||
|
||||
node = pinos_client_node_new (daemon,
|
||||
|
|
@ -421,7 +418,7 @@ handle_create_client_node (PinosDaemon1 *interface,
|
|||
pinos_client_add_object (client, G_OBJECT (node));
|
||||
|
||||
object_path = pinos_node_get_object_path (PINOS_NODE (node));
|
||||
g_debug ("daemon %p: add client-node %p, %s", daemon, node, object_path);
|
||||
pinos_log_debug ("daemon %p: add client-node %p, %s", daemon, node, object_path);
|
||||
g_object_unref (node);
|
||||
|
||||
fdlist = g_unix_fd_list_new ();
|
||||
|
|
@ -438,7 +435,7 @@ handle_create_client_node (PinosDaemon1 *interface,
|
|||
|
||||
no_socket:
|
||||
{
|
||||
g_debug ("daemon %p: could not create socket %s", daemon, error->message);
|
||||
pinos_log_debug ("daemon %p: could not create socket %s", daemon, error->message);
|
||||
g_object_unref (node);
|
||||
goto exit_error;
|
||||
}
|
||||
|
|
@ -470,7 +467,7 @@ handle_register_client_node (PinosDaemon1 *interface,
|
|||
sender = g_dbus_method_invocation_get_sender (invocation);
|
||||
client = sender_get_client (daemon, sender, TRUE);
|
||||
|
||||
g_debug ("daemon %p: register client-node: %s", daemon, sender);
|
||||
pinos_log_debug ("daemon %p: register client-node: %s", daemon, sender);
|
||||
props = pinos_properties_from_variant (arg_properties);
|
||||
|
||||
node = pinos_dbus_client_node_new (daemon,
|
||||
|
|
@ -498,7 +495,7 @@ handle_register_client_node (PinosDaemon1 *interface,
|
|||
|
||||
no_socket:
|
||||
{
|
||||
g_debug ("daemon %p: could not create socket %s", daemon, error->message);
|
||||
pinos_log_debug ("daemon %p: could not create socket %s", daemon, error->message);
|
||||
g_object_unref (node);
|
||||
goto exit_error;
|
||||
}
|
||||
|
|
@ -606,7 +603,7 @@ pinos_daemon_start (PinosDaemon *daemon)
|
|||
priv = daemon->priv;
|
||||
g_return_if_fail (priv->id == 0);
|
||||
|
||||
g_debug ("daemon %p: start", daemon);
|
||||
pinos_log_debug ("daemon %p: start", daemon);
|
||||
|
||||
priv->id = g_bus_own_name (G_BUS_TYPE_SESSION,
|
||||
PINOS_DBUS_SERVICE,
|
||||
|
|
@ -631,7 +628,7 @@ pinos_daemon_stop (PinosDaemon *daemon)
|
|||
|
||||
g_return_if_fail (PINOS_IS_DAEMON (daemon));
|
||||
|
||||
g_debug ("daemon %p: stop", daemon);
|
||||
pinos_log_debug ("daemon %p: stop", daemon);
|
||||
|
||||
if (priv->id != 0) {
|
||||
g_bus_unown_name (priv->id);
|
||||
|
|
@ -688,13 +685,9 @@ void
|
|||
pinos_daemon_add_node (PinosDaemon *daemon,
|
||||
PinosNode *node)
|
||||
{
|
||||
PinosDaemonPrivate *priv;
|
||||
|
||||
g_return_if_fail (PINOS_IS_DAEMON (daemon));
|
||||
g_return_if_fail (PINOS_IS_NODE (node));
|
||||
priv = daemon->priv;
|
||||
|
||||
priv->nodes = g_list_prepend (priv->nodes, node);
|
||||
on_node_added (daemon, node);
|
||||
}
|
||||
|
||||
|
|
@ -709,14 +702,10 @@ void
|
|||
pinos_daemon_remove_node (PinosDaemon *daemon,
|
||||
PinosNode *node)
|
||||
{
|
||||
PinosDaemonPrivate *priv;
|
||||
|
||||
g_return_if_fail (PINOS_IS_DAEMON (daemon));
|
||||
g_return_if_fail (PINOS_IS_NODE (node));
|
||||
priv = daemon->priv;
|
||||
|
||||
on_node_removed (daemon, node);
|
||||
priv->nodes = g_list_remove (priv->nodes, node);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -740,29 +729,27 @@ pinos_daemon_find_port (PinosDaemon *daemon,
|
|||
GPtrArray *format_filters,
|
||||
GError **error)
|
||||
{
|
||||
PinosDaemonPrivate *priv;
|
||||
PinosPort *best = NULL;
|
||||
GList *nodes;
|
||||
gboolean have_name;
|
||||
guint i;
|
||||
|
||||
g_return_val_if_fail (PINOS_IS_DAEMON (daemon), NULL);
|
||||
priv = daemon->priv;
|
||||
|
||||
have_name = name ? strlen (name) > 0 : FALSE;
|
||||
|
||||
g_debug ("name \"%s\", %d", name, have_name);
|
||||
pinos_log_debug ("name \"%s\", %d", name, have_name);
|
||||
|
||||
for (nodes = priv->nodes; nodes; nodes = g_list_next (nodes)) {
|
||||
PinosNode *n = nodes->data;
|
||||
for (i = 0; i < pinos_map_get_size (&daemon->registry.nodes); i++) {
|
||||
PinosNode *n = pinos_map_lookup (&daemon->registry.nodes, i);
|
||||
|
||||
if (n->flags & PINOS_NODE_FLAG_REMOVING)
|
||||
if (n == NULL || n->flags & PINOS_NODE_FLAG_REMOVING)
|
||||
continue;
|
||||
|
||||
g_debug ("node path \"%s\"", pinos_node_get_object_path (n));
|
||||
pinos_log_debug ("node path \"%s\"", pinos_node_get_object_path (n));
|
||||
|
||||
if (have_name) {
|
||||
if (g_str_has_suffix (pinos_node_get_object_path (n), name)) {
|
||||
g_debug ("name \"%s\" matches node %p", name, n);
|
||||
pinos_log_debug ("name \"%s\" matches node %p", name, n);
|
||||
|
||||
best = pinos_node_get_free_port (n, pinos_direction_reverse (other_port->direction));
|
||||
if (best)
|
||||
|
|
@ -839,7 +826,7 @@ pinos_daemon_constructed (GObject * object)
|
|||
PinosDaemon *daemon = PINOS_DAEMON_CAST (object);
|
||||
PinosDaemonPrivate *priv = daemon->priv;
|
||||
|
||||
g_debug ("daemon %p: constructed", object);
|
||||
pinos_log_debug ("daemon %p: constructed", object);
|
||||
pinos_daemon1_set_user_name (priv->iface, g_get_user_name ());
|
||||
pinos_daemon1_set_host_name (priv->iface, g_get_host_name ());
|
||||
pinos_daemon1_set_version (priv->iface, PACKAGE_VERSION);
|
||||
|
|
@ -855,7 +842,7 @@ pinos_daemon_dispose (GObject * object)
|
|||
{
|
||||
PinosDaemon *daemon = PINOS_DAEMON_CAST (object);
|
||||
|
||||
g_debug ("daemon %p: dispose", object);
|
||||
pinos_log_debug ("daemon %p: dispose", object);
|
||||
|
||||
pinos_daemon_stop (daemon);
|
||||
|
||||
|
|
@ -868,7 +855,7 @@ pinos_daemon_finalize (GObject * object)
|
|||
PinosDaemon *daemon = PINOS_DAEMON_CAST (object);
|
||||
PinosDaemonPrivate *priv = daemon->priv;
|
||||
|
||||
g_debug ("daemon %p: finalize", object);
|
||||
pinos_log_debug ("daemon %p: finalize", object);
|
||||
g_clear_object (&priv->server_manager);
|
||||
g_clear_object (&priv->iface);
|
||||
g_clear_object (&priv->data_loop);
|
||||
|
|
@ -922,55 +909,19 @@ pinos_daemon_class_init (PinosDaemonClass * klass)
|
|||
|
||||
}
|
||||
|
||||
static void
|
||||
do_logv (SpaLog *log,
|
||||
SpaLogLevel level,
|
||||
const char *file,
|
||||
int line,
|
||||
const char *func,
|
||||
const char *fmt,
|
||||
va_list args)
|
||||
|
||||
{
|
||||
char text[16*1024], location[128];
|
||||
static const char *levels[] = {
|
||||
"-",
|
||||
"E",
|
||||
"W",
|
||||
"I",
|
||||
"D",
|
||||
"T",
|
||||
};
|
||||
vsnprintf (text, sizeof(text), fmt, args);
|
||||
snprintf (location, sizeof(location), "%s:%i %s()", file, line, func);
|
||||
fprintf(stderr, "[%s][%s] %s", levels[level], location, text);
|
||||
}
|
||||
|
||||
static void
|
||||
do_log (SpaLog *log,
|
||||
SpaLogLevel level,
|
||||
const char *file,
|
||||
int line,
|
||||
const char *func,
|
||||
const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start (args, fmt);
|
||||
do_logv (log, level, file, line, func, fmt, args);
|
||||
va_end (args);
|
||||
}
|
||||
|
||||
static void
|
||||
pinos_daemon_init (PinosDaemon * daemon)
|
||||
{
|
||||
PinosDaemonPrivate *priv = daemon->priv = PINOS_DAEMON_GET_PRIVATE (daemon);
|
||||
|
||||
g_debug ("daemon %p: new", daemon);
|
||||
pinos_log_debug ("daemon %p: new", daemon);
|
||||
priv->iface = pinos_daemon1_skeleton_new ();
|
||||
g_signal_connect (priv->iface, "handle-create-node", (GCallback) handle_create_node, daemon);
|
||||
g_signal_connect (priv->iface, "handle-create-client-node", (GCallback) handle_create_client_node, daemon);
|
||||
g_signal_connect (priv->iface, "handle-register-client-node", (GCallback) handle_register_client_node, daemon);
|
||||
|
||||
pinos_registry_init (&daemon->registry);
|
||||
|
||||
priv->server_manager = g_dbus_object_manager_server_new (PINOS_DBUS_OBJECT_PREFIX);
|
||||
priv->clients = g_hash_table_new (g_str_hash, g_str_equal);
|
||||
priv->node_factories = g_hash_table_new_full (g_str_hash,
|
||||
|
|
@ -979,17 +930,10 @@ pinos_daemon_init (PinosDaemon * daemon)
|
|||
g_object_unref);
|
||||
|
||||
daemon->main_loop = pinos_main_loop_new (g_main_context_get_thread_default ());
|
||||
|
||||
priv->data_loop = pinos_data_loop_new();
|
||||
|
||||
priv->log.size = sizeof (SpaLog);
|
||||
priv->log.info = NULL;
|
||||
priv->log.level = SPA_LOG_LEVEL_INFO;
|
||||
priv->log.log = do_log;
|
||||
priv->log.logv = do_logv;
|
||||
|
||||
daemon->map = spa_id_map_get_default();
|
||||
daemon->log = &priv->log;
|
||||
daemon->map = pinos_id_map_get_default();
|
||||
daemon->log = pinos_log_get();
|
||||
|
||||
priv->support[0].uri = SPA_ID_MAP_URI;
|
||||
priv->support[0].data = daemon->map;
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ typedef struct _PinosDaemonPrivate PinosDaemonPrivate;
|
|||
#include <pinos/server/node-factory.h>
|
||||
#include <pinos/server/main-loop.h>
|
||||
#include <pinos/client/properties.h>
|
||||
#include <pinos/server/registry.h>
|
||||
|
||||
/**
|
||||
* PinosDaemon:
|
||||
|
|
@ -61,6 +62,8 @@ struct _PinosDaemon {
|
|||
SpaSupport *support;
|
||||
unsigned int n_support;
|
||||
|
||||
PinosRegistry registry;
|
||||
|
||||
PinosDaemonPrivate *priv;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -27,9 +27,8 @@
|
|||
#include <sys/time.h>
|
||||
#include <sys/resource.h>
|
||||
|
||||
#include <gio/gio.h>
|
||||
|
||||
#include "spa/include/spa/ringbuffer.h"
|
||||
#include "pinos/client/log.h"
|
||||
#include "pinos/client/rtkit.h"
|
||||
#include "pinos/server/data-loop.h"
|
||||
|
||||
|
|
@ -63,7 +62,7 @@ struct _PinosDataLoopPrivate
|
|||
uint32_t counter;
|
||||
uint32_t seq;
|
||||
|
||||
gboolean running;
|
||||
bool running;
|
||||
pthread_t thread;
|
||||
|
||||
};
|
||||
|
|
@ -97,31 +96,31 @@ make_realtime (PinosDataLoop *this)
|
|||
sp.sched_priority = rtprio;
|
||||
|
||||
if (pthread_setschedparam (pthread_self(), SCHED_RR|SCHED_RESET_ON_FORK, &sp) == 0) {
|
||||
g_debug ("SCHED_OTHER|SCHED_RESET_ON_FORK worked.");
|
||||
pinos_log_debug ("SCHED_OTHER|SCHED_RESET_ON_FORK worked.");
|
||||
return;
|
||||
}
|
||||
system_bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, NULL);
|
||||
|
||||
rl.rlim_cur = rl.rlim_max = rttime;
|
||||
if ((r = setrlimit (RLIMIT_RTTIME, &rl)) < 0)
|
||||
g_debug ("setrlimit() failed: %s", strerror (errno));
|
||||
pinos_log_debug ("setrlimit() failed: %s", strerror (errno));
|
||||
|
||||
if (rttime >= 0) {
|
||||
r = getrlimit (RLIMIT_RTTIME, &rl);
|
||||
if (r >= 0 && (long long) rl.rlim_max > rttime) {
|
||||
g_debug ("Clamping rlimit-rttime to %lld for RealtimeKit", rttime);
|
||||
pinos_log_debug ("Clamping rlimit-rttime to %lld for RealtimeKit", rttime);
|
||||
rl.rlim_cur = rl.rlim_max = rttime;
|
||||
|
||||
if ((r = setrlimit (RLIMIT_RTTIME, &rl)) < 0)
|
||||
g_debug ("setrlimit() failed: %s", strerror (errno));
|
||||
pinos_log_debug ("setrlimit() failed: %s", strerror (errno));
|
||||
}
|
||||
}
|
||||
|
||||
if (!pinos_rtkit_make_realtime (system_bus, 0, rtprio, &error)) {
|
||||
g_debug ("could not make thread realtime: %s", error->message);
|
||||
pinos_log_debug ("could not make thread realtime: %s", error->message);
|
||||
g_clear_error (&error);
|
||||
} else {
|
||||
g_debug ("thread made realtime");
|
||||
pinos_log_debug ("thread made realtime");
|
||||
}
|
||||
g_object_unref (system_bus);
|
||||
}
|
||||
|
|
@ -136,7 +135,7 @@ loop (void *user_data)
|
|||
|
||||
make_realtime (this);
|
||||
|
||||
g_debug ("data-loop %p: enter thread", this);
|
||||
pinos_log_debug ("data-loop %p: enter thread", this);
|
||||
while (priv->running) {
|
||||
SpaPollNotifyData ndata;
|
||||
unsigned int n_idle = 0;
|
||||
|
|
@ -196,7 +195,7 @@ loop (void *user_data)
|
|||
break;
|
||||
}
|
||||
if (r == 0) {
|
||||
g_warning ("data-loop %p: select timeout should not happen", this);
|
||||
pinos_log_warn ("data-loop %p: select timeout should not happen", this);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -206,7 +205,7 @@ loop (void *user_data)
|
|||
size_t offset;
|
||||
|
||||
if (read (priv->fds[0].fd, &u, sizeof(uint64_t)) != sizeof(uint64_t))
|
||||
g_warning ("data-loop %p: failed to read fd: %s", this, strerror (errno));
|
||||
pinos_log_warn ("data-loop %p: failed to read fd: %s", this, strerror (errno));
|
||||
|
||||
while (spa_ringbuffer_get_read_offset (&priv->buffer, &offset) > 0) {
|
||||
InvokeItem *item = SPA_MEMBER (priv->buffer_data, offset, InvokeItem);
|
||||
|
|
@ -232,7 +231,7 @@ loop (void *user_data)
|
|||
}
|
||||
}
|
||||
}
|
||||
g_debug ("data-loop %p: leave thread", this);
|
||||
pinos_log_debug ("data-loop %p: leave thread", this);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -244,7 +243,7 @@ wakeup_thread (PinosDataLoop *this)
|
|||
uint64_t u = 1;
|
||||
|
||||
if (write (priv->fds[0].fd, &u, sizeof(uint64_t)) != sizeof(uint64_t))
|
||||
g_warning ("data-loop %p: failed to write fd: %s", this, strerror (errno));
|
||||
pinos_log_warn ("data-loop %p: failed to write fd: %s", this, strerror (errno));
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -256,14 +255,14 @@ start_thread (PinosDataLoop *this)
|
|||
if (!priv->running) {
|
||||
priv->running = true;
|
||||
if ((err = pthread_create (&priv->thread, NULL, loop, this)) != 0) {
|
||||
g_warning ("data-loop %p: can't create thread: %s", this, strerror (err));
|
||||
pinos_log_warn ("data-loop %p: can't create thread: %s", this, strerror (err));
|
||||
priv->running = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
stop_thread (PinosDataLoop *this, gboolean in_thread)
|
||||
stop_thread (PinosDataLoop *this, bool in_thread)
|
||||
{
|
||||
PinosDataLoopPrivate *priv = this->priv;
|
||||
|
||||
|
|
@ -282,7 +281,7 @@ do_add_item (SpaPoll *poll,
|
|||
{
|
||||
PinosDataLoop *this = SPA_CONTAINER_OF (poll, PinosDataLoop, poll);
|
||||
PinosDataLoopPrivate *priv = this->priv;
|
||||
gboolean in_thread = pthread_equal (priv->thread, pthread_self());
|
||||
bool in_thread = pthread_equal (priv->thread, pthread_self());
|
||||
|
||||
item->id = ++priv->counter;
|
||||
priv->poll[priv->n_poll] = *item;
|
||||
|
|
@ -304,7 +303,7 @@ do_update_item (SpaPoll *poll,
|
|||
{
|
||||
PinosDataLoop *this = SPA_CONTAINER_OF (poll, PinosDataLoop, poll);
|
||||
PinosDataLoopPrivate *priv = this->priv;
|
||||
gboolean in_thread = pthread_equal (priv->thread, pthread_self());
|
||||
bool in_thread = pthread_equal (priv->thread, pthread_self());
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < priv->n_poll; i++) {
|
||||
|
|
@ -326,7 +325,7 @@ do_remove_item (SpaPoll *poll,
|
|||
{
|
||||
PinosDataLoop *this = SPA_CONTAINER_OF (poll, PinosDataLoop, poll);
|
||||
PinosDataLoopPrivate *priv = this->priv;
|
||||
gboolean in_thread = pthread_equal (priv->thread, pthread_self());
|
||||
bool in_thread = pthread_equal (priv->thread, pthread_self());
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < priv->n_poll; i++) {
|
||||
|
|
@ -355,7 +354,7 @@ do_invoke (SpaPoll *poll,
|
|||
{
|
||||
PinosDataLoop *this = SPA_CONTAINER_OF (poll, PinosDataLoop, poll);
|
||||
PinosDataLoopPrivate *priv = this->priv;
|
||||
gboolean in_thread = pthread_equal (priv->thread, pthread_self());
|
||||
bool in_thread = pthread_equal (priv->thread, pthread_self());
|
||||
SpaRingbufferArea areas[2];
|
||||
InvokeItem *item;
|
||||
SpaResult res;
|
||||
|
|
@ -365,7 +364,7 @@ do_invoke (SpaPoll *poll,
|
|||
} else {
|
||||
spa_ringbuffer_get_write_areas (&priv->buffer, areas);
|
||||
if (areas[0].len < sizeof (InvokeItem)) {
|
||||
g_warning ("queue full");
|
||||
pinos_log_warn ("queue full");
|
||||
return SPA_RESULT_ERROR;
|
||||
}
|
||||
item = SPA_MEMBER (priv->buffer_data, areas[0].offset, InvokeItem);
|
||||
|
|
@ -403,7 +402,7 @@ pinos_data_loop_constructed (GObject * obj)
|
|||
PinosDataLoop *this = PINOS_DATA_LOOP (obj);
|
||||
PinosDataLoopPrivate *priv = this->priv;
|
||||
|
||||
g_debug ("data-loop %p: constructed", this);
|
||||
pinos_log_debug ("data-loop %p: constructed", this);
|
||||
|
||||
G_OBJECT_CLASS (pinos_data_loop_parent_class)->constructed (obj);
|
||||
|
||||
|
|
@ -418,7 +417,7 @@ pinos_data_loop_dispose (GObject * obj)
|
|||
{
|
||||
PinosDataLoop *this = PINOS_DATA_LOOP (obj);
|
||||
|
||||
g_debug ("data-loop %p: dispose", this);
|
||||
pinos_log_debug ("data-loop %p: dispose", this);
|
||||
stop_thread (this, FALSE);
|
||||
|
||||
G_OBJECT_CLASS (pinos_data_loop_parent_class)->dispose (obj);
|
||||
|
|
@ -429,7 +428,7 @@ pinos_data_loop_finalize (GObject * obj)
|
|||
{
|
||||
PinosDataLoop *this = PINOS_DATA_LOOP (obj);
|
||||
|
||||
g_debug ("data-loop %p: finalize", this);
|
||||
pinos_log_debug ("data-loop %p: finalize", this);
|
||||
|
||||
G_OBJECT_CLASS (pinos_data_loop_parent_class)->finalize (obj);
|
||||
}
|
||||
|
|
@ -451,7 +450,7 @@ pinos_data_loop_init (PinosDataLoop * this)
|
|||
{
|
||||
PinosDataLoopPrivate *priv = this->priv = PINOS_DATA_LOOP_GET_PRIVATE (this);
|
||||
|
||||
g_debug ("data-loop %p: new", this);
|
||||
pinos_log_debug ("data-loop %p: new", this);
|
||||
|
||||
this->poll.size = sizeof (SpaPoll);
|
||||
this->poll.info = NULL;
|
||||
|
|
@ -476,7 +475,7 @@ pinos_data_loop_new (void)
|
|||
return g_object_new (PINOS_TYPE_DATA_LOOP, NULL);
|
||||
}
|
||||
|
||||
gboolean
|
||||
bool
|
||||
pinos_data_loop_in_thread (PinosDataLoop *loop)
|
||||
{
|
||||
return pthread_equal (loop->priv->thread, pthread_self());
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ GType pinos_data_loop_get_type (void);
|
|||
|
||||
PinosDataLoop * pinos_data_loop_new (void);
|
||||
|
||||
gboolean pinos_data_loop_in_thread (PinosDataLoop *loop);
|
||||
bool pinos_data_loop_in_thread (PinosDataLoop *loop);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
|
|
|||
|
|
@ -27,6 +27,8 @@
|
|||
#include <poll.h>
|
||||
#include <sys/eventfd.h>
|
||||
|
||||
#include "spa/lib/props.h"
|
||||
|
||||
#include "pinos/client/pinos.h"
|
||||
#include "pinos/client/enumtypes.h"
|
||||
#include "pinos/client/private.h"
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
#include <gio/gio.h>
|
||||
|
||||
#include <spa/include/spa/video/format.h>
|
||||
#include <spa/include/spa/debug.h>
|
||||
#include <spa/lib/debug.h>
|
||||
|
||||
#include "pinos/client/pinos.h"
|
||||
#include "pinos/client/enumtypes.h"
|
||||
|
|
@ -181,7 +181,9 @@ link_register_object (PinosLink *this)
|
|||
priv->object_path = pinos_daemon_export_uniquely (priv->daemon, G_DBUS_OBJECT_SKELETON (skel));
|
||||
g_object_unref (skel);
|
||||
|
||||
g_debug ("link %p: register object %s", this, priv->object_path);
|
||||
this->id = pinos_map_insert_new (&priv->daemon->registry.links, this);
|
||||
|
||||
pinos_log_debug ("link %p: register object %s, id %u", this, priv->object_path, this->id);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -189,8 +191,9 @@ link_unregister_object (PinosLink *this)
|
|||
{
|
||||
PinosLinkPrivate *priv = this->priv;
|
||||
|
||||
g_debug ("link %p: unregister object", this);
|
||||
pinos_log_debug ("link %p: unregister object", this);
|
||||
pinos_daemon_unexport (priv->daemon, priv->object_path);
|
||||
pinos_map_remove (&priv->daemon->registry.links, this->id);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -200,7 +203,7 @@ pinos_link_update_state (PinosLink *link, PinosLinkState state)
|
|||
|
||||
if (state != priv->state) {
|
||||
g_clear_error (&priv->error);
|
||||
g_debug ("link %p: update state %s -> %s", link,
|
||||
pinos_log_debug ("link %p: update state %s -> %s", link,
|
||||
pinos_link_state_as_string (priv->state),
|
||||
pinos_link_state_as_string (state));
|
||||
priv->state = state;
|
||||
|
|
@ -216,7 +219,7 @@ pinos_link_report_error (PinosLink *link, GError *error)
|
|||
g_clear_error (&priv->error);
|
||||
priv->error = error;
|
||||
priv->state = PINOS_LINK_STATE_ERROR;
|
||||
g_debug ("link %p: got error state %s", link, error->message);
|
||||
pinos_log_debug ("link %p: got error state %s", link, error->message);
|
||||
g_object_notify (G_OBJECT (link), "state");
|
||||
}
|
||||
|
||||
|
|
@ -235,7 +238,7 @@ do_negotiate (PinosLink *this, SpaNodeState in_state, SpaNodeState out_state)
|
|||
|
||||
/* both ports need a format */
|
||||
if (in_state == SPA_NODE_STATE_CONFIGURE && out_state == SPA_NODE_STATE_CONFIGURE) {
|
||||
g_debug ("link %p: doing negotiate format", this);
|
||||
pinos_log_debug ("link %p: doing negotiate format", this);
|
||||
again:
|
||||
if ((res = spa_node_port_enum_formats (this->input->node->node,
|
||||
SPA_DIRECTION_INPUT,
|
||||
|
|
@ -251,7 +254,7 @@ again:
|
|||
goto error;
|
||||
}
|
||||
}
|
||||
g_debug ("Try filter:");
|
||||
pinos_log_debug ("Try filter:");
|
||||
spa_debug_format (filter);
|
||||
|
||||
if ((res = spa_node_port_enum_formats (this->output->node->node,
|
||||
|
|
@ -270,7 +273,7 @@ again:
|
|||
"error output enum formats: %d", res);
|
||||
goto error;
|
||||
}
|
||||
g_debug ("Got filtered:");
|
||||
pinos_log_debug ("Got filtered:");
|
||||
spa_debug_format (format);
|
||||
spa_format_fixate (format);
|
||||
} else if (in_state == SPA_NODE_STATE_CONFIGURE && out_state > SPA_NODE_STATE_CONFIGURE) {
|
||||
|
|
@ -300,11 +303,11 @@ again:
|
|||
} else
|
||||
return SPA_RESULT_OK;
|
||||
|
||||
g_debug ("link %p: doing set format", this);
|
||||
pinos_log_debug ("link %p: doing set format", this);
|
||||
spa_debug_format (format);
|
||||
|
||||
if (out_state == SPA_NODE_STATE_CONFIGURE) {
|
||||
g_debug ("link %p: doing set format on output", this);
|
||||
pinos_log_debug ("link %p: doing set format on output", this);
|
||||
if ((res = spa_node_port_set_format (this->output->node->node,
|
||||
SPA_DIRECTION_OUTPUT,
|
||||
this->output->port,
|
||||
|
|
@ -317,7 +320,7 @@ again:
|
|||
goto error;
|
||||
}
|
||||
} else if (in_state == SPA_NODE_STATE_CONFIGURE) {
|
||||
g_debug ("link %p: doing set format on input", this);
|
||||
pinos_log_debug ("link %p: doing set format on input", this);
|
||||
if ((res = spa_node_port_set_format (this->input->node->node,
|
||||
SPA_DIRECTION_INPUT,
|
||||
this->input->port,
|
||||
|
|
@ -351,6 +354,20 @@ find_param (const SpaPortInfo *info, SpaAllocParamType type)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static void *
|
||||
find_meta_enable (const SpaPortInfo *info, SpaMetaType type)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < info->n_params; i++) {
|
||||
if (info->params[i]->type == SPA_ALLOC_PARAM_TYPE_META_ENABLE &&
|
||||
((SpaAllocParamMetaEnable*)info->params[i])->type == type) {
|
||||
return info->params[i];
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
do_allocation (PinosLink *this, SpaNodeState in_state, SpaNodeState out_state)
|
||||
{
|
||||
|
|
@ -365,7 +382,7 @@ do_allocation (PinosLink *this, SpaNodeState in_state, SpaNodeState out_state)
|
|||
|
||||
pinos_link_update_state (this, PINOS_LINK_STATE_ALLOCATING);
|
||||
|
||||
g_debug ("link %p: doing alloc buffers %p %p", this, this->output->node, this->input->node);
|
||||
pinos_log_debug ("link %p: doing alloc buffers %p %p", this, this->output->node, this->input->node);
|
||||
/* find out what's possible */
|
||||
if ((res = spa_node_port_get_info (this->output->node->node,
|
||||
SPA_DIRECTION_OUTPUT,
|
||||
|
|
@ -394,7 +411,7 @@ do_allocation (PinosLink *this, SpaNodeState in_state, SpaNodeState out_state)
|
|||
out_flags = oinfo->flags;
|
||||
|
||||
if (out_flags & SPA_PORT_INFO_FLAG_LIVE) {
|
||||
g_debug ("setting link as live");
|
||||
pinos_log_debug ("setting link as live");
|
||||
this->output->node->live = true;
|
||||
this->input->node->live = true;
|
||||
}
|
||||
|
|
@ -435,21 +452,33 @@ do_allocation (PinosLink *this, SpaNodeState in_state, SpaNodeState out_state)
|
|||
|
||||
if (priv->buffers == NULL) {
|
||||
SpaAllocParamBuffers *in_alloc, *out_alloc;
|
||||
guint max_buffers = MAX_BUFFERS;
|
||||
size_t minsize = 0, stride = 0;
|
||||
SpaAllocParamMetaEnableRingbuffer *in_me, *out_me;
|
||||
guint max_buffers;
|
||||
size_t minsize, stride, blocks;
|
||||
|
||||
max_buffers = MAX_BUFFERS;
|
||||
in_alloc = find_param (iinfo, SPA_ALLOC_PARAM_TYPE_BUFFERS);
|
||||
if (in_alloc) {
|
||||
max_buffers = in_alloc->max_buffers == 0 ? max_buffers : SPA_MIN (in_alloc->max_buffers, max_buffers);
|
||||
minsize = SPA_MAX (minsize, in_alloc->minsize);
|
||||
stride = SPA_MAX (stride, in_alloc->stride);
|
||||
}
|
||||
out_alloc = find_param (oinfo, SPA_ALLOC_PARAM_TYPE_BUFFERS);
|
||||
if (out_alloc) {
|
||||
max_buffers = out_alloc->max_buffers == 0 ? max_buffers : SPA_MIN (out_alloc->max_buffers, max_buffers);
|
||||
minsize = SPA_MAX (minsize, out_alloc->minsize);
|
||||
stride = SPA_MAX (stride, out_alloc->stride);
|
||||
in_me = find_meta_enable (iinfo, SPA_META_TYPE_RINGBUFFER);
|
||||
out_me = find_meta_enable (oinfo, SPA_META_TYPE_RINGBUFFER);
|
||||
if (in_me && out_me) {
|
||||
max_buffers = 1;
|
||||
minsize = SPA_MAX (out_me->minsize, in_me->minsize);
|
||||
stride = SPA_MAX (out_me->stride, in_me->stride);
|
||||
blocks = SPA_MAX (1, SPA_MAX (out_me->blocks, in_me->blocks));
|
||||
} else {
|
||||
max_buffers = MAX_BUFFERS;
|
||||
minsize = stride = 0;
|
||||
blocks = 1;
|
||||
in_alloc = find_param (iinfo, SPA_ALLOC_PARAM_TYPE_BUFFERS);
|
||||
if (in_alloc) {
|
||||
max_buffers = in_alloc->max_buffers == 0 ? max_buffers : SPA_MIN (in_alloc->max_buffers, max_buffers);
|
||||
minsize = SPA_MAX (minsize, in_alloc->minsize);
|
||||
stride = SPA_MAX (stride, in_alloc->stride);
|
||||
}
|
||||
out_alloc = find_param (oinfo, SPA_ALLOC_PARAM_TYPE_BUFFERS);
|
||||
if (out_alloc) {
|
||||
max_buffers = out_alloc->max_buffers == 0 ? max_buffers : SPA_MIN (out_alloc->max_buffers, max_buffers);
|
||||
minsize = SPA_MAX (minsize, out_alloc->minsize);
|
||||
stride = SPA_MAX (stride, out_alloc->stride);
|
||||
}
|
||||
}
|
||||
|
||||
if ((in_flags & SPA_PORT_INFO_FLAG_CAN_ALLOC_BUFFERS) ||
|
||||
|
|
@ -462,7 +491,7 @@ do_allocation (PinosLink *this, SpaNodeState in_state, SpaNodeState out_state)
|
|||
priv->n_buffers = this->output->n_buffers;
|
||||
priv->buffers = this->output->buffers;
|
||||
priv->allocated = FALSE;
|
||||
g_debug ("reusing %d output buffers %p", priv->n_buffers, priv->buffers);
|
||||
pinos_log_debug ("reusing %d output buffers %p", priv->n_buffers, priv->buffers);
|
||||
} else {
|
||||
guint i, j;
|
||||
size_t hdr_size, buf_size, arr_size;
|
||||
|
|
@ -486,7 +515,7 @@ do_allocation (PinosLink *this, SpaNodeState in_state, SpaNodeState out_state)
|
|||
}
|
||||
hdr_size += n_metas * sizeof (SpaMeta);
|
||||
|
||||
buf_size = SPA_ROUND_UP_N (hdr_size + minsize, 64);
|
||||
buf_size = SPA_ROUND_UP_N (hdr_size + (minsize * blocks), 64);
|
||||
|
||||
priv->n_buffers = max_buffers;
|
||||
pinos_memblock_alloc (PINOS_MEMBLOCK_FLAG_WITH_FD |
|
||||
|
|
@ -523,6 +552,17 @@ do_allocation (PinosLink *this, SpaNodeState in_state, SpaNodeState out_state)
|
|||
b->metas[mi].type = pme->type;
|
||||
b->metas[mi].data = pd;
|
||||
b->metas[mi].size = spa_meta_type_get_size (pme->type);
|
||||
|
||||
switch (pme->type) {
|
||||
case SPA_META_TYPE_RINGBUFFER:
|
||||
{
|
||||
SpaMetaRingbuffer *rb = pd;
|
||||
spa_ringbuffer_init (&rb->ringbuffer, minsize);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
pd = SPA_MEMBER (pd, b->metas[mi].size, void);
|
||||
mi++;
|
||||
}
|
||||
|
|
@ -543,7 +583,7 @@ do_allocation (PinosLink *this, SpaNodeState in_state, SpaNodeState out_state)
|
|||
d->data = NULL;
|
||||
}
|
||||
}
|
||||
g_debug ("allocated %d buffers %p %zd", priv->n_buffers, priv->buffers, minsize);
|
||||
pinos_log_debug ("allocated %d buffers %p %zd", priv->n_buffers, priv->buffers, minsize);
|
||||
priv->allocated = TRUE;
|
||||
}
|
||||
|
||||
|
|
@ -564,7 +604,7 @@ do_allocation (PinosLink *this, SpaNodeState in_state, SpaNodeState out_state)
|
|||
this->output->allocated = TRUE;
|
||||
this->output->buffer_mem = priv->buffer_mem;
|
||||
priv->allocated = FALSE;
|
||||
g_debug ("allocated %d buffers %p from output port", priv->n_buffers, priv->buffers);
|
||||
pinos_log_debug ("allocated %d buffers %p from output port", priv->n_buffers, priv->buffers);
|
||||
} else if (in_flags & SPA_PORT_INFO_FLAG_CAN_ALLOC_BUFFERS) {
|
||||
if ((res = spa_node_port_alloc_buffers (this->input->node->node,
|
||||
SPA_DIRECTION_INPUT,
|
||||
|
|
@ -582,12 +622,12 @@ do_allocation (PinosLink *this, SpaNodeState in_state, SpaNodeState out_state)
|
|||
this->input->allocated = TRUE;
|
||||
this->input->buffer_mem = priv->buffer_mem;
|
||||
priv->allocated = FALSE;
|
||||
g_debug ("allocated %d buffers %p from input port", priv->n_buffers, priv->buffers);
|
||||
pinos_log_debug ("allocated %d buffers %p from input port", priv->n_buffers, priv->buffers);
|
||||
}
|
||||
}
|
||||
|
||||
if (in_flags & SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS) {
|
||||
g_debug ("using %d buffers %p on input port", priv->n_buffers, priv->buffers);
|
||||
pinos_log_debug ("using %d buffers %p on input port", priv->n_buffers, priv->buffers);
|
||||
if ((res = spa_node_port_use_buffers (this->input->node->node,
|
||||
SPA_DIRECTION_INPUT,
|
||||
this->input->port,
|
||||
|
|
@ -604,7 +644,7 @@ do_allocation (PinosLink *this, SpaNodeState in_state, SpaNodeState out_state)
|
|||
this->input->allocated = FALSE;
|
||||
}
|
||||
else if (out_flags & SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS) {
|
||||
g_debug ("using %d buffers %p on output port", priv->n_buffers, priv->buffers);
|
||||
pinos_log_debug ("using %d buffers %p on output port", priv->n_buffers, priv->buffers);
|
||||
if ((res = spa_node_port_use_buffers (this->output->node->node,
|
||||
SPA_DIRECTION_OUTPUT,
|
||||
this->output->port,
|
||||
|
|
@ -673,7 +713,7 @@ check_states (PinosLink *this,
|
|||
PinosLinkPrivate *priv = this->priv;
|
||||
|
||||
if (res != SPA_RESULT_OK) {
|
||||
g_warning ("link %p: error: %d", this, res);
|
||||
pinos_log_warn ("link %p: error: %d", this, res);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
@ -684,7 +724,7 @@ again:
|
|||
in_state = this->input->node->node->state;
|
||||
out_state = this->output->node->node->state;
|
||||
|
||||
g_debug ("link %p: input state %d, output state %d", this, in_state, out_state);
|
||||
pinos_log_debug ("link %p: input state %d, output state %d", this, in_state, out_state);
|
||||
|
||||
if ((res = do_negotiate (this, in_state, out_state)) != SPA_RESULT_OK)
|
||||
goto exit;
|
||||
|
|
@ -714,7 +754,7 @@ on_async_complete_notify (PinosNode *node,
|
|||
PinosLink *this)
|
||||
{
|
||||
PinosLinkPrivate *priv = this->priv;
|
||||
g_debug ("link %p: node %p async complete %d %d", this, node, seq, res);
|
||||
pinos_log_debug ("link %p: node %p async complete %d %d", this, node, seq, res);
|
||||
pinos_main_loop_defer_complete (priv->main_loop, this, seq, res);
|
||||
}
|
||||
|
||||
|
|
@ -782,7 +822,7 @@ on_node_remove (PinosNode *node, PinosLink *this)
|
|||
priv->buffers = NULL;
|
||||
priv->n_buffers = 0;
|
||||
|
||||
g_debug ("link %p: clear input allocated buffers on port %p", link, other);
|
||||
pinos_log_debug ("link %p: clear input allocated buffers on port %p", link, other);
|
||||
pinos_port_clear_buffers (other);
|
||||
}
|
||||
|
||||
|
|
@ -814,7 +854,7 @@ pinos_link_constructed (GObject * object)
|
|||
G_OBJECT_CLASS (pinos_link_parent_class)->constructed (object);
|
||||
|
||||
on_property_notify (G_OBJECT (this), NULL, this);
|
||||
g_debug ("link %p: constructed %p:%d -> %p:%d", this,
|
||||
pinos_log_debug ("link %p: constructed %p:%d -> %p:%d", this,
|
||||
this->output->node, this->output->port,
|
||||
this->input->node, this->input->port);
|
||||
link_register_object (this);
|
||||
|
|
@ -826,7 +866,7 @@ pinos_link_dispose (GObject * object)
|
|||
PinosLink *this = PINOS_LINK (object);
|
||||
PinosLinkPrivate *priv = this->priv;
|
||||
|
||||
g_debug ("link %p: dispose", this);
|
||||
pinos_log_debug ("link %p: dispose", this);
|
||||
|
||||
if (this->input && this->input->node)
|
||||
g_signal_handlers_disconnect_by_data (this->input->node, this);
|
||||
|
|
@ -853,7 +893,7 @@ pinos_link_finalize (GObject * object)
|
|||
PinosLink *this = PINOS_LINK (object);
|
||||
PinosLinkPrivate *priv = this->priv;
|
||||
|
||||
g_debug ("link %p: finalize", this);
|
||||
pinos_log_debug ("link %p: finalize", this);
|
||||
g_clear_object (&priv->daemon);
|
||||
g_clear_object (&priv->iface);
|
||||
g_free (priv->object_path);
|
||||
|
|
@ -963,7 +1003,7 @@ pinos_link_init (PinosLink * this)
|
|||
PinosLinkPrivate *priv = this->priv = PINOS_LINK_GET_PRIVATE (this);
|
||||
|
||||
priv->iface = pinos_link1_skeleton_new ();
|
||||
g_debug ("link %p: new", this);
|
||||
pinos_log_debug ("link %p: new", this);
|
||||
priv->state = PINOS_LINK_STATE_INIT;
|
||||
}
|
||||
|
||||
|
|
@ -976,7 +1016,7 @@ pinos_link_init (PinosLink * this)
|
|||
void
|
||||
pinos_link_remove (PinosLink *this)
|
||||
{
|
||||
g_debug ("link %p: remove", this);
|
||||
pinos_log_debug ("link %p: remove", this);
|
||||
g_signal_emit (this, signals[SIGNAL_REMOVE], 0, NULL);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -50,6 +50,8 @@ typedef struct _PinosLinkPrivate PinosLinkPrivate;
|
|||
struct _PinosLink {
|
||||
GObject object;
|
||||
|
||||
uint32_t id;
|
||||
|
||||
PinosPort *output;
|
||||
PinosPort *input;
|
||||
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@
|
|||
|
||||
#include "spa/include/spa/queue.h"
|
||||
#include "spa/include/spa/ringbuffer.h"
|
||||
#include "pinos/client/log.h"
|
||||
#include "pinos/server/main-loop.h"
|
||||
|
||||
#define PINOS_MAIN_LOOP_GET_PRIVATE(loop) \
|
||||
|
|
@ -130,7 +131,7 @@ do_add_item (SpaPoll *poll,
|
|||
item->id = g_source_attach (source, g_main_context_get_thread_default ());
|
||||
g_source_unref (source);
|
||||
|
||||
g_debug ("added main poll %d", item->id);
|
||||
pinos_log_debug ("added main poll %d", item->id);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -139,7 +140,7 @@ static SpaResult
|
|||
do_update_item (SpaPoll *poll,
|
||||
SpaPollItem *item)
|
||||
{
|
||||
g_debug ("update main poll %d", item->id);
|
||||
pinos_log_debug ("update main poll %d", item->id);
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
|
|
@ -149,7 +150,7 @@ do_remove_item (SpaPoll *poll,
|
|||
{
|
||||
GSource *source;
|
||||
|
||||
g_debug ("remove main poll %d", item->id);
|
||||
pinos_log_debug ("remove main poll %d", item->id);
|
||||
source = g_main_context_find_source_by_id (g_main_context_get_thread_default (), item->id);
|
||||
g_source_destroy (source);
|
||||
|
||||
|
|
@ -167,7 +168,7 @@ main_loop_dispatch (SpaPollNotifyData *data)
|
|||
InvokeItem *item;
|
||||
|
||||
if (read (priv->fds[0].fd, &u, sizeof(uint64_t)) != sizeof(uint64_t))
|
||||
g_warning ("main-loop %p: failed to read fd", strerror (errno));
|
||||
pinos_log_warn ("main-loop %p: failed to read fd", strerror (errno));
|
||||
|
||||
while (spa_ringbuffer_get_read_offset (&priv->buffer, &offset) > 0) {
|
||||
item = SPA_MEMBER (priv->buffer_data, offset, InvokeItem);
|
||||
|
|
@ -199,7 +200,7 @@ do_invoke (SpaPoll *poll,
|
|||
} else {
|
||||
spa_ringbuffer_get_write_areas (&priv->buffer, areas);
|
||||
if (areas[0].len < sizeof (InvokeItem)) {
|
||||
g_warning ("queue full");
|
||||
pinos_log_warn ("queue full");
|
||||
return SPA_RESULT_ERROR;
|
||||
}
|
||||
item = SPA_MEMBER (priv->buffer_data, areas[0].offset, InvokeItem);
|
||||
|
|
@ -222,7 +223,7 @@ do_invoke (SpaPoll *poll,
|
|||
spa_ringbuffer_write_advance (&priv->buffer, item->item_size);
|
||||
|
||||
if (write (priv->fds[0].fd, &u, sizeof(uint64_t)) != sizeof(uint64_t))
|
||||
g_warning ("data-loop %p: failed to write fd", strerror (errno));
|
||||
pinos_log_warn ("data-loop %p: failed to write fd", strerror (errno));
|
||||
|
||||
res = SPA_RESULT_RETURN_ASYNC (seq);
|
||||
}
|
||||
|
|
@ -276,7 +277,7 @@ pinos_main_loop_constructed (GObject * obj)
|
|||
PinosMainLoop *this = PINOS_MAIN_LOOP (obj);
|
||||
PinosMainLoopPrivate *priv = this->priv;
|
||||
|
||||
g_debug ("main-loop %p: constructed", this);
|
||||
pinos_log_debug ("main-loop %p: constructed", this);
|
||||
priv->loop = g_main_loop_new (priv->context, FALSE);
|
||||
|
||||
priv->fds[0].fd = eventfd (0, 0);
|
||||
|
|
@ -301,7 +302,7 @@ pinos_main_loop_dispose (GObject * obj)
|
|||
{
|
||||
PinosMainLoop *this = PINOS_MAIN_LOOP (obj);
|
||||
|
||||
g_debug ("main-loop %p: dispose", this);
|
||||
pinos_log_debug ("main-loop %p: dispose", this);
|
||||
|
||||
G_OBJECT_CLASS (pinos_main_loop_parent_class)->dispose (obj);
|
||||
}
|
||||
|
|
@ -312,7 +313,7 @@ pinos_main_loop_finalize (GObject * obj)
|
|||
PinosMainLoop *this = PINOS_MAIN_LOOP (obj);
|
||||
PinosMainLoopPrivate *priv = this->priv;
|
||||
|
||||
g_debug ("main-loop %p: finalize", this);
|
||||
pinos_log_debug ("main-loop %p: finalize", this);
|
||||
|
||||
g_slice_free_chain (WorkItem, priv->free_list, next);
|
||||
|
||||
|
|
@ -349,7 +350,7 @@ pinos_main_loop_init (PinosMainLoop * this)
|
|||
{
|
||||
PinosMainLoopPrivate *priv = this->priv = PINOS_MAIN_LOOP_GET_PRIVATE (this);
|
||||
|
||||
g_debug ("main-loop %p: new", this);
|
||||
pinos_log_debug ("main-loop %p: new", this);
|
||||
|
||||
this->poll.size = sizeof (SpaPoll);
|
||||
this->poll.info = NULL;
|
||||
|
|
@ -400,7 +401,7 @@ process_work_queue (PinosMainLoop *this)
|
|||
prev->next = next;
|
||||
|
||||
if (item->func) {
|
||||
g_debug ("main-loop %p: process work item %p", this, item->obj);
|
||||
pinos_log_debug ("main-loop %p: process work item %p", this, item->obj);
|
||||
item->func (item->obj, item->data, item->res, item->id);
|
||||
}
|
||||
if (item->notify)
|
||||
|
|
@ -445,12 +446,12 @@ pinos_main_loop_defer (PinosMainLoop *loop,
|
|||
if (SPA_RESULT_IS_ASYNC (res)) {
|
||||
item->seq = SPA_RESULT_ASYNC_SEQ (res);
|
||||
item->res = res;
|
||||
g_debug ("main-loop %p: defer async %d for object %p", loop, item->seq, obj);
|
||||
pinos_log_debug ("main-loop %p: defer async %d for object %p", loop, item->seq, obj);
|
||||
} else {
|
||||
item->seq = SPA_ID_INVALID;
|
||||
item->res = res;
|
||||
have_work = TRUE;
|
||||
g_debug ("main-loop %p: defer object %p", loop, obj);
|
||||
pinos_log_debug ("main-loop %p: defer object %p", loop, obj);
|
||||
}
|
||||
SPA_QUEUE_PUSH_TAIL (&priv->work, WorkItem, next, item);
|
||||
|
||||
|
|
@ -474,7 +475,7 @@ pinos_main_loop_defer_cancel (PinosMainLoop *loop,
|
|||
|
||||
for (item = priv->work.head; item; item = item->next) {
|
||||
if ((id == 0 || item->id == id) && (obj == NULL || item->obj == obj)) {
|
||||
g_debug ("main-loop %p: cancel defer %d for object %p", loop, item->seq, item->obj);
|
||||
pinos_log_debug ("main-loop %p: cancel defer %d for object %p", loop, item->seq, item->obj);
|
||||
item->seq = SPA_ID_INVALID;
|
||||
item->func = NULL;
|
||||
have_work = TRUE;
|
||||
|
|
@ -499,14 +500,14 @@ pinos_main_loop_defer_complete (PinosMainLoop *loop,
|
|||
|
||||
for (item = priv->work.head; item; item = item->next) {
|
||||
if (item->obj == obj && item->seq == seq) {
|
||||
g_debug ("main-loop %p: found defered %d for object %p", loop, seq, obj);
|
||||
pinos_log_debug ("main-loop %p: found defered %d for object %p", loop, seq, obj);
|
||||
item->seq = SPA_ID_INVALID;
|
||||
item->res = res;
|
||||
have_work = TRUE;
|
||||
}
|
||||
}
|
||||
if (!have_work)
|
||||
g_debug ("main-loop %p: no defered %d found for object %p", loop, seq, obj);
|
||||
pinos_log_debug ("main-loop %p: no defered %d found for object %p", loop, seq, obj);
|
||||
|
||||
if (priv->work_id == 0 && have_work)
|
||||
priv->work_id = g_idle_add ((GSourceFunc) process_work_queue, loop);
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ pinoscore_headers = [
|
|||
'module.h',
|
||||
'node.h',
|
||||
'node-factory.h',
|
||||
'registry.h',
|
||||
'utils.h',
|
||||
]
|
||||
|
||||
|
|
@ -25,6 +26,7 @@ pinoscore_sources = [
|
|||
'module.c',
|
||||
'node.c',
|
||||
'node-factory.c',
|
||||
'registry.c',
|
||||
'utils.c',
|
||||
]
|
||||
|
||||
|
|
|
|||
|
|
@ -180,7 +180,7 @@ find_module (const gchar * path, const gchar *name)
|
|||
|
||||
dir = g_dir_open (path, 0, &err);
|
||||
if (dir == NULL) {
|
||||
g_warning ("could not open %s: %s", path, err->message);
|
||||
pinos_log_warn ("could not open %s: %s", path, err->message);
|
||||
g_error_free (err);
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -241,7 +241,7 @@ pinos_module_load (PinosDaemon * daemon,
|
|||
gchar **l;
|
||||
gint i;
|
||||
|
||||
g_debug ("PINOS_MODULE_DIR set to: %s", module_dir);
|
||||
pinos_log_debug ("PINOS_MODULE_DIR set to: %s", module_dir);
|
||||
|
||||
l = g_strsplit (module_dir, G_SEARCHPATH_SEPARATOR_S, 0);
|
||||
for (i = 0; l[i] != NULL; i++) {
|
||||
|
|
@ -251,7 +251,7 @@ pinos_module_load (PinosDaemon * daemon,
|
|||
}
|
||||
g_strfreev (l);
|
||||
} else {
|
||||
g_debug ("moduledir set to: %s", MODULEDIR);
|
||||
pinos_log_debug ("moduledir set to: %s", MODULEDIR);
|
||||
|
||||
filename = find_module (MODULEDIR, name);
|
||||
}
|
||||
|
|
@ -262,7 +262,7 @@ pinos_module_load (PinosDaemon * daemon,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
g_debug ("trying to load module: %s (%s)", name, filename);
|
||||
pinos_log_debug ("trying to load module: %s (%s)", name, filename);
|
||||
|
||||
gmodule = g_module_open (filename, G_MODULE_BIND_LOCAL);
|
||||
g_free (filename);
|
||||
|
|
@ -295,7 +295,7 @@ pinos_module_load (PinosDaemon * daemon,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
g_debug ("loaded module: %s", module->name);
|
||||
pinos_log_debug ("loaded module: %s", module->name);
|
||||
|
||||
return module;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,6 +25,8 @@
|
|||
|
||||
struct _PinosNodeFactoryPrivate
|
||||
{
|
||||
PinosDaemon *daemon;
|
||||
|
||||
gchar *name;
|
||||
};
|
||||
|
||||
|
|
@ -33,6 +35,7 @@ G_DEFINE_ABSTRACT_TYPE (PinosNodeFactory, pinos_node_factory, G_TYPE_OBJECT);
|
|||
enum
|
||||
{
|
||||
PROP_0,
|
||||
PROP_DAEMON,
|
||||
PROP_NAME,
|
||||
};
|
||||
|
||||
|
|
@ -46,6 +49,10 @@ pinos_node_factory_get_property (GObject *_object,
|
|||
PinosNodeFactoryPrivate *priv = factory->priv;
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_DAEMON:
|
||||
g_value_set_object (value, priv->daemon);
|
||||
break;
|
||||
|
||||
case PROP_NAME:
|
||||
g_value_set_string (value, priv->name);
|
||||
break;
|
||||
|
|
@ -66,6 +73,10 @@ pinos_node_factory_set_property (GObject *_object,
|
|||
PinosNodeFactoryPrivate *priv = factory->priv;
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_DAEMON:
|
||||
priv->daemon = g_value_dup_object (value);
|
||||
break;
|
||||
|
||||
case PROP_NAME:
|
||||
priv->name = g_value_dup_string (value);
|
||||
break;
|
||||
|
|
@ -80,9 +91,12 @@ static void
|
|||
pinos_node_factory_constructed (GObject * obj)
|
||||
{
|
||||
PinosNodeFactory *factory = PINOS_NODE_FACTORY (obj);
|
||||
PinosNodeFactoryPrivate *priv = factory->priv;
|
||||
|
||||
g_debug ("node factory %p: constructed", factory);
|
||||
|
||||
factory->id = pinos_map_insert_new (&priv->daemon->registry.node_factories, factory);
|
||||
|
||||
G_OBJECT_CLASS (pinos_node_factory_parent_class)->constructed (obj);
|
||||
}
|
||||
|
||||
|
|
@ -93,6 +107,7 @@ pinos_node_factory_finalize (GObject * obj)
|
|||
PinosNodeFactoryPrivate *priv = factory->priv;
|
||||
|
||||
g_debug ("node factory %p: finalize", factory);
|
||||
pinos_map_remove (&priv->daemon->registry.node_factories, factory->id);
|
||||
|
||||
g_free (priv->name);
|
||||
|
||||
|
|
@ -111,6 +126,16 @@ pinos_node_factory_class_init (PinosNodeFactoryClass * klass)
|
|||
gobject_class->set_property = pinos_node_factory_set_property;
|
||||
gobject_class->get_property = pinos_node_factory_get_property;
|
||||
|
||||
g_object_class_install_property (gobject_class,
|
||||
PROP_DAEMON,
|
||||
g_param_spec_object ("daemon",
|
||||
"Daemon",
|
||||
"The Daemon",
|
||||
PINOS_TYPE_DAEMON,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT_ONLY |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
g_object_class_install_property (gobject_class,
|
||||
PROP_NAME,
|
||||
g_param_spec_string ("name",
|
||||
|
|
@ -152,7 +177,6 @@ pinos_node_factory_get_name (PinosNodeFactory *factory)
|
|||
/**
|
||||
* pinos_node_factory_create_node:
|
||||
* @factory: A #PinosNodeFactory
|
||||
* @daemon: a #PinosDaemon
|
||||
* @client: the owner client
|
||||
* @name: node name
|
||||
* @props: #PinosProperties for the node
|
||||
|
|
@ -163,7 +187,6 @@ pinos_node_factory_get_name (PinosNodeFactory *factory)
|
|||
*/
|
||||
PinosNode *
|
||||
pinos_node_factory_create_node (PinosNodeFactory *factory,
|
||||
PinosDaemon *daemon,
|
||||
PinosClient *client,
|
||||
const gchar *name,
|
||||
PinosProperties *props)
|
||||
|
|
@ -177,5 +200,5 @@ pinos_node_factory_create_node (PinosNodeFactory *factory,
|
|||
return NULL;
|
||||
|
||||
g_debug ("node factory %p: create node", factory);
|
||||
return klass->create_node (factory, daemon, client, name, props);
|
||||
return klass->create_node (factory, factory->priv->daemon, client, name, props);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,6 +48,8 @@ typedef struct _PinosNodeFactoryPrivate PinosNodeFactoryPrivate;
|
|||
struct _PinosNodeFactory {
|
||||
GObject object;
|
||||
|
||||
uint32_t id;
|
||||
|
||||
PinosNodeFactoryPrivate *priv;
|
||||
};
|
||||
|
||||
|
|
@ -71,7 +73,6 @@ struct _PinosNodeFactoryClass {
|
|||
GType pinos_node_factory_get_type (void);
|
||||
|
||||
PinosNode * pinos_node_factory_create_node (PinosNodeFactory *factory,
|
||||
PinosDaemon *daemon,
|
||||
PinosClient *client,
|
||||
const gchar *name,
|
||||
PinosProperties *props);
|
||||
|
|
|
|||
|
|
@ -144,7 +144,7 @@ update_port_ids (PinosNode *node, gboolean create)
|
|||
max_output_ports,
|
||||
output_port_ids);
|
||||
|
||||
g_debug ("node %p: update_port ids %u/%u, %u/%u", node,
|
||||
pinos_log_debug ("node %p: update_port ids %u/%u, %u/%u", node,
|
||||
n_input_ports, max_input_ports, n_output_ports, max_output_ports);
|
||||
|
||||
i = 0;
|
||||
|
|
@ -157,7 +157,7 @@ update_port_ids (PinosNode *node, gboolean create)
|
|||
ports = g_list_next (ports);
|
||||
} else if ((p && i < n_input_ports && input_port_ids[i] < p->port) || i < n_input_ports) {
|
||||
PinosPort *np;
|
||||
g_debug ("node %p: input port added %d", node, input_port_ids[i]);
|
||||
pinos_log_debug ("node %p: input port added %d", node, input_port_ids[i]);
|
||||
|
||||
np = new_pinos_port (node, PINOS_DIRECTION_INPUT, input_port_ids[i]);
|
||||
priv->input_ports = g_list_insert_before (priv->input_ports, ports, np);
|
||||
|
|
@ -167,7 +167,7 @@ update_port_ids (PinosNode *node, gboolean create)
|
|||
i++;
|
||||
} else if (p) {
|
||||
GList *next;
|
||||
g_debug ("node %p: input port removed %d", node, p->port);
|
||||
pinos_log_debug ("node %p: input port removed %d", node, p->port);
|
||||
|
||||
next = g_list_next (ports);
|
||||
priv->input_ports = g_list_delete_link (priv->input_ports, ports);
|
||||
|
|
@ -191,7 +191,7 @@ update_port_ids (PinosNode *node, gboolean create)
|
|||
ports = g_list_next (ports);
|
||||
} else if ((p && i < n_output_ports && output_port_ids[i] < p->port) || i < n_output_ports) {
|
||||
PinosPort *np;
|
||||
g_debug ("node %p: output port added %d", node, output_port_ids[i]);
|
||||
pinos_log_debug ("node %p: output port added %d", node, output_port_ids[i]);
|
||||
|
||||
np = new_pinos_port (node, PINOS_DIRECTION_OUTPUT, output_port_ids[i]);
|
||||
priv->output_ports = g_list_insert_before (priv->output_ports, ports, np);
|
||||
|
|
@ -201,7 +201,7 @@ update_port_ids (PinosNode *node, gboolean create)
|
|||
i++;
|
||||
} else if (p) {
|
||||
GList *next;
|
||||
g_debug ("node %p: output port removed %d", node, p->port);
|
||||
pinos_log_debug ("node %p: output port removed %d", node, p->port);
|
||||
|
||||
next = g_list_next (ports);
|
||||
priv->output_ports = g_list_delete_link (priv->output_ports, ports);
|
||||
|
|
@ -231,12 +231,12 @@ pause_node (PinosNode *this)
|
|||
SpaResult res;
|
||||
SpaNodeCommand cmd;
|
||||
|
||||
g_debug ("node %p: pause node", this);
|
||||
pinos_log_debug ("node %p: pause node", this);
|
||||
|
||||
cmd.type = SPA_NODE_COMMAND_PAUSE;
|
||||
cmd.size = sizeof (cmd);
|
||||
if ((res = spa_node_send_command (this->node, &cmd)) < 0)
|
||||
g_debug ("got error %d", res);
|
||||
pinos_log_debug ("got error %d", res);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
|
@ -247,12 +247,12 @@ start_node (PinosNode *this)
|
|||
SpaResult res;
|
||||
SpaNodeCommand cmd;
|
||||
|
||||
g_debug ("node %p: start node", this);
|
||||
pinos_log_debug ("node %p: start node", this);
|
||||
|
||||
cmd.type = SPA_NODE_COMMAND_START;
|
||||
cmd.size = sizeof (cmd);
|
||||
if ((res = spa_node_send_command (this->node, &cmd)) < 0)
|
||||
g_debug ("got error %d", res);
|
||||
pinos_log_debug ("got error %d", res);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
|
@ -264,12 +264,12 @@ suspend_node (PinosNode *this)
|
|||
SpaResult res = SPA_RESULT_OK;
|
||||
GList *walk;
|
||||
|
||||
g_debug ("node %p: suspend node", this);
|
||||
pinos_log_debug ("node %p: suspend node", this);
|
||||
|
||||
for (walk = priv->input_ports; walk; walk = g_list_next (walk)) {
|
||||
PinosPort *p = walk->data;
|
||||
if ((res = spa_node_port_set_format (this->node, SPA_DIRECTION_INPUT, p->port, 0, NULL)) < 0)
|
||||
g_warning ("error unset format output: %d", res);
|
||||
pinos_log_warn ("error unset format output: %d", res);
|
||||
p->buffers = NULL;
|
||||
p->n_buffers = 0;
|
||||
if (p->allocated)
|
||||
|
|
@ -279,7 +279,7 @@ suspend_node (PinosNode *this)
|
|||
for (walk = priv->output_ports; walk; walk = g_list_next (walk)) {
|
||||
PinosPort *p = walk->data;
|
||||
if ((res = spa_node_port_set_format (this->node, SPA_DIRECTION_OUTPUT, p->port, 0, NULL)) < 0)
|
||||
g_warning ("error unset format output: %d", res);
|
||||
pinos_log_warn ("error unset format output: %d", res);
|
||||
p->buffers = NULL;
|
||||
p->n_buffers = 0;
|
||||
if (p->allocated)
|
||||
|
|
@ -314,7 +314,7 @@ send_clock_update (PinosNode *this)
|
|||
cu.state = SPA_CLOCK_STATE_RUNNING;
|
||||
|
||||
if ((res = spa_node_send_command (this->node, &cu.command)) < 0)
|
||||
g_debug ("got error %d", res);
|
||||
pinos_log_debug ("got error %d", res);
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
|
|
@ -341,7 +341,7 @@ do_read_link (SpaPoll *poll,
|
|||
iinfo[0].flags = SPA_PORT_INPUT_FLAG_NONE;
|
||||
|
||||
if ((res = spa_node_port_push_input (link->input->node->node, 1, iinfo)) < 0)
|
||||
g_warning ("node %p: error pushing buffer: %d, %d", this, res, iinfo[0].status);
|
||||
pinos_log_warn ("node %p: error pushing buffer: %d, %d", this, res, iinfo[0].status);
|
||||
|
||||
spa_ringbuffer_read_advance (&link->ringbuffer, 1);
|
||||
link->in_ready--;
|
||||
|
|
@ -367,7 +367,7 @@ on_node_event (SpaNode *node, SpaNodeEvent *event, void *user_data)
|
|||
{
|
||||
SpaNodeEventAsyncComplete *ac = (SpaNodeEventAsyncComplete *) event;
|
||||
|
||||
g_debug ("node %p: async complete event %d %d", this, ac->seq, ac->res);
|
||||
pinos_log_debug ("node %p: async complete event %d %d", this, ac->seq, ac->res);
|
||||
if (!pinos_main_loop_defer_complete (priv->main_loop, this, ac->seq, ac->res))
|
||||
g_signal_emit (this, signals[SIGNAL_ASYNC_COMPLETE], 0, ac->seq, ac->res);
|
||||
break;
|
||||
|
|
@ -405,7 +405,7 @@ on_node_event (SpaNode *node, SpaNodeEvent *event, void *user_data)
|
|||
oinfo[0].port_id = ho->port_id;
|
||||
|
||||
if ((res = spa_node_port_pull_output (node, 1, oinfo)) < 0) {
|
||||
g_warning ("node %p: got pull error %d, %d", this, res, oinfo[0].status);
|
||||
pinos_log_warn ("node %p: got pull error %d, %d", this, res, oinfo[0].status);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -434,7 +434,7 @@ on_node_event (SpaNode *node, SpaNodeEvent *event, void *user_data)
|
|||
}
|
||||
if (!pushed) {
|
||||
if ((res = spa_node_port_reuse_buffer (node, oinfo[0].port_id, oinfo[0].buffer_id)) < 0)
|
||||
g_warning ("node %p: error reuse buffer: %d", node, res);
|
||||
pinos_log_warn ("node %p: error reuse buffer: %d", node, res);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
@ -453,7 +453,7 @@ on_node_event (SpaNode *node, SpaNodeEvent *event, void *user_data)
|
|||
if ((res = spa_node_port_reuse_buffer (link->output->node->node,
|
||||
link->output->port,
|
||||
rb->buffer_id)) < 0)
|
||||
g_warning ("node %p: error reuse buffer: %d", node, res);
|
||||
pinos_log_warn ("node %p: error reuse buffer: %d", node, res);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
@ -470,7 +470,7 @@ handle_remove (PinosNode1 *interface,
|
|||
{
|
||||
PinosNode *this = user_data;
|
||||
|
||||
g_debug ("node %p: remove", this);
|
||||
pinos_log_debug ("node %p: remove", this);
|
||||
pinos_node_remove (this);
|
||||
|
||||
g_dbus_method_invocation_return_value (invocation,
|
||||
|
|
@ -554,7 +554,7 @@ pinos_node_set_property (GObject *_object,
|
|||
|
||||
if (priv->data_loop) {
|
||||
if ((res = spa_node_set_event_callback (this->node, on_node_event, this)) < 0)
|
||||
g_warning ("node %p: error setting callback", this);
|
||||
pinos_log_warn ("node %p: error setting callback", this);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
@ -599,7 +599,9 @@ node_register_object (PinosNode *this)
|
|||
priv->object_path = pinos_daemon_export_uniquely (daemon, G_DBUS_OBJECT_SKELETON (skel));
|
||||
g_object_unref (skel);
|
||||
|
||||
g_debug ("node %p: register object %s", this, priv->object_path);
|
||||
this->id = pinos_map_insert_new (&daemon->registry.nodes, this);
|
||||
pinos_log_debug ("node %p: register object %s, id %u", this, priv->object_path, this->id);
|
||||
|
||||
pinos_daemon_add_node (daemon, this);
|
||||
|
||||
return;
|
||||
|
|
@ -610,10 +612,11 @@ node_unregister_object (PinosNode *this)
|
|||
{
|
||||
PinosNodePrivate *priv = this->priv;
|
||||
|
||||
g_debug ("node %p: unregister object %s", this, priv->object_path);
|
||||
pinos_log_debug ("node %p: unregister object %s", this, priv->object_path);
|
||||
pinos_daemon_unexport (priv->daemon, priv->object_path);
|
||||
g_clear_pointer (&priv->object_path, g_free);
|
||||
pinos_daemon_remove_node (priv->daemon, this);
|
||||
pinos_map_remove (&priv->daemon->registry.nodes, this->id);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -645,7 +648,7 @@ init_complete (PinosNode *this)
|
|||
PinosNodePrivate *priv = this->priv;
|
||||
|
||||
update_port_ids (this, FALSE);
|
||||
g_debug ("node %p: init completed", this);
|
||||
pinos_log_debug ("node %p: init completed", this);
|
||||
priv->async_init = FALSE;
|
||||
on_property_notify (G_OBJECT (this), NULL, this);
|
||||
pinos_node_update_state (this, PINOS_NODE_STATE_SUSPENDED);
|
||||
|
|
@ -657,7 +660,7 @@ pinos_node_constructed (GObject * obj)
|
|||
PinosNode *this = PINOS_NODE (obj);
|
||||
PinosNodePrivate *priv = this->priv;
|
||||
|
||||
g_debug ("node %p: constructed", this);
|
||||
pinos_log_debug ("node %p: constructed", this);
|
||||
|
||||
priv->main_loop = priv->daemon->main_loop;
|
||||
|
||||
|
|
@ -696,7 +699,7 @@ pinos_node_dispose (GObject * obj)
|
|||
PinosNode *node = PINOS_NODE (obj);
|
||||
PinosNodePrivate *priv = node->priv;
|
||||
|
||||
g_debug ("node %p: dispose", node);
|
||||
pinos_log_debug ("node %p: dispose", node);
|
||||
pinos_node_set_state (node, PINOS_NODE_STATE_SUSPENDED);
|
||||
|
||||
node_unregister_object (node);
|
||||
|
|
@ -712,7 +715,7 @@ pinos_node_finalize (GObject * obj)
|
|||
PinosNode *node = PINOS_NODE (obj);
|
||||
PinosNodePrivate *priv = node->priv;
|
||||
|
||||
g_debug ("node %p: finalize", node);
|
||||
pinos_log_debug ("node %p: finalize", node);
|
||||
g_clear_object (&priv->daemon);
|
||||
g_clear_object (&priv->iface);
|
||||
g_clear_object (&priv->data_loop);
|
||||
|
|
@ -871,7 +874,7 @@ pinos_node_init (PinosNode * node)
|
|||
{
|
||||
PinosNodePrivate *priv = node->priv = PINOS_NODE_GET_PRIVATE (node);
|
||||
|
||||
g_debug ("node %p: new", node);
|
||||
pinos_log_debug ("node %p: new", node);
|
||||
priv->iface = pinos_node1_skeleton_new ();
|
||||
g_signal_connect (priv->iface, "handle-remove",
|
||||
(GCallback) handle_remove,
|
||||
|
|
@ -1009,7 +1012,7 @@ pinos_node_remove (PinosNode *node)
|
|||
if (node->flags & PINOS_NODE_FLAG_REMOVING)
|
||||
return;
|
||||
|
||||
g_debug ("node %p: remove", node);
|
||||
pinos_log_debug ("node %p: remove", node);
|
||||
node->flags |= PINOS_NODE_FLAG_REMOVING;
|
||||
g_signal_emit (node, signals[SIGNAL_REMOVE], 0, NULL);
|
||||
}
|
||||
|
|
@ -1046,7 +1049,7 @@ pinos_node_get_free_port (PinosNode *node,
|
|||
}
|
||||
free_port = 0;
|
||||
|
||||
g_debug ("node %p: direction %d max %u, n %u, free_port %u", node, direction, max_ports, n_ports, free_port);
|
||||
pinos_log_debug ("node %p: direction %d max %u, n %u, free_port %u", node, direction, max_ports, n_ports, free_port);
|
||||
|
||||
for (walk = ports; walk; walk = g_list_next (walk)) {
|
||||
PinosPort *p = walk->data;
|
||||
|
|
@ -1140,7 +1143,7 @@ pinos_port_link (PinosPort *output_port,
|
|||
priv = output_node->priv;
|
||||
input_node = input_port->node;
|
||||
|
||||
g_debug ("port link %p:%u -> %p:%u", output_node, output_port->port, input_node, input_port->port);
|
||||
pinos_log_debug ("port link %p:%u -> %p:%u", output_node, output_port->port, input_node, input_port->port);
|
||||
|
||||
if (output_node == input_node)
|
||||
goto same_node;
|
||||
|
|
@ -1156,7 +1159,7 @@ pinos_port_link (PinosPort *output_port,
|
|||
input_node->live = output_node->live;
|
||||
if (output_node->clock)
|
||||
input_node->clock = output_node->clock;
|
||||
g_debug ("node %p: clock %p, live %d", output_node, output_node->clock, output_node->live);
|
||||
pinos_log_debug ("node %p: clock %p, live %d", output_node, output_node->clock, output_node->live);
|
||||
|
||||
link = g_object_new (PINOS_TYPE_LINK,
|
||||
"daemon", priv->daemon,
|
||||
|
|
@ -1231,7 +1234,7 @@ do_remove_link_done (SpaPoll *poll,
|
|||
PinosNodePrivate *priv = this->priv;
|
||||
PinosLink *link = ((PinosLink**)data)[0];
|
||||
|
||||
g_debug ("port %p: finish unlink", port);
|
||||
pinos_log_debug ("port %p: finish unlink", port);
|
||||
if (port->direction == PINOS_DIRECTION_OUTPUT) {
|
||||
if (g_ptr_array_remove_fast (port->links, link))
|
||||
priv->n_used_output_links--;
|
||||
|
|
@ -1248,7 +1251,7 @@ do_remove_link_done (SpaPoll *poll,
|
|||
}
|
||||
|
||||
if (!port->allocated) {
|
||||
g_debug ("port %p: clear buffers on port", port);
|
||||
pinos_log_debug ("port %p: clear buffers on port", port);
|
||||
spa_node_port_use_buffers (port->node->node,
|
||||
port->direction,
|
||||
port->port,
|
||||
|
|
@ -1302,7 +1305,7 @@ pinos_port_unlink (PinosPort *port, PinosLink *link)
|
|||
{
|
||||
SpaResult res;
|
||||
|
||||
g_debug ("port %p: start unlink %p", port, link);
|
||||
pinos_log_debug ("port %p: start unlink %p", port, link);
|
||||
|
||||
g_object_ref (link);
|
||||
g_object_ref (port->node);
|
||||
|
|
@ -1328,7 +1331,7 @@ do_clear_buffers_done (SpaPoll *poll,
|
|||
PinosNodePrivate *priv = this->priv;
|
||||
SpaResult res;
|
||||
|
||||
g_debug ("port %p: clear buffers finish", port);
|
||||
pinos_log_debug ("port %p: clear buffers finish", port);
|
||||
|
||||
res = spa_node_port_use_buffers (port->node->node,
|
||||
port->direction,
|
||||
|
|
@ -1372,7 +1375,7 @@ pinos_port_clear_buffers (PinosPort *port)
|
|||
{
|
||||
SpaResult res;
|
||||
|
||||
g_debug ("port %p: clear buffers", port);
|
||||
pinos_log_debug ("port %p: clear buffers", port);
|
||||
res = spa_poll_invoke (&port->node->priv->data_loop->poll,
|
||||
do_clear_buffers,
|
||||
port->node->priv->seq++,
|
||||
|
|
@ -1457,7 +1460,7 @@ pinos_node_set_state (PinosNode *node,
|
|||
|
||||
remove_idle_timeout (node);
|
||||
|
||||
g_debug ("node %p: set state %s", node, pinos_node_state_as_string (state));
|
||||
pinos_log_debug ("node %p: set state %s", node, pinos_node_state_as_string (state));
|
||||
|
||||
switch (state) {
|
||||
case PINOS_NODE_STATE_CREATING:
|
||||
|
|
@ -1515,7 +1518,7 @@ pinos_node_update_state (PinosNode *node,
|
|||
|
||||
old = priv->state;
|
||||
if (old != state) {
|
||||
g_debug ("node %p: update state from %s -> %s", node,
|
||||
pinos_log_debug ("node %p: update state from %s -> %s", node,
|
||||
pinos_node_state_as_string (old),
|
||||
pinos_node_state_as_string (state));
|
||||
priv->state = state;
|
||||
|
|
@ -1546,7 +1549,7 @@ pinos_node_report_error (PinosNode *node,
|
|||
remove_idle_timeout (node);
|
||||
priv->error = error;
|
||||
priv->state = PINOS_NODE_STATE_ERROR;
|
||||
g_debug ("node %p: got error state %s", node, error->message);
|
||||
pinos_log_debug ("node %p: got error state %s", node, error->message);
|
||||
pinos_node1_set_state (priv->iface, PINOS_NODE_STATE_ERROR);
|
||||
g_signal_emit (node, signals[SIGNAL_STATE_CHANGE], 0, old, priv->state);
|
||||
}
|
||||
|
|
@ -1557,7 +1560,7 @@ idle_timeout (PinosNode *node)
|
|||
PinosNodePrivate *priv = node->priv;
|
||||
|
||||
priv->idle_timeout = 0;
|
||||
g_debug ("node %p: idle timeout", node);
|
||||
pinos_log_debug ("node %p: idle timeout", node);
|
||||
pinos_node_set_state (node, PINOS_NODE_STATE_SUSPENDED);
|
||||
|
||||
return G_SOURCE_REMOVE;
|
||||
|
|
@ -1578,7 +1581,7 @@ pinos_node_report_idle (PinosNode *node)
|
|||
g_return_if_fail (PINOS_IS_NODE (node));
|
||||
priv = node->priv;
|
||||
|
||||
g_debug ("node %p: report idle", node);
|
||||
pinos_log_debug ("node %p: report idle", node);
|
||||
pinos_node_set_state (node, PINOS_NODE_STATE_IDLE);
|
||||
|
||||
priv->idle_timeout = g_timeout_add_seconds (3,
|
||||
|
|
@ -1598,6 +1601,6 @@ pinos_node_report_busy (PinosNode *node)
|
|||
{
|
||||
g_return_if_fail (PINOS_IS_NODE (node));
|
||||
|
||||
g_debug ("node %p: report busy", node);
|
||||
pinos_log_debug ("node %p: report busy", node);
|
||||
pinos_node_set_state (node, PINOS_NODE_STATE_RUNNING);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ typedef enum {
|
|||
#include <pinos/server/utils.h>
|
||||
|
||||
struct _PinosPort {
|
||||
uint32_t id;
|
||||
PinosNode *node;
|
||||
PinosDirection direction;
|
||||
uint32_t port;
|
||||
|
|
@ -71,6 +72,8 @@ struct _PinosPort {
|
|||
struct _PinosNode {
|
||||
GObject object;
|
||||
|
||||
uint32_t id;
|
||||
|
||||
PinosNodeFlags flags;
|
||||
|
||||
SpaNode *node;
|
||||
|
|
|
|||
36
pinos/server/registry.c
Normal file
36
pinos/server/registry.c
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
/* Pinos
|
||||
* Copyright (C) 2015 Wim Taymans <wim.taymans@gmail.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "pinos/client/pinos.h"
|
||||
#include "pinos/server/registry.h"
|
||||
|
||||
void
|
||||
pinos_registry_init (PinosRegistry *reg)
|
||||
{
|
||||
reg->map = pinos_id_map_get_default();
|
||||
|
||||
pinos_map_init (®->clients, 64);
|
||||
pinos_map_init (®->nodes, 128);
|
||||
pinos_map_init (®->ports, 512);
|
||||
pinos_map_init (®->links, 256);
|
||||
pinos_map_init (®->modules, 128);
|
||||
pinos_map_init (®->monitors, 64);
|
||||
}
|
||||
57
pinos/server/registry.h
Normal file
57
pinos/server/registry.h
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
/* Pinos
|
||||
* Copyright (C) 2015 Wim Taymans <wim.taymans@gmail.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __PINOS_REGISTRY_H__
|
||||
#define __PINOS_REGISTRY_H__
|
||||
|
||||
#include <glib-object.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#include <pinos/client/map.h>
|
||||
#include <spa/include/spa/id-map.h>
|
||||
|
||||
typedef struct _PinosRegistry PinosRegistry;
|
||||
|
||||
/**
|
||||
* PinosRegistry:
|
||||
*
|
||||
* Pinos registry struct.
|
||||
*/
|
||||
struct _PinosRegistry {
|
||||
SpaIDMap *map;
|
||||
|
||||
PinosMap objects;
|
||||
|
||||
PinosMap clients;
|
||||
PinosMap node_factories;
|
||||
PinosMap nodes;
|
||||
PinosMap ports;
|
||||
PinosMap links;
|
||||
PinosMap modules;
|
||||
PinosMap monitors;
|
||||
PinosMap devices;
|
||||
};
|
||||
|
||||
|
||||
void pinos_registry_init (PinosRegistry *reg);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __PINOS_REGISTRY_H__ */
|
||||
|
|
@ -28,6 +28,7 @@
|
|||
|
||||
#include "memfd-wrappers.h"
|
||||
|
||||
#include <pinos/client/log.h>
|
||||
#include <pinos/server/utils.h>
|
||||
|
||||
#undef USE_MEMFD
|
||||
|
|
@ -47,21 +48,21 @@ pinos_memblock_alloc (PinosMemblockFlags flags,
|
|||
#ifdef USE_MEMFD
|
||||
mem->fd = memfd_create ("pinos-memfd", MFD_CLOEXEC | MFD_ALLOW_SEALING);
|
||||
if (mem->fd == -1) {
|
||||
fprintf (stderr, "Failed to create memfd: %s\n", strerror (errno));
|
||||
pinos_log_error ("Failed to create memfd: %s\n", strerror (errno));
|
||||
return FALSE;
|
||||
}
|
||||
#else
|
||||
char filename[] = "/dev/shm/spa-tmpfile.XXXXXX";
|
||||
mem->fd = mkostemp (filename, O_CLOEXEC);
|
||||
if (mem->fd == -1) {
|
||||
fprintf (stderr, "Failed to create temporary file: %s\n", strerror (errno));
|
||||
pinos_log_error ("Failed to create temporary file: %s\n", strerror (errno));
|
||||
return FALSE;
|
||||
}
|
||||
unlink (filename);
|
||||
#endif
|
||||
|
||||
if (ftruncate (mem->fd, size) < 0) {
|
||||
g_warning ("Failed to truncate temporary file: %s", strerror (errno));
|
||||
pinos_log_warn ("Failed to truncate temporary file: %s", strerror (errno));
|
||||
close (mem->fd);
|
||||
return FALSE;
|
||||
}
|
||||
|
|
@ -69,7 +70,7 @@ pinos_memblock_alloc (PinosMemblockFlags flags,
|
|||
if (flags & PINOS_MEMBLOCK_FLAG_SEAL) {
|
||||
unsigned int seals = F_SEAL_GROW | F_SEAL_SHRINK | F_SEAL_SEAL;
|
||||
if (fcntl (mem->fd, F_ADD_SEALS, seals) == -1) {
|
||||
g_warning ("Failed to add seals: %s", strerror (errno));
|
||||
pinos_log_warn ("Failed to add seals: %s", strerror (errno));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue