Optimize transport some more

We can optimize the transport some more if we allow the host to
configure the area used for transfering buffers. We can then also place
the current status in the area and avoid calling get_status(). We can
also allocate this area in shared memory, avoiding a memcpy in the
client-node.
This commit is contained in:
Wim Taymans 2016-11-07 18:23:09 +01:00
parent b774b99db5
commit e88a376d7c
21 changed files with 903 additions and 989 deletions

View file

@ -668,7 +668,9 @@ static inline void
send_need_input (PinosStream *stream)
{
PinosStreamPrivate *priv = stream->priv;
pinos_transport_write_cmd (priv->trans, PINOS_TRANSPORT_CMD_NEED_DATA);
uint8_t cmd = PINOS_TRANSPORT_CMD_NEED_DATA;
write (priv->rtfd, &cmd, 1);
}
static void
@ -1068,7 +1070,6 @@ parse_connection (PinosStream *stream)
break;
info.offset = p.offset;
info.size = p.size;
info.fd = priv->rtfd;
pinos_log_debug ("transport update %d %p", priv->rtfd, priv->trans);
@ -1165,24 +1166,24 @@ on_rtsocket_condition (GSocket *socket,
uint8_t cmd;
int i;
pinos_transport_read_cmd (priv->trans, &cmd);
read (priv->rtfd, &cmd, 1);
if (cmd & PINOS_TRANSPORT_CMD_HAVE_DATA) {
BufferId *bid;
for (i = 0; i < priv->trans->area->n_input_info; i++) {
SpaPortInputInfo *info = &priv->trans->input_info[i];
for (i = 0; i < priv->trans->area->n_inputs; i++) {
SpaPortInput *input = &priv->trans->inputs[i];
if (info->buffer_id == SPA_ID_INVALID)
if (input->buffer_id == SPA_ID_INVALID)
continue;
if ((bid = find_buffer (stream, info->buffer_id))) {
if ((bid = find_buffer (stream, input->buffer_id))) {
for (i = 0; i < bid->buf->n_datas; i++) {
bid->buf->datas[i].size = bid->datas[i].size;
}
g_signal_emit (stream, signals[SIGNAL_NEW_BUFFER], 0, bid->id);
}
info->buffer_id = SPA_ID_INVALID;
input->buffer_id = SPA_ID_INVALID;
}
send_need_input (stream);
}
@ -1804,6 +1805,7 @@ pinos_stream_recycle_buffer (PinosStream *stream,
{
PinosStreamPrivate *priv;
SpaNodeEventReuseBuffer rb;
uint8_t cmd = PINOS_TRANSPORT_CMD_HAVE_EVENT;
g_return_val_if_fail (PINOS_IS_STREAM (stream), FALSE);
g_return_val_if_fail (id != SPA_ID_INVALID, FALSE);
@ -1815,7 +1817,7 @@ pinos_stream_recycle_buffer (PinosStream *stream,
rb.port_id = priv->port_id;
rb.buffer_id = id;
pinos_transport_add_event (priv->trans, &rb.event);
pinos_transport_write_cmd (priv->trans, PINOS_TRANSPORT_CMD_HAVE_EVENT);
write (priv->rtfd, &cmd, 1);
return TRUE;
}
@ -1871,13 +1873,15 @@ pinos_stream_send_buffer (PinosStream *stream,
g_return_val_if_fail (priv->direction == SPA_DIRECTION_OUTPUT, FALSE);
if ((bid = find_buffer (stream, id))) {
uint8_t cmd = PINOS_TRANSPORT_CMD_HAVE_DATA;
bid->used = TRUE;
for (i = 0; i < bid->buf->n_datas; i++) {
bid->datas[i].size = bid->buf->datas[i].size;
}
priv->trans->output_info[0].buffer_id = id;
priv->trans->output_info[0].status = SPA_RESULT_OK;
pinos_transport_write_cmd (priv->trans, PINOS_TRANSPORT_CMD_HAVE_DATA);
priv->trans->outputs[0].buffer_id = id;
priv->trans->outputs[0].status = SPA_RESULT_OK;
write (priv->rtfd, &cmd, 1);
return TRUE;
} else {
return FALSE;

View file

@ -45,8 +45,8 @@ transport_area_get_size (PinosTransportArea *area)
{
size_t size;
size = sizeof (PinosTransportArea);
size += area->max_input_info * sizeof (SpaPortInputInfo);
size += area->max_output_info * sizeof (SpaPortOutputInfo);
size += area->max_inputs * sizeof (SpaPortInput);
size += area->max_outputs * sizeof (SpaPortOutput);
size += sizeof (SpaRingbuffer);
size += INPUT_BUFFER_SIZE;
size += sizeof (SpaRingbuffer);
@ -60,13 +60,13 @@ transport_setup_area (void *p, PinosTransport *trans)
PinosTransportArea *a;
trans->area = a = p;
p = SPA_MEMBER (p, sizeof (PinosTransportArea), SpaPortInputInfo);
p = SPA_MEMBER (p, sizeof (PinosTransportArea), SpaPortInput);
trans->input_info = p;
p = SPA_MEMBER (p, a->max_input_info * sizeof (SpaPortInputInfo), void);
trans->inputs = p;
p = SPA_MEMBER (p, a->max_inputs * sizeof (SpaPortInput), void);
trans->output_info = p;
p = SPA_MEMBER (p, a->max_output_info * sizeof (SpaPortOutputInfo), void);
trans->outputs = p;
p = SPA_MEMBER (p, a->max_outputs * sizeof (SpaPortOutput), void);
trans->input_buffer = p;
spa_ringbuffer_init (trans->input_buffer, INPUT_BUFFER_SIZE);
@ -84,24 +84,22 @@ transport_setup_area (void *p, PinosTransport *trans)
}
PinosTransport *
pinos_transport_new (unsigned int max_input_info,
unsigned int max_output_info,
int fd)
pinos_transport_new (unsigned int max_inputs,
unsigned int max_outputs)
{
PinosTransportImpl *impl;
PinosTransport *trans;
PinosTransportArea area;
area.max_input_info = max_input_info;
area.n_input_info = 0;
area.max_output_info = max_output_info;
area.n_output_info = 0;
area.max_inputs = max_inputs;
area.n_inputs = 0;
area.max_outputs = max_outputs;
area.n_outputs = 0;
impl = calloc (1, sizeof (PinosTransportImpl));
impl->offset = 0;
trans = &impl->trans;
trans->fd = fd;
pinos_memblock_alloc (PINOS_MEMBLOCK_FLAG_WITH_FD |
PINOS_MEMBLOCK_FLAG_MAP_READWRITE |
@ -127,7 +125,6 @@ pinos_transport_new_from_info (PinosTransportInfo *info)
impl = calloc (1, sizeof (PinosTransportImpl));
trans = &impl->trans;
trans->fd = info->fd;
impl->mem.flags = PINOS_MEMBLOCK_FLAG_MAP_READWRITE |
PINOS_MEMBLOCK_FLAG_WITH_FD;
@ -159,8 +156,6 @@ pinos_transport_free (PinosTransport *trans)
return;
pinos_memblock_free (&impl->mem);
if (trans->fd != -1)
close (trans->fd);
free (impl);
}
@ -176,7 +171,6 @@ pinos_transport_get_info (PinosTransport *trans,
info->memfd = impl->mem.fd;
info->offset = impl->offset;
info->size = impl->mem.size;
info->fd = trans->fd;
return SPA_RESULT_OK;
}

View file

@ -46,30 +46,27 @@ typedef struct {
int memfd;
off_t offset;
size_t size;
int fd;
} PinosTransportInfo;
struct _PinosTransportArea {
unsigned int max_input_info;
unsigned int n_input_info;
unsigned int max_output_info;
unsigned int n_output_info;
unsigned int max_inputs;
unsigned int n_inputs;
unsigned int max_outputs;
unsigned int n_outputs;
};
struct _PinosTransport {
PinosTransportArea *area;
SpaPortInputInfo *input_info;
SpaPortOutputInfo *output_info;
SpaPortInput *inputs;
SpaPortOutput *outputs;
void *input_data;
SpaRingbuffer *input_buffer;
void *output_data;
SpaRingbuffer *output_buffer;
int fd;
};
PinosTransport * pinos_transport_new (unsigned int max_input_info,
unsigned int max_output_info,
int fd);
PinosTransport * pinos_transport_new (unsigned int max_inputs,
unsigned int max_outputs);
PinosTransport * pinos_transport_new_from_info (PinosTransportInfo *info);
void pinos_transport_free (PinosTransport *trans);
@ -85,29 +82,6 @@ SpaResult pinos_transport_next_event (PinosTransport *trans,
SpaResult pinos_transport_parse_event (PinosTransport *trans,
void *event);
static inline void
pinos_transport_write_cmd (PinosTransport *trans,
uint8_t cmd)
{
write (trans->fd, &cmd, 1);
}
static inline void
pinos_transport_read_cmd (PinosTransport *trans,
uint8_t *cmd)
{
read (trans->fd, cmd, 1);
}
static inline void
pinos_transport_sync_cmd (PinosTransport *trans,
uint8_t out_cmd,
uint8_t *in_cmd)
{
write (trans->fd, &out_cmd, 1);
read (trans->fd, in_cmd, 1);
}
#ifdef __cplusplus
} /* extern "C" */
#endif

View file

@ -80,7 +80,7 @@ typedef struct {
SpaFormat *format;
unsigned int n_formats;
SpaFormat **formats;
SpaPortStatus status;
void *io;
unsigned int n_buffers;
ProxyBuffer buffers[MAX_BUFFERS];
@ -97,6 +97,8 @@ struct _SpaProxy
{
SpaNode node;
PinosNode *pnode;
SpaIDMap *map;
SpaLog *log;
SpaPoll *main_loop;
@ -119,8 +121,6 @@ struct _SpaProxy
SpaProxyPort in_ports[MAX_INPUTS];
SpaProxyPort out_ports[MAX_OUTPUTS];
PinosTransport *trans;
uint32_t seq;
};
@ -590,28 +590,41 @@ spa_proxy_node_port_set_props (SpaNode *node,
}
static SpaResult
spa_proxy_node_port_get_status (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
const SpaPortStatus **status)
spa_proxy_node_port_set_input (SpaNode *node,
uint32_t port_id,
SpaPortInput *input)
{
SpaProxy *this;
SpaProxyPort *port;
if (node == NULL || status == NULL)
if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
this = SPA_CONTAINER_OF (node, SpaProxy, node);
if (!CHECK_PORT (this, direction, port_id))
if (!CHECK_PORT (this, SPA_DIRECTION_INPUT, port_id))
return SPA_RESULT_INVALID_PORT;
port = direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[port_id];
this->in_ports[port_id].io = input;
if (!port->format)
return SPA_RESULT_NO_FORMAT;
return SPA_RESULT_OK;
}
*status = &port->status;
static SpaResult
spa_proxy_node_port_set_output (SpaNode *node,
uint32_t port_id,
SpaPortOutput *output)
{
SpaProxy *this;
if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
this = SPA_CONTAINER_OF (node, SpaProxy, node);
if (!CHECK_PORT (this, SPA_DIRECTION_OUTPUT, port_id))
return SPA_RESULT_INVALID_PORT;
this->out_ports[port_id].io = output;
return SPA_RESULT_OK;
}
@ -848,99 +861,6 @@ copy_meta_out (SpaProxy *this, SpaProxyPort *port, uint32_t buffer_id)
}
}
static SpaResult
spa_proxy_node_port_push_input (SpaNode *node,
unsigned int n_info,
SpaPortInputInfo *info)
{
SpaProxy *this;
unsigned int i;
bool have_error = false;
if (node == NULL || n_info == 0 || info == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
this = SPA_CONTAINER_OF (node, SpaProxy, node);
for (i = 0; i < n_info; i++) {
SpaProxyPort *port;
uint32_t port_id = info[i].port_id;
if (!CHECK_IN_PORT (this, SPA_DIRECTION_INPUT, port_id)) {
spa_log_warn (this->log, "invalid port %d", port_id);
info[i].status = SPA_RESULT_INVALID_PORT;
have_error = true;
continue;
}
port = &this->in_ports[port_id];
if (!port->format) {
info[i].status = SPA_RESULT_NO_FORMAT;
have_error = true;
continue;
}
if (!CHECK_PORT_BUFFER (this, info[i].buffer_id, port)) {
info[i].status = SPA_RESULT_INVALID_BUFFER_ID;
have_error = true;
continue;
}
copy_meta_out (this, port, info[i].buffer_id);
this->trans->input_info[i] = *info;
}
this->trans->area->n_input_info = n_info;
if (have_error)
return SPA_RESULT_ERROR;
pinos_transport_write_cmd (this->trans, PINOS_TRANSPORT_CMD_HAVE_DATA);
return SPA_RESULT_OK;
}
static SpaResult
spa_proxy_node_port_pull_output (SpaNode *node,
unsigned int n_info,
SpaPortOutputInfo *info)
{
SpaProxy *this;
unsigned int i;
bool have_error = false;
if (node == NULL || n_info == 0 || info == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
this = SPA_CONTAINER_OF (node, SpaProxy, node);
for (i = 0; i < n_info; i++) {
SpaProxyPort *port;
uint32_t port_id = info[i].port_id;
if (!CHECK_OUT_PORT (this, SPA_DIRECTION_OUTPUT, port_id)) {
info[i].status = SPA_RESULT_INVALID_PORT;
have_error = true;
continue;
}
port = &this->out_ports[port_id];
info[i] = this->trans->output_info[port_id];
if (!CHECK_PORT_BUFFER (this, info[i].buffer_id, port)) {
info[i].status = SPA_RESULT_INVALID_BUFFER_ID;
have_error = true;
continue;
}
copy_meta_in (this, port, info[i].buffer_id);
if (info[i].status != SPA_RESULT_OK)
have_error = true;
}
if (have_error)
return SPA_RESULT_ERROR;
return SPA_RESULT_OK;
}
static SpaResult
spa_proxy_node_port_reuse_buffer (SpaNode *node,
uint32_t port_id,
@ -948,11 +868,14 @@ spa_proxy_node_port_reuse_buffer (SpaNode *node,
{
SpaProxy *this;
SpaNodeEventReuseBuffer rb;
PinosNode *pnode;
uint8_t cmd;
if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
this = SPA_CONTAINER_OF (node, SpaProxy, node);
pnode = this->pnode;
if (!CHECK_OUT_PORT (this, SPA_DIRECTION_OUTPUT, port_id))
return SPA_RESULT_INVALID_PORT;
@ -961,8 +884,9 @@ spa_proxy_node_port_reuse_buffer (SpaNode *node,
rb.event.size = sizeof (rb);
rb.port_id = port_id;
rb.buffer_id = buffer_id;
pinos_transport_add_event (this->trans, &rb.event);
pinos_transport_write_cmd (this->trans, PINOS_TRANSPORT_CMD_HAVE_EVENT);
pinos_transport_add_event (pnode->transport, &rb.event);
cmd = PINOS_TRANSPORT_CMD_HAVE_EVENT;
write (this->rtfds[0].fd, &cmd, 1);
return SPA_RESULT_OK;
}
@ -1000,6 +924,72 @@ spa_proxy_node_port_send_command (SpaNode *node,
return res;
}
static SpaResult
spa_proxy_node_process_input (SpaNode *node)
{
SpaProxy *this;
unsigned int i;
bool have_error = false;
uint8_t cmd;
if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
this = SPA_CONTAINER_OF (node, SpaProxy, node);
for (i = 0; i < this->n_inputs; i++) {
SpaProxyPort *port = &this->in_ports[i];
SpaPortInput *input;
if ((input = port->io) == NULL)
continue;
if (!CHECK_PORT_BUFFER (this, input->buffer_id, port)) {
input->status = SPA_RESULT_INVALID_BUFFER_ID;
have_error = true;
continue;
}
copy_meta_out (this, port, input->buffer_id);
}
if (have_error)
return SPA_RESULT_ERROR;
cmd = PINOS_TRANSPORT_CMD_HAVE_DATA;
write (this->rtfds[0].fd, &cmd, 1);
return SPA_RESULT_OK;
}
static SpaResult
spa_proxy_node_process_output (SpaNode *node)
{
SpaProxy *this;
unsigned int i;
bool have_error = false;
if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
this = SPA_CONTAINER_OF (node, SpaProxy, node);
for (i = 0; i < this->n_outputs; i++) {
SpaProxyPort *port = &this->out_ports[i];
SpaPortOutput *output;
if ((output = port->io) == NULL)
continue;
copy_meta_in (this, port, output->buffer_id);
if (output->status != SPA_RESULT_OK)
have_error = true;
}
if (have_error)
return SPA_RESULT_ERROR;
return SPA_RESULT_OK;
}
static SpaResult
handle_node_event (SpaProxy *this,
SpaNodeEvent *event)
@ -1047,8 +1037,6 @@ parse_connection (SpaProxy *this)
case PINOS_MESSAGE_NODE_UPDATE:
{
PinosMessageNodeUpdate nu;
PinosTransportInfo info;
PinosMessageTransportUpdate tu;
if (!pinos_connection_parse_message (conn, &nu))
break;
@ -1061,19 +1049,8 @@ parse_connection (SpaProxy *this)
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);
this->trans = pinos_transport_new (this->max_inputs,
this->max_outputs,
this->rtfds[0].fd);
pinos_transport_get_info (this->trans, &info);
tu.memfd_index = pinos_connection_add_fd (conn, info.memfd, false);
tu.offset = info.offset;
tu.size = info.size;
pinos_connection_add_message (conn, PINOS_MESSAGE_TRANSPORT_UPDATE, &tu);
if (!pinos_connection_flush (conn))
spa_log_error (this->log, "proxy %p: error writing connection", this);
#if 0
#endif
break;
}
@ -1157,17 +1134,18 @@ static int
proxy_on_rtfd_events (SpaPollNotifyData *data)
{
SpaProxy *this = data->user_data;
PinosNode *pnode = this->pnode;
if (data->fds[0].revents & POLLIN) {
uint8_t cmd;
pinos_transport_read_cmd (this->trans, &cmd);
read (this->rtfds[0].fd, &cmd, 1);
if (cmd & PINOS_TRANSPORT_CMD_HAVE_EVENT) {
SpaNodeEvent event;
while (pinos_transport_next_event (this->trans, &event) == SPA_RESULT_OK) {
while (pinos_transport_next_event (pnode->transport, &event) == SPA_RESULT_OK) {
SpaNodeEvent *ev = alloca (event.size);
pinos_transport_parse_event (this->trans, ev);
pinos_transport_parse_event (pnode->transport, ev);
this->event_cb (&this->node, ev, this->user_data);
}
}
@ -1209,11 +1187,12 @@ static const SpaNode proxy_node = {
spa_proxy_node_port_set_props,
spa_proxy_node_port_use_buffers,
spa_proxy_node_port_alloc_buffers,
spa_proxy_node_port_get_status,
spa_proxy_node_port_push_input,
spa_proxy_node_port_pull_output,
spa_proxy_node_port_set_input,
spa_proxy_node_port_set_output,
spa_proxy_node_port_reuse_buffer,
spa_proxy_node_port_send_command,
spa_proxy_node_process_input,
spa_proxy_node_process_output,
};
static SpaResult
@ -1268,6 +1247,28 @@ proxy_init (SpaProxy *this,
return SPA_RESULT_RETURN_ASYNC (this->seq++);
}
static void
on_transport_changed (GObject *obj,
GParamSpec *pspec,
PinosClientNode *this)
{
PinosNode *node = PINOS_NODE (obj);
PinosClientNodePrivate *priv = this->priv;
PinosTransportInfo info;
PinosMessageTransportUpdate tu;
PinosConnection *conn = priv->proxy->conn;
pinos_transport_get_info (node->transport, &info);
tu.memfd_index = pinos_connection_add_fd (conn, info.memfd, false);
tu.offset = info.offset;
tu.size = info.size;
pinos_connection_add_message (conn, PINOS_MESSAGE_TRANSPORT_UPDATE, &tu);
if (!pinos_connection_flush (conn))
pinos_log_error ("client-node %p: error writing connection", this);
}
static SpaResult
proxy_clear (SpaProxy *this)
{
@ -1358,6 +1359,7 @@ pinos_client_node_constructed (GObject * object)
G_OBJECT_CLASS (pinos_client_node_parent_class)->constructed (object);
g_signal_connect (object, "notify::transport", (GCallback) on_transport_changed, this);
priv->proxy = (SpaProxy *) PINOS_NODE (this)->node;
}
@ -1408,7 +1410,6 @@ pinos_client_node_new (PinosDaemon *daemon,
p = g_malloc0 (sizeof (SpaProxy));
proxy_init (p, NULL, daemon->support, daemon->n_support);
node = g_object_new (PINOS_TYPE_CLIENT_NODE,
"daemon", daemon,
"client", client,
@ -1417,6 +1418,8 @@ pinos_client_node_new (PinosDaemon *daemon,
"node", p,
NULL);
p->pnode = node;
return node;
}

View file

@ -65,10 +65,6 @@ struct _PinosNodePrivate
uint32_t seq;
gboolean async_init;
unsigned int max_input_ports;
unsigned int max_output_ports;
unsigned int n_input_ports;
unsigned int n_output_ports;
GList *input_ports;
GList *output_ports;
guint n_used_output_links;
@ -101,6 +97,7 @@ enum
PROP_PROPERTIES,
PROP_NODE,
PROP_CLOCK,
PROP_TRANSPORT,
};
enum
@ -215,13 +212,21 @@ update_port_ids (PinosNode *node, gboolean create)
break;
}
priv->max_input_ports = max_input_ports;
priv->max_output_ports = max_output_ports;
priv->n_input_ports = n_input_ports;
priv->n_output_ports = n_output_ports;
node->have_inputs = n_input_ports > 0;
node->have_outputs = n_output_ports > 0;
node->have_inputs = priv->n_input_ports > 0;
node->have_outputs = priv->n_output_ports > 0;
node->transport = pinos_transport_new (max_input_ports,
max_output_ports);
node->transport->area->n_inputs = n_input_ports;
node->transport->area->n_outputs = n_output_ports;
for (i = 0; i < max_input_ports; i++)
spa_node_port_set_input (node->node, i, &node->transport->inputs[i]);
for (i = 0; i < max_output_ports; i++)
spa_node_port_set_output (node->node, i, &node->transport->outputs[i]);
g_object_notify (G_OBJECT (node), "transport");
}
static SpaResult
@ -333,14 +338,12 @@ do_read_link (SpaPoll *poll,
return SPA_RESULT_OK;
while (link->in_ready > 0 && spa_ringbuffer_get_read_offset (&link->ringbuffer, &offset) > 0) {
SpaPortInputInfo iinfo[1];
SpaPortInput *input = &this->transport->inputs[link->input->port];
iinfo[0].port_id = link->input->port;
iinfo[0].buffer_id = link->queue[offset];
iinfo[0].flags = SPA_PORT_INPUT_FLAG_NONE;
input->buffer_id = link->queue[offset];
if ((res = spa_node_port_push_input (link->input->node->node, 1, iinfo)) < 0)
pinos_log_warn ("node %p: error pushing buffer: %d, %d", this, res, iinfo[0].status);
if ((res = spa_node_process_input (link->input->node->node)) < 0)
pinos_log_warn ("node %p: error pushing buffer: %d, %d", this, res, input->status);
spa_ringbuffer_read_advance (&link->ringbuffer, 1);
link->in_ready--;
@ -396,15 +399,13 @@ on_node_event (SpaNode *node, SpaNodeEvent *event, void *user_data)
case SPA_NODE_EVENT_TYPE_HAVE_OUTPUT:
{
SpaNodeEventHaveOutput *ho = (SpaNodeEventHaveOutput *) event;
SpaPortOutputInfo oinfo[1] = { 0, };
SpaResult res;
guint i;
gboolean pushed = FALSE;
SpaPortOutput *po = &this->transport->outputs[ho->port_id];
oinfo[0].port_id = ho->port_id;
if ((res = spa_node_port_pull_output (node, 1, oinfo)) < 0) {
pinos_log_warn ("node %p: got pull error %d, %d", this, res, oinfo[0].status);
if ((res = spa_node_process_output (node)) < 0) {
pinos_log_warn ("node %p: got pull error %d, %d", this, res, po->status);
break;
}
@ -419,7 +420,7 @@ on_node_event (SpaNode *node, SpaNodeEvent *event, void *user_data)
continue;
if (spa_ringbuffer_get_write_offset (&link->ringbuffer, &offset) > 0) {
link->queue[offset] = oinfo[0].buffer_id;
link->queue[offset] = po->buffer_id;
spa_ringbuffer_write_advance (&link->ringbuffer, 1);
spa_poll_invoke (&link->input->node->priv->data_loop->poll,
@ -432,7 +433,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)
if ((res = spa_node_port_reuse_buffer (node, ho->port_id, po->buffer_id)) < 0)
pinos_log_warn ("node %p: error reuse buffer: %d", node, res);
}
break;
@ -519,6 +520,10 @@ pinos_node_get_property (GObject *_object,
g_value_set_pointer (value, this->clock);
break;
case PROP_TRANSPORT:
g_value_set_pointer (value, this->transport);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (this, prop_id, pspec);
break;
@ -813,6 +818,13 @@ pinos_node_class_init (PinosNodeClass * klass)
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT |
G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class,
PROP_TRANSPORT,
g_param_spec_pointer ("transport",
"Transport",
"The Transport",
G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS));
signals[SIGNAL_REMOVE] = g_signal_new ("remove",
G_TYPE_FROM_CLASS (klass),
@ -1038,12 +1050,12 @@ pinos_node_get_free_port (PinosNode *node,
priv = node->priv;
if (direction == PINOS_DIRECTION_INPUT) {
max_ports = priv->max_input_ports;
n_ports = priv->n_input_ports;
max_ports = node->transport->area->max_inputs;
n_ports = node->transport->area->n_inputs;
ports = priv->input_ports;
} else {
max_ports = priv->max_output_ports;
n_ports = priv->n_output_ports;
max_ports = node->transport->area->max_outputs;
n_ports = node->transport->area->n_outputs;
ports = priv->output_ports;
}
free_port = 0;

View file

@ -39,6 +39,7 @@ typedef enum {
#include <pinos/client/introspect.h>
#include <pinos/client/mem.h>
#include <pinos/client/transport.h>
#include <pinos/server/daemon.h>
#include <pinos/server/link.h>
@ -85,6 +86,8 @@ struct _PinosNode {
gboolean have_inputs;
gboolean have_outputs;
PinosTransport *transport;
PinosNodePrivate *priv;
};