SpaConnection -> PinosConnection

This commit is contained in:
Wim Taymans 2016-10-18 18:19:04 +02:00
parent 7ee66cfc35
commit 70fb53cdc6
4 changed files with 458 additions and 474 deletions

View file

@ -38,7 +38,7 @@ typedef struct {
int fds[MAX_FDS]; int fds[MAX_FDS];
unsigned int n_fds; unsigned int n_fds;
SpaControlCmd cmd; PinosControlCmd cmd;
off_t offset; off_t offset;
void *data; void *data;
size_t size; size_t size;
@ -46,15 +46,15 @@ typedef struct {
bool update; bool update;
} ConnectionBuffer; } ConnectionBuffer;
struct _SpaConnection { struct _PinosConnection {
ConnectionBuffer in, out; ConnectionBuffer in, out;
int fd; int fd;
}; };
#if 0 #if 0
#define SPA_DEBUG_CONTROL(format,args...) fprintf(stderr,format,##args) #define PINOS_DEBUG_CONTROL(format,args...) g_debug(format,##args)
#else #else
#define SPA_DEBUG_CONTROL(format,args...) #define PINOS_DEBUG_CONTROL(format,args...)
#endif #endif
static bool static bool
@ -80,20 +80,20 @@ read_length (uint8_t * data, unsigned int size, size_t * length, size_t * skip)
} }
static void static void
connection_parse_node_update (SpaConnection *conn, SpaControlCmdNodeUpdate *nu) connection_parse_node_update (PinosConnection *conn, PinosControlCmdNodeUpdate *nu)
{ {
memcpy (nu, conn->in.data, sizeof (SpaControlCmdNodeUpdate)); memcpy (nu, conn->in.data, sizeof (PinosControlCmdNodeUpdate));
if (nu->props) if (nu->props)
nu->props = spa_serialize_props_deserialize (conn->in.data, SPA_PTR_TO_INT (nu->props)); nu->props = spa_serialize_props_deserialize (conn->in.data, SPA_PTR_TO_INT (nu->props));
} }
static void static void
connection_parse_port_update (SpaConnection *conn, SpaControlCmdPortUpdate *pu) connection_parse_port_update (PinosConnection *conn, PinosControlCmdPortUpdate *pu)
{ {
void *p; void *p;
unsigned int i; unsigned int i;
memcpy (pu, conn->in.data, sizeof (SpaControlCmdPortUpdate)); memcpy (pu, conn->in.data, sizeof (PinosControlCmdPortUpdate));
p = conn->in.data; p = conn->in.data;
@ -115,29 +115,29 @@ connection_parse_port_update (SpaConnection *conn, SpaControlCmdPortUpdate *pu)
} }
static void static void
connection_parse_set_format (SpaConnection *conn, SpaControlCmdSetFormat *cmd) connection_parse_set_format (PinosConnection *conn, PinosControlCmdSetFormat *cmd)
{ {
memcpy (cmd, conn->in.data, sizeof (SpaControlCmdSetFormat)); memcpy (cmd, conn->in.data, sizeof (PinosControlCmdSetFormat));
if (cmd->format) if (cmd->format)
cmd->format = spa_serialize_format_deserialize (conn->in.data, SPA_PTR_TO_INT (cmd->format)); cmd->format = spa_serialize_format_deserialize (conn->in.data, SPA_PTR_TO_INT (cmd->format));
} }
static void static void
connection_parse_use_buffers (SpaConnection *conn, SpaControlCmdUseBuffers *cmd) connection_parse_use_buffers (PinosConnection *conn, PinosControlCmdUseBuffers *cmd)
{ {
void *p; void *p;
p = conn->in.data; p = conn->in.data;
memcpy (cmd, p, sizeof (SpaControlCmdUseBuffers)); memcpy (cmd, p, sizeof (PinosControlCmdUseBuffers));
if (cmd->buffers) if (cmd->buffers)
cmd->buffers = SPA_MEMBER (p, SPA_PTR_TO_INT (cmd->buffers), SpaControlMemRef); cmd->buffers = SPA_MEMBER (p, SPA_PTR_TO_INT (cmd->buffers), PinosControlMemRef);
} }
static void static void
connection_parse_node_event (SpaConnection *conn, SpaControlCmdNodeEvent *cmd) connection_parse_node_event (PinosConnection *conn, PinosControlCmdNodeEvent *cmd)
{ {
void *p = conn->in.data; void *p = conn->in.data;
memcpy (cmd, p, sizeof (SpaControlCmdNodeEvent)); memcpy (cmd, p, sizeof (PinosControlCmdNodeEvent));
if (cmd->event) if (cmd->event)
cmd->event = SPA_MEMBER (p, SPA_PTR_TO_INT (cmd->event), SpaNodeEvent); cmd->event = SPA_MEMBER (p, SPA_PTR_TO_INT (cmd->event), SpaNodeEvent);
if (cmd->event->data) if (cmd->event->data)
@ -145,31 +145,29 @@ connection_parse_node_event (SpaConnection *conn, SpaControlCmdNodeEvent *cmd)
} }
static void static void
connection_parse_node_command (SpaConnection *conn, SpaControlCmdNodeCommand *cmd) connection_parse_node_command (PinosConnection *conn, PinosControlCmdNodeCommand *cmd)
{ {
void *p = conn->in.data; void *p = conn->in.data;
memcpy (cmd, p, sizeof (SpaControlCmdNodeCommand)); memcpy (cmd, p, sizeof (PinosControlCmdNodeCommand));
if (cmd->command) if (cmd->command)
cmd->command = SPA_MEMBER (p, SPA_PTR_TO_INT (cmd->command), SpaNodeCommand); cmd->command = SPA_MEMBER (p, SPA_PTR_TO_INT (cmd->command), SpaNodeCommand);
if (cmd->command->data) if (cmd->command->data)
cmd->command->data = SPA_MEMBER (p, SPA_PTR_TO_INT (cmd->command->data), void); cmd->command->data = SPA_MEMBER (p, SPA_PTR_TO_INT (cmd->command->data), void);
} }
#define MAX(a,b) ((a) > (b) ? (a) : (b))
static void * static void *
connection_ensure_size (SpaConnection *conn, ConnectionBuffer *buf, size_t size) connection_ensure_size (PinosConnection *conn, ConnectionBuffer *buf, size_t size)
{ {
if (buf->buffer_size + size > buf->buffer_maxsize) { if (buf->buffer_size + size > buf->buffer_maxsize) {
buf->buffer_maxsize = buf->buffer_size + MAX_BUFFER_SIZE * ((size + MAX_BUFFER_SIZE-1) / MAX_BUFFER_SIZE); buf->buffer_maxsize = buf->buffer_size + MAX_BUFFER_SIZE * ((size + MAX_BUFFER_SIZE-1) / MAX_BUFFER_SIZE);
buf->buffer_data = realloc (buf->buffer_data, buf->buffer_maxsize); buf->buffer_data = realloc (buf->buffer_data, buf->buffer_maxsize);
fprintf (stderr, "connection %p: resize buffer to %zd\n", conn, buf->buffer_maxsize); g_warning ("connection %p: resize buffer to %zd\n", conn, buf->buffer_maxsize);
} }
return (uint8_t *) buf->buffer_data + buf->buffer_size; return (uint8_t *) buf->buffer_data + buf->buffer_size;
} }
static void * static void *
connection_add_cmd (SpaConnection *conn, SpaControlCmd cmd, size_t size) connection_add_cmd (PinosConnection *conn, PinosControlCmd cmd, size_t size)
{ {
uint8_t *p; uint8_t *p;
unsigned int plen; unsigned int plen;
@ -196,21 +194,21 @@ connection_add_cmd (SpaConnection *conn, SpaControlCmd cmd, size_t size)
} }
static void static void
connection_add_node_update (SpaConnection *conn, SpaControlCmdNodeUpdate *nu) connection_add_node_update (PinosConnection *conn, PinosControlCmdNodeUpdate *nu)
{ {
size_t len; size_t len;
void *p; void *p;
SpaControlCmdNodeUpdate *d; PinosControlCmdNodeUpdate *d;
/* calc len */ /* calc len */
len = sizeof (SpaControlCmdNodeUpdate); len = sizeof (PinosControlCmdNodeUpdate);
len += spa_serialize_props_get_size (nu->props); len += spa_serialize_props_get_size (nu->props);
p = connection_add_cmd (conn, SPA_CONTROL_CMD_NODE_UPDATE, len); p = connection_add_cmd (conn, PINOS_CONTROL_CMD_NODE_UPDATE, len);
memcpy (p, nu, sizeof (SpaControlCmdNodeUpdate)); memcpy (p, nu, sizeof (PinosControlCmdNodeUpdate));
d = p; d = p;
p = SPA_MEMBER (d, sizeof (SpaControlCmdNodeUpdate), void); p = SPA_MEMBER (d, sizeof (PinosControlCmdNodeUpdate), void);
if (nu->props) { if (nu->props) {
len = spa_serialize_props_serialize (p, nu->props); len = spa_serialize_props_serialize (p, nu->props);
d->props = SPA_INT_TO_PTR (SPA_PTRDIFF (p, d)); d->props = SPA_INT_TO_PTR (SPA_PTRDIFF (p, d));
@ -220,16 +218,16 @@ connection_add_node_update (SpaConnection *conn, SpaControlCmdNodeUpdate *nu)
} }
static void static void
connection_add_port_update (SpaConnection *conn, SpaControlCmdPortUpdate *pu) connection_add_port_update (PinosConnection *conn, PinosControlCmdPortUpdate *pu)
{ {
size_t len; size_t len;
void *p; void *p;
int i; int i;
SpaFormat **bfa; SpaFormat **bfa;
SpaControlCmdPortUpdate *d; PinosControlCmdPortUpdate *d;
/* calc len */ /* calc len */
len = sizeof (SpaControlCmdPortUpdate); len = sizeof (PinosControlCmdPortUpdate);
len += pu->n_possible_formats * sizeof (SpaFormat *); len += pu->n_possible_formats * sizeof (SpaFormat *);
for (i = 0; i < pu->n_possible_formats; i++) { for (i = 0; i < pu->n_possible_formats; i++) {
len += spa_serialize_format_get_size (pu->possible_formats[i]); len += spa_serialize_format_get_size (pu->possible_formats[i]);
@ -239,11 +237,11 @@ connection_add_port_update (SpaConnection *conn, SpaControlCmdPortUpdate *pu)
if (pu->info) if (pu->info)
len += spa_serialize_port_info_get_size (pu->info); len += spa_serialize_port_info_get_size (pu->info);
p = connection_add_cmd (conn, SPA_CONTROL_CMD_PORT_UPDATE, len); p = connection_add_cmd (conn, PINOS_CONTROL_CMD_PORT_UPDATE, len);
memcpy (p, pu, sizeof (SpaControlCmdPortUpdate)); memcpy (p, pu, sizeof (PinosControlCmdPortUpdate));
d = p; d = p;
p = SPA_MEMBER (d, sizeof (SpaControlCmdPortUpdate), void); p = SPA_MEMBER (d, sizeof (PinosControlCmdPortUpdate), void);
bfa = p; bfa = p;
if (pu->n_possible_formats) if (pu->n_possible_formats)
d->possible_formats = SPA_INT_TO_PTR (SPA_PTRDIFF (p, d)); d->possible_formats = SPA_INT_TO_PTR (SPA_PTRDIFF (p, d));
@ -281,19 +279,19 @@ connection_add_port_update (SpaConnection *conn, SpaControlCmdPortUpdate *pu)
} }
static void static void
connection_add_set_format (SpaConnection *conn, SpaControlCmdSetFormat *sf) connection_add_set_format (PinosConnection *conn, PinosControlCmdSetFormat *sf)
{ {
size_t len; size_t len;
void *p; void *p;
/* calculate length */ /* calculate length */
/* port_id + format + mask */ /* port_id + format + mask */
len = sizeof (SpaControlCmdSetFormat) + spa_serialize_format_get_size (sf->format); len = sizeof (PinosControlCmdSetFormat) + spa_serialize_format_get_size (sf->format);
p = connection_add_cmd (conn, SPA_CONTROL_CMD_SET_FORMAT, len); p = connection_add_cmd (conn, PINOS_CONTROL_CMD_SET_FORMAT, len);
memcpy (p, sf, sizeof (SpaControlCmdSetFormat)); memcpy (p, sf, sizeof (PinosControlCmdSetFormat));
sf = p; sf = p;
p = SPA_MEMBER (sf, sizeof (SpaControlCmdSetFormat), void); p = SPA_MEMBER (sf, sizeof (PinosControlCmdSetFormat), void);
if (sf->format) { if (sf->format) {
len = spa_serialize_format_serialize (p, sf->format); len = spa_serialize_format_serialize (p, sf->format);
sf->format = SPA_INT_TO_PTR (SPA_PTRDIFF (p, sf)); sf->format = SPA_INT_TO_PTR (SPA_PTRDIFF (p, sf));
@ -302,21 +300,21 @@ connection_add_set_format (SpaConnection *conn, SpaControlCmdSetFormat *sf)
} }
static void static void
connection_add_use_buffers (SpaConnection *conn, SpaControlCmdUseBuffers *ub) connection_add_use_buffers (PinosConnection *conn, PinosControlCmdUseBuffers *ub)
{ {
size_t len; size_t len;
int i; int i;
SpaControlCmdUseBuffers *d; PinosControlCmdUseBuffers *d;
SpaControlMemRef *mr; PinosControlMemRef *mr;
/* calculate length */ /* calculate length */
len = sizeof (SpaControlCmdUseBuffers); len = sizeof (PinosControlCmdUseBuffers);
len += ub->n_buffers * sizeof (SpaControlMemRef); len += ub->n_buffers * sizeof (PinosControlMemRef);
d = connection_add_cmd (conn, SPA_CONTROL_CMD_USE_BUFFERS, len); d = connection_add_cmd (conn, PINOS_CONTROL_CMD_USE_BUFFERS, len);
memcpy (d, ub, sizeof (SpaControlCmdUseBuffers)); memcpy (d, ub, sizeof (PinosControlCmdUseBuffers));
mr = SPA_MEMBER (d, sizeof (SpaControlCmdUseBuffers), void); mr = SPA_MEMBER (d, sizeof (PinosControlCmdUseBuffers), void);
if (d->n_buffers) if (d->n_buffers)
d->buffers = SPA_INT_TO_PTR (SPA_PTRDIFF (mr, d)); d->buffers = SPA_INT_TO_PTR (SPA_PTRDIFF (mr, d));
@ -324,27 +322,27 @@ connection_add_use_buffers (SpaConnection *conn, SpaControlCmdUseBuffers *ub)
d->buffers = 0; d->buffers = 0;
for (i = 0; i < ub->n_buffers; i++) for (i = 0; i < ub->n_buffers; i++)
memcpy (&mr[i], &ub->buffers[i], sizeof (SpaControlMemRef)); memcpy (&mr[i], &ub->buffers[i], sizeof (PinosControlMemRef));
} }
static void static void
connection_add_node_event (SpaConnection *conn, SpaControlCmdNodeEvent *ev) connection_add_node_event (PinosConnection *conn, PinosControlCmdNodeEvent *ev)
{ {
size_t len; size_t len;
void *p; void *p;
SpaControlCmdNodeEvent *d; PinosControlCmdNodeEvent *d;
SpaNodeEvent *ne; SpaNodeEvent *ne;
/* calculate length */ /* calculate length */
len = sizeof (SpaControlCmdNodeEvent); len = sizeof (PinosControlCmdNodeEvent);
len += sizeof (SpaNodeEvent); len += sizeof (SpaNodeEvent);
len += ev->event->size; len += ev->event->size;
p = connection_add_cmd (conn, SPA_CONTROL_CMD_NODE_EVENT, len); p = connection_add_cmd (conn, PINOS_CONTROL_CMD_NODE_EVENT, len);
memcpy (p, ev, sizeof (SpaControlCmdNodeEvent)); memcpy (p, ev, sizeof (PinosControlCmdNodeEvent));
d = p; d = p;
p = SPA_MEMBER (d, sizeof (SpaControlCmdNodeEvent), void); p = SPA_MEMBER (d, sizeof (PinosControlCmdNodeEvent), void);
d->event = SPA_INT_TO_PTR (SPA_PTRDIFF (p, d)); d->event = SPA_INT_TO_PTR (SPA_PTRDIFF (p, d));
ne = p; ne = p;
@ -356,23 +354,23 @@ connection_add_node_event (SpaConnection *conn, SpaControlCmdNodeEvent *ev)
static void static void
connection_add_node_command (SpaConnection *conn, SpaControlCmdNodeCommand *cm) connection_add_node_command (PinosConnection *conn, PinosControlCmdNodeCommand *cm)
{ {
size_t len; size_t len;
void *p; void *p;
SpaControlCmdNodeCommand *d; PinosControlCmdNodeCommand *d;
SpaNodeCommand *nc; SpaNodeCommand *nc;
/* calculate length */ /* calculate length */
len = sizeof (SpaControlCmdNodeCommand); len = sizeof (PinosControlCmdNodeCommand);
len += sizeof (SpaNodeCommand); len += sizeof (SpaNodeCommand);
len += cm->command->size; len += cm->command->size;
p = connection_add_cmd (conn, SPA_CONTROL_CMD_NODE_COMMAND, len); p = connection_add_cmd (conn, PINOS_CONTROL_CMD_NODE_COMMAND, len);
memcpy (p, cm, sizeof (SpaControlCmdNodeCommand)); memcpy (p, cm, sizeof (PinosControlCmdNodeCommand));
d = p; d = p;
p = SPA_MEMBER (d, sizeof (SpaControlCmdNodeCommand), void); p = SPA_MEMBER (d, sizeof (PinosControlCmdNodeCommand), void);
d->command = SPA_INT_TO_PTR (SPA_PTRDIFF (p, d)); d->command = SPA_INT_TO_PTR (SPA_PTRDIFF (p, d));
nc = p; nc = p;
@ -382,8 +380,8 @@ connection_add_node_command (SpaConnection *conn, SpaControlCmdNodeCommand *cm)
memcpy (p, cm->command->data, cm->command->size); memcpy (p, cm->command->data, cm->command->size);
} }
static SpaResult static gboolean
refill_buffer (SpaConnection *conn, ConnectionBuffer *buf) refill_buffer (PinosConnection *conn, ConnectionBuffer *buf)
{ {
ssize_t len; ssize_t len;
struct cmsghdr *cmsg; struct cmsghdr *cmsg;
@ -411,7 +409,7 @@ refill_buffer (SpaConnection *conn, ConnectionBuffer *buf)
} }
if (len < 4) if (len < 4)
return SPA_RESULT_ERROR; return FALSE;
buf->buffer_size += len; buf->buffer_size += len;
@ -423,15 +421,15 @@ refill_buffer (SpaConnection *conn, ConnectionBuffer *buf)
buf->n_fds = (cmsg->cmsg_len - ((char *)CMSG_DATA (cmsg) - (char *)cmsg)) / sizeof (int); buf->n_fds = (cmsg->cmsg_len - ((char *)CMSG_DATA (cmsg) - (char *)cmsg)) / sizeof (int);
memcpy (buf->fds, CMSG_DATA (cmsg), buf->n_fds * sizeof (int)); memcpy (buf->fds, CMSG_DATA (cmsg), buf->n_fds * sizeof (int));
} }
SPA_DEBUG_CONTROL ("connection %p: %d read %zd bytes and %d fds\n", conn, conn->fd, len, buf->n_fds); PINOS_DEBUG_CONTROL ("connection %p: %d read %zd bytes and %d fds\n", conn, conn->fd, len, buf->n_fds);
return SPA_RESULT_OK; return TRUE;
/* ERRORS */ /* ERRORS */
recv_error: recv_error:
{ {
fprintf (stderr, "could not recvmsg on fd %d: %s\n", conn->fd, strerror (errno)); g_warning ("could not recvmsg on fd %d: %s\n", conn->fd, strerror (errno));
return SPA_RESULT_ERROR; return FALSE;
} }
} }
@ -447,18 +445,18 @@ clear_buffer (ConnectionBuffer *buf)
} }
} }
buf->n_fds = 0; buf->n_fds = 0;
buf->cmd = SPA_CONTROL_CMD_INVALID; buf->cmd = PINOS_CONTROL_CMD_INVALID;
buf->offset = 0; buf->offset = 0;
buf->size = 0; buf->size = 0;
buf->buffer_size = 0; buf->buffer_size = 0;
} }
SpaConnection * PinosConnection *
spa_connection_new (int fd) pinos_connection_new (int fd)
{ {
SpaConnection *c; PinosConnection *c;
c = calloc (1, sizeof (SpaConnection)); c = calloc (1, sizeof (PinosConnection));
c->fd = fd; c->fd = fd;
c->out.buffer_data = malloc (MAX_BUFFER_SIZE); c->out.buffer_data = malloc (MAX_BUFFER_SIZE);
c->out.buffer_maxsize = MAX_BUFFER_SIZE; c->out.buffer_maxsize = MAX_BUFFER_SIZE;
@ -470,7 +468,7 @@ spa_connection_new (int fd)
} }
void void
spa_connection_free (SpaConnection *conn) pinos_connection_free (PinosConnection *conn)
{ {
free (conn->out.buffer_data); free (conn->out.buffer_data);
free (conn->in.buffer_data); free (conn->in.buffer_data);
@ -478,22 +476,21 @@ spa_connection_free (SpaConnection *conn)
} }
/** /**
* spa_connection_has_next: * pinos_connection_has_next:
* @iter: a #SpaConnection * @iter: a #PinosConnection
* *
* Move to the next packet in @conn. * Move to the next packet in @conn.
* *
* Returns: %SPA_RESULT_OK if more packets are available. * Returns: %TRUE if more packets are available.
*/ */
SpaResult gboolean
spa_connection_has_next (SpaConnection *conn) pinos_connection_has_next (PinosConnection *conn)
{ {
size_t len, size, skip; size_t len, size, skip;
uint8_t *data; uint8_t *data;
ConnectionBuffer *buf; ConnectionBuffer *buf;
if (conn == NULL) g_return_val_if_fail (conn != NULL, FALSE);
return SPA_RESULT_INVALID_ARGUMENTS;
buf = &conn->in; buf = &conn->in;
@ -513,7 +510,7 @@ again:
if (buf->offset >= size) { if (buf->offset >= size) {
clear_buffer (buf); clear_buffer (buf);
buf->update = true; buf->update = true;
return SPA_RESULT_ERROR; return FALSE;
} }
data += buf->offset; data += buf->offset;
@ -532,108 +529,104 @@ again:
buf->data = data + skip; buf->data = data + skip;
buf->offset += 1 + skip; buf->offset += 1 + skip;
return SPA_RESULT_OK; return TRUE;
} }
SpaControlCmd PinosControlCmd
spa_connection_get_cmd (SpaConnection *conn) pinos_connection_get_cmd (PinosConnection *conn)
{ {
if (conn == NULL) g_return_val_if_fail (conn != NULL, PINOS_CONTROL_CMD_INVALID);
return SPA_CONTROL_CMD_INVALID;
return conn->in.cmd; return conn->in.cmd;
} }
SpaResult gboolean
spa_connection_parse_cmd (SpaConnection *conn, pinos_connection_parse_cmd (PinosConnection *conn,
void *command) gpointer command)
{ {
SpaResult res = SPA_RESULT_OK; g_return_val_if_fail (conn != NULL, FALSE);
if (conn == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
switch (conn->in.cmd) { switch (conn->in.cmd) {
/* C -> S */ /* C -> S */
case SPA_CONTROL_CMD_NODE_UPDATE: case PINOS_CONTROL_CMD_NODE_UPDATE:
connection_parse_node_update (conn, command); connection_parse_node_update (conn, command);
break; break;
case SPA_CONTROL_CMD_PORT_UPDATE: case PINOS_CONTROL_CMD_PORT_UPDATE:
connection_parse_port_update (conn, command); connection_parse_port_update (conn, command);
break; break;
case SPA_CONTROL_CMD_PORT_STATUS_CHANGE: case PINOS_CONTROL_CMD_PORT_STATUS_CHANGE:
fprintf (stderr, "implement iter of %d\n", conn->in.cmd); g_warning ("implement iter of %d\n", conn->in.cmd);
break; break;
case SPA_CONTROL_CMD_NODE_STATE_CHANGE: case PINOS_CONTROL_CMD_NODE_STATE_CHANGE:
if (conn->in.size < sizeof (SpaControlCmdNodeStateChange)) if (conn->in.size < sizeof (PinosControlCmdNodeStateChange))
return SPA_RESULT_ERROR; return FALSE;
memcpy (command, conn->in.data, sizeof (SpaControlCmdNodeStateChange)); memcpy (command, conn->in.data, sizeof (PinosControlCmdNodeStateChange));
break; break;
/* S -> C */ /* S -> C */
case SPA_CONTROL_CMD_ADD_PORT: case PINOS_CONTROL_CMD_ADD_PORT:
if (conn->in.size < sizeof (SpaControlCmdAddPort)) if (conn->in.size < sizeof (PinosControlCmdAddPort))
return SPA_RESULT_ERROR; return FALSE;
memcpy (command, conn->in.data, sizeof (SpaControlCmdAddPort)); memcpy (command, conn->in.data, sizeof (PinosControlCmdAddPort));
break; break;
case SPA_CONTROL_CMD_REMOVE_PORT: case PINOS_CONTROL_CMD_REMOVE_PORT:
if (conn->in.size < sizeof (SpaControlCmdRemovePort)) if (conn->in.size < sizeof (PinosControlCmdRemovePort))
return SPA_RESULT_ERROR; return FALSE;
memcpy (command, conn->in.data, sizeof (SpaControlCmdRemovePort)); memcpy (command, conn->in.data, sizeof (PinosControlCmdRemovePort));
break; break;
case SPA_CONTROL_CMD_SET_FORMAT: case PINOS_CONTROL_CMD_SET_FORMAT:
connection_parse_set_format (conn, command); connection_parse_set_format (conn, command);
break; break;
case SPA_CONTROL_CMD_SET_PROPERTY: case PINOS_CONTROL_CMD_SET_PROPERTY:
fprintf (stderr, "implement iter of %d\n", conn->in.cmd); g_warning ("implement iter of %d\n", conn->in.cmd);
break; break;
/* bidirectional */ /* bidirectional */
case SPA_CONTROL_CMD_ADD_MEM: case PINOS_CONTROL_CMD_ADD_MEM:
if (conn->in.size < sizeof (SpaControlCmdAddMem)) if (conn->in.size < sizeof (PinosControlCmdAddMem))
return SPA_RESULT_ERROR; return FALSE;
memcpy (command, conn->in.data, sizeof (SpaControlCmdAddMem)); memcpy (command, conn->in.data, sizeof (PinosControlCmdAddMem));
break; break;
case SPA_CONTROL_CMD_REMOVE_MEM: case PINOS_CONTROL_CMD_REMOVE_MEM:
if (conn->in.size < sizeof (SpaControlCmdRemoveMem)) if (conn->in.size < sizeof (PinosControlCmdRemoveMem))
return SPA_RESULT_ERROR; return FALSE;
memcpy (command, conn->in.data, sizeof (SpaControlCmdRemoveMem)); memcpy (command, conn->in.data, sizeof (PinosControlCmdRemoveMem));
break; break;
case SPA_CONTROL_CMD_USE_BUFFERS: case PINOS_CONTROL_CMD_USE_BUFFERS:
connection_parse_use_buffers (conn, command); connection_parse_use_buffers (conn, command);
break; break;
case SPA_CONTROL_CMD_PROCESS_BUFFER: case PINOS_CONTROL_CMD_PROCESS_BUFFER:
if (conn->in.size < sizeof (SpaControlCmdProcessBuffer)) if (conn->in.size < sizeof (PinosControlCmdProcessBuffer))
return SPA_RESULT_ERROR; return FALSE;
memcpy (command, conn->in.data, sizeof (SpaControlCmdProcessBuffer)); memcpy (command, conn->in.data, sizeof (PinosControlCmdProcessBuffer));
break; break;
case SPA_CONTROL_CMD_NODE_EVENT: case PINOS_CONTROL_CMD_NODE_EVENT:
connection_parse_node_event (conn, command); connection_parse_node_event (conn, command);
break; break;
case SPA_CONTROL_CMD_NODE_COMMAND: case PINOS_CONTROL_CMD_NODE_COMMAND:
connection_parse_node_command (conn, command); connection_parse_node_command (conn, command);
break; break;
case SPA_CONTROL_CMD_INVALID: case PINOS_CONTROL_CMD_INVALID:
return SPA_RESULT_ERROR; return FALSE;
} }
return res; return TRUE;
} }
/** /**
* spa_connection_get_fd: * pinos_connection_get_fd:
* @conn: a #SpaConnection * @conn: a #PinosConnection
* @index: an index * @index: an index
* @steal: steal the fd * @steal: steal the fd
* *
@ -643,14 +636,14 @@ spa_connection_parse_cmd (SpaConnection *conn,
* is not duplicated in any way. -1 is returned on error. * is not duplicated in any way. -1 is returned on error.
*/ */
int int
spa_connection_get_fd (SpaConnection *conn, pinos_connection_get_fd (PinosConnection *conn,
unsigned int index, guint index,
bool close) gboolean close)
{ {
int fd; int fd;
if (conn == NULL || conn->in.n_fds < index) g_return_val_if_fail (conn != NULL, -1);
return -1; g_return_val_if_fail (index < conn->in.n_fds, -1);
fd = conn->in.fds[index]; fd = conn->in.fds[index];
if (fd < 0) if (fd < 0)
@ -661,8 +654,8 @@ spa_connection_get_fd (SpaConnection *conn,
} }
/** /**
* spa_connection_add_fd: * pinos_connection_add_fd:
* @conn: a #SpaConnection * @conn: a #PinosConnection
* @fd: a valid fd * @fd: a valid fd
* @close: if the descriptor should be closed when sent * @close: if the descriptor should be closed when sent
* *
@ -671,14 +664,13 @@ spa_connection_get_fd (SpaConnection *conn,
* Returns: the index of the file descriptor in @builder. * Returns: the index of the file descriptor in @builder.
*/ */
int int
spa_connection_add_fd (SpaConnection *conn, pinos_connection_add_fd (PinosConnection *conn,
int fd, int fd,
bool close) gboolean close)
{ {
int index, i; int index, i;
if (conn == NULL) g_return_val_if_fail (conn != NULL, -1);
return -1;
for (i = 0; i < conn->out.n_fds; i++) { for (i = 0; i < conn->out.n_fds; i++) {
if (conn->out.fds[i] == fd || conn->out.fds[i] == -fd) if (conn->out.fds[i] == fd || conn->out.fds[i] == -fd)
@ -693,99 +685,99 @@ spa_connection_add_fd (SpaConnection *conn,
} }
/** /**
* spa_connection_add_cmd: * pinos_connection_add_cmd:
* @conn: a #SpaConnection * @conn: a #PinosConnection
* @cmd: a #SpaControlCmd * @cmd: a #PinosControlCmd
* @command: a command * @command: a command
* *
* Add a @cmd to @conn with data from @command. * Add a @cmd to @conn with data from @command.
* *
* Returns: %SPA_RESULT_OK on success. * Returns: %TRUE on success.
*/ */
SpaResult gboolean
spa_connection_add_cmd (SpaConnection *conn, pinos_connection_add_cmd (PinosConnection *conn,
SpaControlCmd cmd, PinosControlCmd cmd,
void *command) gpointer command)
{ {
void *p; void *p;
if (conn == NULL || command == NULL) g_return_val_if_fail (conn != NULL, FALSE);
return SPA_RESULT_INVALID_ARGUMENTS; g_return_val_if_fail (command != NULL, FALSE);
switch (cmd) { switch (cmd) {
/* C -> S */ /* C -> S */
case SPA_CONTROL_CMD_NODE_UPDATE: case PINOS_CONTROL_CMD_NODE_UPDATE:
connection_add_node_update (conn, command); connection_add_node_update (conn, command);
break; break;
case SPA_CONTROL_CMD_PORT_UPDATE: case PINOS_CONTROL_CMD_PORT_UPDATE:
connection_add_port_update (conn, command); connection_add_port_update (conn, command);
break; break;
case SPA_CONTROL_CMD_PORT_STATUS_CHANGE: case PINOS_CONTROL_CMD_PORT_STATUS_CHANGE:
p = connection_add_cmd (conn, cmd, 0); p = connection_add_cmd (conn, cmd, 0);
break; break;
case SPA_CONTROL_CMD_NODE_STATE_CHANGE: case PINOS_CONTROL_CMD_NODE_STATE_CHANGE:
p = connection_add_cmd (conn, cmd, sizeof (SpaControlCmdNodeStateChange)); p = connection_add_cmd (conn, cmd, sizeof (PinosControlCmdNodeStateChange));
memcpy (p, command, sizeof (SpaControlCmdNodeStateChange)); memcpy (p, command, sizeof (PinosControlCmdNodeStateChange));
break; break;
/* S -> C */ /* S -> C */
case SPA_CONTROL_CMD_ADD_PORT: case PINOS_CONTROL_CMD_ADD_PORT:
p = connection_add_cmd (conn, cmd, sizeof (SpaControlCmdAddPort)); p = connection_add_cmd (conn, cmd, sizeof (PinosControlCmdAddPort));
memcpy (p, command, sizeof (SpaControlCmdAddPort)); memcpy (p, command, sizeof (PinosControlCmdAddPort));
break; break;
case SPA_CONTROL_CMD_REMOVE_PORT: case PINOS_CONTROL_CMD_REMOVE_PORT:
p = connection_add_cmd (conn, cmd, sizeof (SpaControlCmdRemovePort)); p = connection_add_cmd (conn, cmd, sizeof (PinosControlCmdRemovePort));
memcpy (p, command, sizeof (SpaControlCmdRemovePort)); memcpy (p, command, sizeof (PinosControlCmdRemovePort));
break; break;
case SPA_CONTROL_CMD_SET_FORMAT: case PINOS_CONTROL_CMD_SET_FORMAT:
connection_add_set_format (conn, command); connection_add_set_format (conn, command);
break; break;
case SPA_CONTROL_CMD_SET_PROPERTY: case PINOS_CONTROL_CMD_SET_PROPERTY:
fprintf (stderr, "implement builder of %d\n", cmd); g_warning ("implement builder of %d\n", cmd);
break; break;
/* bidirectional */ /* bidirectional */
case SPA_CONTROL_CMD_ADD_MEM: case PINOS_CONTROL_CMD_ADD_MEM:
p = connection_add_cmd (conn, cmd, sizeof (SpaControlCmdAddMem)); p = connection_add_cmd (conn, cmd, sizeof (PinosControlCmdAddMem));
memcpy (p, command, sizeof (SpaControlCmdAddMem)); memcpy (p, command, sizeof (PinosControlCmdAddMem));
break; break;
case SPA_CONTROL_CMD_REMOVE_MEM: case PINOS_CONTROL_CMD_REMOVE_MEM:
p = connection_add_cmd (conn, cmd, sizeof (SpaControlCmdRemoveMem)); p = connection_add_cmd (conn, cmd, sizeof (PinosControlCmdRemoveMem));
memcpy (p, command, sizeof (SpaControlCmdRemoveMem)); memcpy (p, command, sizeof (PinosControlCmdRemoveMem));
break; break;
case SPA_CONTROL_CMD_USE_BUFFERS: case PINOS_CONTROL_CMD_USE_BUFFERS:
connection_add_use_buffers (conn, command); connection_add_use_buffers (conn, command);
break; break;
case SPA_CONTROL_CMD_PROCESS_BUFFER: case PINOS_CONTROL_CMD_PROCESS_BUFFER:
p = connection_add_cmd (conn, cmd, sizeof (SpaControlCmdProcessBuffer)); p = connection_add_cmd (conn, cmd, sizeof (PinosControlCmdProcessBuffer));
memcpy (p, command, sizeof (SpaControlCmdProcessBuffer)); memcpy (p, command, sizeof (PinosControlCmdProcessBuffer));
break; break;
case SPA_CONTROL_CMD_NODE_EVENT: case PINOS_CONTROL_CMD_NODE_EVENT:
connection_add_node_event (conn, command); connection_add_node_event (conn, command);
break; break;
case SPA_CONTROL_CMD_NODE_COMMAND: case PINOS_CONTROL_CMD_NODE_COMMAND:
connection_add_node_command (conn, command); connection_add_node_command (conn, command);
break; break;
case SPA_CONTROL_CMD_INVALID: case PINOS_CONTROL_CMD_INVALID:
return SPA_RESULT_INVALID_ARGUMENTS; return FALSE;
} }
return SPA_RESULT_OK; return TRUE;
} }
SpaResult gboolean
spa_connection_flush (SpaConnection *conn) pinos_connection_flush (PinosConnection *conn)
{ {
ssize_t len; ssize_t len;
struct msghdr msg = {0}; struct msghdr msg = {0};
@ -795,13 +787,12 @@ spa_connection_flush (SpaConnection *conn)
int *cm, i, fds_len; int *cm, i, fds_len;
ConnectionBuffer *buf; ConnectionBuffer *buf;
if (conn == NULL) g_return_val_if_fail (conn != NULL, FALSE);
return SPA_RESULT_INVALID_ARGUMENTS;
buf = &conn->out; buf = &conn->out;
if (buf->buffer_size == 0) if (buf->buffer_size == 0)
return SPA_RESULT_OK; return TRUE;
fds_len = buf->n_fds * sizeof (int); fds_len = buf->n_fds * sizeof (int);
@ -839,27 +830,26 @@ spa_connection_flush (SpaConnection *conn)
buf->buffer_size -= len; buf->buffer_size -= len;
buf->n_fds = 0; buf->n_fds = 0;
SPA_DEBUG_CONTROL ("connection %p: %d written %zd bytes and %u fds\n", conn, conn->fd, len, buf->n_fds); PINOS_DEBUG_CONTROL ("connection %p: %d written %zd bytes and %u fds\n", conn, conn->fd, len, buf->n_fds);
return SPA_RESULT_OK; return TRUE;
/* ERRORS */ /* ERRORS */
send_error: send_error:
{ {
fprintf (stderr, "could not sendmsg: %s\n", strerror (errno)); g_warning ("could not sendmsg: %s\n", strerror (errno));
return SPA_RESULT_ERROR; return FALSE;
} }
} }
SpaResult gboolean
spa_connection_clear (SpaConnection *conn) pinos_connection_clear (PinosConnection *conn)
{ {
if (conn == NULL) g_return_val_if_fail (conn != NULL, FALSE);
return SPA_RESULT_INVALID_ARGUMENTS;
clear_buffer (&conn->out); clear_buffer (&conn->out);
clear_buffer (&conn->in); clear_buffer (&conn->in);
conn->in.update = true; conn->in.update = true;
return SPA_RESULT_OK; return TRUE;
} }

View file

@ -17,12 +17,12 @@
* Boston, MA 02110-1301, USA. * Boston, MA 02110-1301, USA.
*/ */
#ifndef __SPA_CONTROL_H__ #ifndef __PINOS_CONTROL_H__
#define __SPA_CONTROL_H__ #define __PINOS_CONTROL_H__
#ifdef __cplusplus #include <glib-object.h>
extern "C" {
#endif G_BEGIN_DECLS
#include <spa/defs.h> #include <spa/defs.h>
#include <spa/props.h> #include <spa/props.h>
@ -30,95 +30,95 @@ extern "C" {
#include <spa/port.h> #include <spa/port.h>
#include <spa/node.h> #include <spa/node.h>
typedef struct _SpaConnection SpaConnection; typedef struct _PinosConnection PinosConnection;
typedef enum { typedef enum {
SPA_CONTROL_CMD_INVALID = 0, PINOS_CONTROL_CMD_INVALID = 0,
/* client to server */ /* client to server */
SPA_CONTROL_CMD_NODE_UPDATE = 1, PINOS_CONTROL_CMD_NODE_UPDATE = 1,
SPA_CONTROL_CMD_PORT_UPDATE = 2, PINOS_CONTROL_CMD_PORT_UPDATE = 2,
SPA_CONTROL_CMD_NODE_STATE_CHANGE = 3, PINOS_CONTROL_CMD_NODE_STATE_CHANGE = 3,
SPA_CONTROL_CMD_PORT_STATUS_CHANGE = 4, PINOS_CONTROL_CMD_PORT_STATUS_CHANGE = 4,
/* server to client */ /* server to client */
SPA_CONTROL_CMD_ADD_PORT = 32, PINOS_CONTROL_CMD_ADD_PORT = 32,
SPA_CONTROL_CMD_REMOVE_PORT = 33, PINOS_CONTROL_CMD_REMOVE_PORT = 33,
SPA_CONTROL_CMD_SET_FORMAT = 34, PINOS_CONTROL_CMD_SET_FORMAT = 34,
SPA_CONTROL_CMD_SET_PROPERTY = 35, PINOS_CONTROL_CMD_SET_PROPERTY = 35,
SPA_CONTROL_CMD_NODE_COMMAND = 36, PINOS_CONTROL_CMD_NODE_COMMAND = 36,
/* both */ /* both */
SPA_CONTROL_CMD_ADD_MEM = 64, PINOS_CONTROL_CMD_ADD_MEM = 64,
SPA_CONTROL_CMD_REMOVE_MEM = 65, PINOS_CONTROL_CMD_REMOVE_MEM = 65,
SPA_CONTROL_CMD_USE_BUFFERS = 66, PINOS_CONTROL_CMD_USE_BUFFERS = 66,
SPA_CONTROL_CMD_PROCESS_BUFFER = 67, PINOS_CONTROL_CMD_PROCESS_BUFFER = 67,
SPA_CONTROL_CMD_NODE_EVENT = 68, PINOS_CONTROL_CMD_NODE_EVENT = 68,
} SpaControlCmd; } PinosControlCmd;
/* SPA_CONTROL_CMD_NODE_UPDATE */ /* PINOS_CONTROL_CMD_NODE_UPDATE */
typedef struct { typedef struct {
#define SPA_CONTROL_CMD_NODE_UPDATE_MAX_INPUTS (1 << 0) #define PINOS_CONTROL_CMD_NODE_UPDATE_MAX_INPUTS (1 << 0)
#define SPA_CONTROL_CMD_NODE_UPDATE_MAX_OUTPUTS (1 << 1) #define PINOS_CONTROL_CMD_NODE_UPDATE_MAX_OUTPUTS (1 << 1)
#define SPA_CONTROL_CMD_NODE_UPDATE_PROPS (1 << 2) #define PINOS_CONTROL_CMD_NODE_UPDATE_PROPS (1 << 2)
uint32_t change_mask; uint32_t change_mask;
unsigned int max_input_ports; unsigned int max_input_ports;
unsigned int max_output_ports; unsigned int max_output_ports;
const SpaProps *props; const SpaProps *props;
} SpaControlCmdNodeUpdate; } PinosControlCmdNodeUpdate;
/* SPA_CONTROL_CMD_PORT_UPDATE */ /* PINOS_CONTROL_CMD_PORT_UPDATE */
typedef struct { typedef struct {
SpaDirection direction; SpaDirection direction;
uint32_t port_id; uint32_t port_id;
#define SPA_CONTROL_CMD_PORT_UPDATE_POSSIBLE_FORMATS (1 << 0) #define PINOS_CONTROL_CMD_PORT_UPDATE_POSSIBLE_FORMATS (1 << 0)
#define SPA_CONTROL_CMD_PORT_UPDATE_FORMAT (1 << 1) #define PINOS_CONTROL_CMD_PORT_UPDATE_FORMAT (1 << 1)
#define SPA_CONTROL_CMD_PORT_UPDATE_PROPS (1 << 2) #define PINOS_CONTROL_CMD_PORT_UPDATE_PROPS (1 << 2)
#define SPA_CONTROL_CMD_PORT_UPDATE_INFO (1 << 3) #define PINOS_CONTROL_CMD_PORT_UPDATE_INFO (1 << 3)
uint32_t change_mask; uint32_t change_mask;
unsigned int n_possible_formats; unsigned int n_possible_formats;
SpaFormat **possible_formats; SpaFormat **possible_formats;
SpaFormat *format; SpaFormat *format;
const SpaProps *props; const SpaProps *props;
const SpaPortInfo *info; const SpaPortInfo *info;
} SpaControlCmdPortUpdate; } PinosControlCmdPortUpdate;
/* SPA_CONTROL_CMD_PORT_STATUS_CHANGE */ /* PINOS_CONTROL_CMD_PORT_STATUS_CHANGE */
/* SPA_CONTROL_CMD_NODE_STATE_CHANGE */ /* PINOS_CONTROL_CMD_NODE_STATE_CHANGE */
typedef struct { typedef struct {
SpaNodeState state; SpaNodeState state;
} SpaControlCmdNodeStateChange; } PinosControlCmdNodeStateChange;
/* SPA_CONTROL_CMD_ADD_PORT */ /* PINOS_CONTROL_CMD_ADD_PORT */
typedef struct { typedef struct {
uint32_t seq; uint32_t seq;
SpaDirection direction; SpaDirection direction;
uint32_t port_id; uint32_t port_id;
} SpaControlCmdAddPort; } PinosControlCmdAddPort;
/* SPA_CONTROL_CMD_REMOVE_PORT */ /* PINOS_CONTROL_CMD_REMOVE_PORT */
typedef struct { typedef struct {
uint32_t seq; uint32_t seq;
SpaDirection direction; SpaDirection direction;
uint32_t port_id; uint32_t port_id;
} SpaControlCmdRemovePort; } PinosControlCmdRemovePort;
/* SPA_CONTROL_CMD_SET_FORMAT */ /* PINOS_CONTROL_CMD_SET_FORMAT */
typedef struct { typedef struct {
uint32_t seq; uint32_t seq;
SpaDirection direction; SpaDirection direction;
uint32_t port_id; uint32_t port_id;
SpaPortFormatFlags flags; SpaPortFormatFlags flags;
SpaFormat *format; SpaFormat *format;
} SpaControlCmdSetFormat; } PinosControlCmdSetFormat;
/* SPA_CONTROL_CMD_SET_PROPERTY */ /* PINOS_CONTROL_CMD_SET_PROPERTY */
typedef struct { typedef struct {
uint32_t seq; uint32_t seq;
SpaDirection direction; SpaDirection direction;
@ -126,15 +126,15 @@ typedef struct {
uint32_t id; uint32_t id;
size_t size; size_t size;
void *value; void *value;
} SpaControlCmdSetProperty; } PinosControlCmdSetProperty;
/* SPA_CONTROL_CMD_NODE_COMMAND */ /* PINOS_CONTROL_CMD_NODE_COMMAND */
typedef struct { typedef struct {
uint32_t seq; uint32_t seq;
SpaNodeCommand *command; SpaNodeCommand *command;
} SpaControlCmdNodeCommand; } PinosControlCmdNodeCommand;
/* SPA_CONTROL_CMD_ADD_MEM */ /* PINOS_CONTROL_CMD_ADD_MEM */
typedef struct { typedef struct {
SpaDirection direction; SpaDirection direction;
uint32_t port_id; uint32_t port_id;
@ -144,66 +144,64 @@ typedef struct {
uint32_t flags; uint32_t flags;
off_t offset; off_t offset;
size_t size; size_t size;
} SpaControlCmdAddMem; } PinosControlCmdAddMem;
/* SPA_CONTROL_CMD_REMOVE_MEM */ /* PINOS_CONTROL_CMD_REMOVE_MEM */
typedef struct { typedef struct {
SpaDirection direction; SpaDirection direction;
uint32_t port_id; uint32_t port_id;
uint32_t mem_id; uint32_t mem_id;
} SpaControlCmdRemoveMem; } PinosControlCmdRemoveMem;
typedef struct { typedef struct {
uint32_t mem_id; uint32_t mem_id;
off_t offset; off_t offset;
size_t size; size_t size;
} SpaControlMemRef; } PinosControlMemRef;
/* SPA_CONTROL_CMD_USE_BUFFERS */ /* PINOS_CONTROL_CMD_USE_BUFFERS */
typedef struct { typedef struct {
uint32_t seq; uint32_t seq;
SpaDirection direction; SpaDirection direction;
uint32_t port_id; uint32_t port_id;
unsigned int n_buffers; unsigned int n_buffers;
SpaControlMemRef *buffers; PinosControlMemRef *buffers;
} SpaControlCmdUseBuffers; } PinosControlCmdUseBuffers;
/* SPA_CONTROL_CMD_PROCESS_BUFFER */ /* PINOS_CONTROL_CMD_PROCESS_BUFFER */
typedef struct { typedef struct {
SpaDirection direction; SpaDirection direction;
uint32_t port_id; uint32_t port_id;
uint32_t buffer_id; uint32_t buffer_id;
} SpaControlCmdProcessBuffer; } PinosControlCmdProcessBuffer;
/* SPA_CONTROL_CMD_NODE_EVENT */ /* PINOS_CONTROL_CMD_NODE_EVENT */
typedef struct { typedef struct {
SpaNodeEvent *event; SpaNodeEvent *event;
} SpaControlCmdNodeEvent; } PinosControlCmdNodeEvent;
SpaConnection * spa_connection_new (int fd); PinosConnection * pinos_connection_new (int fd);
void spa_connection_free (SpaConnection *conn); void pinos_connection_free (PinosConnection *conn);
SpaResult spa_connection_has_next (SpaConnection *conn); gboolean pinos_connection_has_next (PinosConnection *conn);
SpaControlCmd spa_connection_get_cmd (SpaConnection *conn); PinosControlCmd pinos_connection_get_cmd (PinosConnection *conn);
SpaResult spa_connection_parse_cmd (SpaConnection *conn, gboolean pinos_connection_parse_cmd (PinosConnection *conn,
void *command); gpointer command);
int spa_connection_get_fd (SpaConnection *conn, int pinos_connection_get_fd (PinosConnection *conn,
unsigned int index, guint index,
bool close); gboolean close);
int spa_connection_add_fd (SpaConnection *conn, int pinos_connection_add_fd (PinosConnection *conn,
int fd, int fd,
bool close); gboolean close);
SpaResult spa_connection_add_cmd (SpaConnection *conn, gboolean pinos_connection_add_cmd (PinosConnection *conn,
SpaControlCmd cmd, PinosControlCmd cmd,
void *command); gpointer command);
SpaResult spa_connection_flush (SpaConnection *conn); gboolean pinos_connection_flush (PinosConnection *conn);
SpaResult spa_connection_clear (SpaConnection *conn); gboolean pinos_connection_clear (PinosConnection *conn);
#ifdef __cplusplus G_END_DECLS
} /* extern "C" */
#endif
#endif /* __SPA_CONTROL_H__ */ #endif /* __PINOS_CONTROL_H__ */

View file

@ -95,8 +95,8 @@ struct _PinosStreamPrivate
GSource *rtsocket_source; GSource *rtsocket_source;
int rtfd; int rtfd;
SpaConnection *conn; PinosConnection *conn;
SpaConnection *rtconn; PinosConnection *rtconn;
GSource *timeout_source; GSource *timeout_source;
@ -614,26 +614,26 @@ static void
add_node_update (PinosStream *stream, uint32_t change_mask) add_node_update (PinosStream *stream, uint32_t change_mask)
{ {
PinosStreamPrivate *priv = stream->priv; PinosStreamPrivate *priv = stream->priv;
SpaControlCmdNodeUpdate nu = { 0, }; PinosControlCmdNodeUpdate nu = { 0, };
nu.change_mask = change_mask; nu.change_mask = change_mask;
if (change_mask & SPA_CONTROL_CMD_NODE_UPDATE_MAX_INPUTS) if (change_mask & PINOS_CONTROL_CMD_NODE_UPDATE_MAX_INPUTS)
nu.max_input_ports = priv->direction == SPA_DIRECTION_INPUT ? 1 : 0; nu.max_input_ports = priv->direction == SPA_DIRECTION_INPUT ? 1 : 0;
if (change_mask & SPA_CONTROL_CMD_NODE_UPDATE_MAX_OUTPUTS) if (change_mask & PINOS_CONTROL_CMD_NODE_UPDATE_MAX_OUTPUTS)
nu.max_output_ports = priv->direction == SPA_DIRECTION_OUTPUT ? 1 : 0; nu.max_output_ports = priv->direction == SPA_DIRECTION_OUTPUT ? 1 : 0;
nu.props = NULL; nu.props = NULL;
spa_connection_add_cmd (priv->conn, SPA_CONTROL_CMD_NODE_UPDATE, &nu); pinos_connection_add_cmd (priv->conn, PINOS_CONTROL_CMD_NODE_UPDATE, &nu);
} }
static void static void
add_state_change (PinosStream *stream, SpaNodeState state) add_state_change (PinosStream *stream, SpaNodeState state)
{ {
PinosStreamPrivate *priv = stream->priv; PinosStreamPrivate *priv = stream->priv;
SpaControlCmdNodeStateChange sc; PinosControlCmdNodeStateChange sc;
if (priv->node_state != state) { if (priv->node_state != state) {
sc.state = priv->node_state = state; sc.state = priv->node_state = state;
spa_connection_add_cmd (priv->conn, SPA_CONTROL_CMD_NODE_STATE_CHANGE, &sc); pinos_connection_add_cmd (priv->conn, PINOS_CONTROL_CMD_NODE_STATE_CHANGE, &sc);
} }
} }
@ -641,31 +641,31 @@ static void
add_port_update (PinosStream *stream, uint32_t change_mask) add_port_update (PinosStream *stream, uint32_t change_mask)
{ {
PinosStreamPrivate *priv = stream->priv; PinosStreamPrivate *priv = stream->priv;
SpaControlCmdPortUpdate pu = { 0, };; PinosControlCmdPortUpdate pu = { 0, };;
pu.direction = priv->direction; pu.direction = priv->direction;
pu.port_id = priv->port_id; pu.port_id = priv->port_id;
pu.change_mask = change_mask; pu.change_mask = change_mask;
if (change_mask & SPA_CONTROL_CMD_PORT_UPDATE_POSSIBLE_FORMATS) { if (change_mask & PINOS_CONTROL_CMD_PORT_UPDATE_POSSIBLE_FORMATS) {
pu.n_possible_formats = priv->possible_formats->len; pu.n_possible_formats = priv->possible_formats->len;
pu.possible_formats = (SpaFormat **)priv->possible_formats->pdata; pu.possible_formats = (SpaFormat **)priv->possible_formats->pdata;
} }
if (change_mask & SPA_CONTROL_CMD_PORT_UPDATE_FORMAT) { if (change_mask & PINOS_CONTROL_CMD_PORT_UPDATE_FORMAT) {
pu.format = priv->format; pu.format = priv->format;
} }
pu.props = NULL; pu.props = NULL;
if (change_mask & SPA_CONTROL_CMD_PORT_UPDATE_INFO) { if (change_mask & PINOS_CONTROL_CMD_PORT_UPDATE_INFO) {
pu.info = &priv->port_info; pu.info = &priv->port_info;
spa_debug_port_info (pu.info); spa_debug_port_info (pu.info);
} }
spa_connection_add_cmd (priv->conn, SPA_CONTROL_CMD_PORT_UPDATE, &pu); pinos_connection_add_cmd (priv->conn, PINOS_CONTROL_CMD_PORT_UPDATE, &pu);
} }
static void static void
send_need_input (PinosStream *stream, uint32_t port_id) send_need_input (PinosStream *stream, uint32_t port_id)
{ {
PinosStreamPrivate *priv = stream->priv; PinosStreamPrivate *priv = stream->priv;
SpaControlCmdNodeEvent cne; PinosControlCmdNodeEvent cne;
SpaNodeEvent ne; SpaNodeEvent ne;
SpaNodeEventNeedInput ni; SpaNodeEventNeedInput ni;
@ -674,9 +674,9 @@ send_need_input (PinosStream *stream, uint32_t port_id)
ne.data = &ni; ne.data = &ni;
ne.size = sizeof (ni); ne.size = sizeof (ni);
ni.port_id = port_id; ni.port_id = port_id;
spa_connection_add_cmd (priv->rtconn, SPA_CONTROL_CMD_NODE_EVENT, &cne); pinos_connection_add_cmd (priv->rtconn, PINOS_CONTROL_CMD_NODE_EVENT, &cne);
if (spa_connection_flush (priv->rtconn) < 0) if (!pinos_connection_flush (priv->rtconn))
g_warning ("stream %p: error writing connection", stream); g_warning ("stream %p: error writing connection", stream);
} }
@ -684,7 +684,7 @@ static void
add_request_clock_update (PinosStream *stream) add_request_clock_update (PinosStream *stream)
{ {
PinosStreamPrivate *priv = stream->priv; PinosStreamPrivate *priv = stream->priv;
SpaControlCmdNodeEvent cne; PinosControlCmdNodeEvent cne;
SpaNodeEvent ne; SpaNodeEvent ne;
SpaNodeEventRequestClockUpdate rcu; SpaNodeEventRequestClockUpdate rcu;
@ -695,7 +695,7 @@ add_request_clock_update (PinosStream *stream)
rcu.update_mask = SPA_NODE_EVENT_REQUEST_CLOCK_UPDATE_TIME; rcu.update_mask = SPA_NODE_EVENT_REQUEST_CLOCK_UPDATE_TIME;
rcu.timestamp = 0; rcu.timestamp = 0;
rcu.offset = 0; rcu.offset = 0;
spa_connection_add_cmd (priv->conn, SPA_CONTROL_CMD_NODE_EVENT, &cne); pinos_connection_add_cmd (priv->conn, PINOS_CONTROL_CMD_NODE_EVENT, &cne);
} }
static void static void
@ -704,7 +704,7 @@ add_async_complete (PinosStream *stream,
SpaResult res) SpaResult res)
{ {
PinosStreamPrivate *priv = stream->priv; PinosStreamPrivate *priv = stream->priv;
SpaControlCmdNodeEvent cne; PinosControlCmdNodeEvent cne;
SpaNodeEvent ne; SpaNodeEvent ne;
SpaNodeEventAsyncComplete ac; SpaNodeEventAsyncComplete ac;
@ -714,14 +714,14 @@ add_async_complete (PinosStream *stream,
ne.size = sizeof (ac); ne.size = sizeof (ac);
ac.seq = seq; ac.seq = seq;
ac.res = res; ac.res = res;
spa_connection_add_cmd (priv->conn, SPA_CONTROL_CMD_NODE_EVENT, &cne); pinos_connection_add_cmd (priv->conn, PINOS_CONTROL_CMD_NODE_EVENT, &cne);
} }
static void static void
send_reuse_buffer (PinosStream *stream, uint32_t port_id, uint32_t buffer_id) send_reuse_buffer (PinosStream *stream, uint32_t port_id, uint32_t buffer_id)
{ {
PinosStreamPrivate *priv = stream->priv; PinosStreamPrivate *priv = stream->priv;
SpaControlCmdNodeEvent cne; PinosControlCmdNodeEvent cne;
SpaNodeEvent ne; SpaNodeEvent ne;
SpaNodeEventReuseBuffer rb; SpaNodeEventReuseBuffer rb;
@ -731,9 +731,9 @@ send_reuse_buffer (PinosStream *stream, uint32_t port_id, uint32_t buffer_id)
ne.size = sizeof (rb); ne.size = sizeof (rb);
rb.port_id = port_id; rb.port_id = port_id;
rb.buffer_id = buffer_id; rb.buffer_id = buffer_id;
spa_connection_add_cmd (priv->rtconn, SPA_CONTROL_CMD_NODE_EVENT, &cne); pinos_connection_add_cmd (priv->rtconn, PINOS_CONTROL_CMD_NODE_EVENT, &cne);
if (spa_connection_flush (priv->rtconn) < 0) if (!pinos_connection_flush (priv->rtconn))
g_warning ("stream %p: error writing connection", stream); g_warning ("stream %p: error writing connection", stream);
} }
@ -741,24 +741,24 @@ static void
send_process_buffer (PinosStream *stream, uint32_t port_id, uint32_t buffer_id) send_process_buffer (PinosStream *stream, uint32_t port_id, uint32_t buffer_id)
{ {
PinosStreamPrivate *priv = stream->priv; PinosStreamPrivate *priv = stream->priv;
SpaControlCmdProcessBuffer pb; PinosControlCmdProcessBuffer pb;
SpaControlCmdNodeEvent cne; PinosControlCmdNodeEvent cne;
SpaNodeEvent ne; SpaNodeEvent ne;
SpaNodeEventHaveOutput ho; SpaNodeEventHaveOutput ho;
pb.direction = priv->direction; pb.direction = priv->direction;
pb.port_id = port_id; pb.port_id = port_id;
pb.buffer_id = buffer_id; pb.buffer_id = buffer_id;
spa_connection_add_cmd (priv->rtconn, SPA_CONTROL_CMD_PROCESS_BUFFER, &pb); pinos_connection_add_cmd (priv->rtconn, PINOS_CONTROL_CMD_PROCESS_BUFFER, &pb);
cne.event = &ne; cne.event = &ne;
ne.type = SPA_NODE_EVENT_TYPE_HAVE_OUTPUT; ne.type = SPA_NODE_EVENT_TYPE_HAVE_OUTPUT;
ne.data = &ho; ne.data = &ho;
ne.size = sizeof (ho); ne.size = sizeof (ho);
ho.port_id = port_id; ho.port_id = port_id;
spa_connection_add_cmd (priv->rtconn, SPA_CONTROL_CMD_NODE_EVENT, &cne); pinos_connection_add_cmd (priv->rtconn, PINOS_CONTROL_CMD_NODE_EVENT, &cne);
if (spa_connection_flush (priv->rtconn) < 0) if (!pinos_connection_flush (priv->rtconn))
g_warning ("stream %p: error writing connection", stream); g_warning ("stream %p: error writing connection", stream);
} }
@ -767,16 +767,16 @@ do_node_init (PinosStream *stream)
{ {
PinosStreamPrivate *priv = stream->priv; PinosStreamPrivate *priv = stream->priv;
add_node_update (stream, SPA_CONTROL_CMD_NODE_UPDATE_MAX_INPUTS | add_node_update (stream, PINOS_CONTROL_CMD_NODE_UPDATE_MAX_INPUTS |
SPA_CONTROL_CMD_NODE_UPDATE_MAX_OUTPUTS); PINOS_CONTROL_CMD_NODE_UPDATE_MAX_OUTPUTS);
priv->port_info.flags = SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS; priv->port_info.flags = SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS;
add_port_update (stream, SPA_CONTROL_CMD_PORT_UPDATE_POSSIBLE_FORMATS | add_port_update (stream, PINOS_CONTROL_CMD_PORT_UPDATE_POSSIBLE_FORMATS |
SPA_CONTROL_CMD_PORT_UPDATE_INFO); PINOS_CONTROL_CMD_PORT_UPDATE_INFO);
add_state_change (stream, SPA_NODE_STATE_CONFIGURE); add_state_change (stream, SPA_NODE_STATE_CONFIGURE);
if (spa_connection_flush (priv->conn) < 0) if (!pinos_connection_flush (priv->conn))
g_warning ("stream %p: error writing connection", stream); g_warning ("stream %p: error writing connection", stream);
} }
@ -894,7 +894,7 @@ handle_node_command (PinosStream *stream,
add_state_change (stream, SPA_NODE_STATE_PAUSED); add_state_change (stream, SPA_NODE_STATE_PAUSED);
add_async_complete (stream, seq, SPA_RESULT_OK); add_async_complete (stream, seq, SPA_RESULT_OK);
if (spa_connection_flush (priv->conn) < 0) if (!pinos_connection_flush (priv->conn))
g_warning ("stream %p: error writing connection", stream); g_warning ("stream %p: error writing connection", stream);
stream_set_state (stream, PINOS_STREAM_STATE_READY, NULL); stream_set_state (stream, PINOS_STREAM_STATE_READY, NULL);
@ -906,7 +906,7 @@ handle_node_command (PinosStream *stream,
add_state_change (stream, SPA_NODE_STATE_STREAMING); add_state_change (stream, SPA_NODE_STATE_STREAMING);
add_async_complete (stream, seq, SPA_RESULT_OK); add_async_complete (stream, seq, SPA_RESULT_OK);
if (spa_connection_flush (priv->conn) < 0) if (!pinos_connection_flush (priv->conn))
g_warning ("stream %p: error writing connection", stream); g_warning ("stream %p: error writing connection", stream);
if (priv->direction == SPA_DIRECTION_INPUT) if (priv->direction == SPA_DIRECTION_INPUT)
@ -922,7 +922,7 @@ handle_node_command (PinosStream *stream,
g_warning ("unhandled node command %d", command->type); g_warning ("unhandled node command %d", command->type);
add_async_complete (stream, seq, SPA_RESULT_NOT_IMPLEMENTED); add_async_complete (stream, seq, SPA_RESULT_NOT_IMPLEMENTED);
if (spa_connection_flush (priv->conn) < 0) if (!pinos_connection_flush (priv->conn))
g_warning ("stream %p: error writing connection", stream); g_warning ("stream %p: error writing connection", stream);
break; break;
} }
@ -949,31 +949,31 @@ static gboolean
parse_connection (PinosStream *stream) parse_connection (PinosStream *stream)
{ {
PinosStreamPrivate *priv = stream->priv; PinosStreamPrivate *priv = stream->priv;
SpaConnection *conn = priv->conn; PinosConnection *conn = priv->conn;
while (spa_connection_has_next (conn) == SPA_RESULT_OK) { while (pinos_connection_has_next (conn)) {
SpaControlCmd cmd = spa_connection_get_cmd (conn); PinosControlCmd cmd = pinos_connection_get_cmd (conn);
switch (cmd) { switch (cmd) {
case SPA_CONTROL_CMD_NODE_UPDATE: case PINOS_CONTROL_CMD_NODE_UPDATE:
case SPA_CONTROL_CMD_PORT_UPDATE: case PINOS_CONTROL_CMD_PORT_UPDATE:
case SPA_CONTROL_CMD_PORT_STATUS_CHANGE: case PINOS_CONTROL_CMD_PORT_STATUS_CHANGE:
case SPA_CONTROL_CMD_NODE_STATE_CHANGE: case PINOS_CONTROL_CMD_NODE_STATE_CHANGE:
case SPA_CONTROL_CMD_PROCESS_BUFFER: case PINOS_CONTROL_CMD_PROCESS_BUFFER:
g_warning ("got unexpected connection %d", cmd); g_warning ("got unexpected connection %d", cmd);
break; break;
case SPA_CONTROL_CMD_ADD_PORT: case PINOS_CONTROL_CMD_ADD_PORT:
case SPA_CONTROL_CMD_REMOVE_PORT: case PINOS_CONTROL_CMD_REMOVE_PORT:
g_warning ("add/remove port not supported"); g_warning ("add/remove port not supported");
break; break;
case SPA_CONTROL_CMD_SET_FORMAT: case PINOS_CONTROL_CMD_SET_FORMAT:
{ {
SpaControlCmdSetFormat p; PinosControlCmdSetFormat p;
gpointer mem; gpointer mem;
if (spa_connection_parse_cmd (conn, &p) < 0) if (!pinos_connection_parse_cmd (conn, &p))
break; break;
if (priv->format) if (priv->format)
@ -986,20 +986,20 @@ parse_connection (PinosStream *stream)
g_object_notify (G_OBJECT (stream), "format"); g_object_notify (G_OBJECT (stream), "format");
break; break;
} }
case SPA_CONTROL_CMD_SET_PROPERTY: case PINOS_CONTROL_CMD_SET_PROPERTY:
g_warning ("set property not implemented"); g_warning ("set property not implemented");
break; break;
case SPA_CONTROL_CMD_ADD_MEM: case PINOS_CONTROL_CMD_ADD_MEM:
{ {
SpaControlCmdAddMem p; PinosControlCmdAddMem p;
int fd; int fd;
MemId mid; MemId mid;
if (spa_connection_parse_cmd (conn, &p) < 0) if (!pinos_connection_parse_cmd (conn, &p))
break; break;
fd = spa_connection_get_fd (conn, p.fd_index, false); fd = pinos_connection_get_fd (conn, p.fd_index, false);
if (fd == -1) if (fd == -1)
break; break;
@ -1013,12 +1013,12 @@ parse_connection (PinosStream *stream)
g_array_append_val (priv->mem_ids, mid); g_array_append_val (priv->mem_ids, mid);
break; break;
} }
case SPA_CONTROL_CMD_REMOVE_MEM: case PINOS_CONTROL_CMD_REMOVE_MEM:
{ {
SpaControlCmdRemoveMem p; PinosControlCmdRemoveMem p;
MemId *mid; MemId *mid;
if (spa_connection_parse_cmd (conn, &p) < 0) if (!pinos_connection_parse_cmd (conn, &p))
break; break;
g_debug ("stream %p: remove mem %d", stream, p.mem_id); g_debug ("stream %p: remove mem %d", stream, p.mem_id);
@ -1026,14 +1026,14 @@ parse_connection (PinosStream *stream)
mid->cleanup = true; mid->cleanup = true;
break; break;
} }
case SPA_CONTROL_CMD_USE_BUFFERS: case PINOS_CONTROL_CMD_USE_BUFFERS:
{ {
SpaControlCmdUseBuffers p; PinosControlCmdUseBuffers p;
BufferId bid; BufferId bid;
unsigned int i, j; unsigned int i, j;
SpaBuffer *b; SpaBuffer *b;
if (spa_connection_parse_cmd (conn, &p) < 0) if (!pinos_connection_parse_cmd (conn, &p))
break; break;
/* clear previous buffers */ /* clear previous buffers */
@ -1130,32 +1130,32 @@ parse_connection (PinosStream *stream)
} }
add_async_complete (stream, p.seq, SPA_RESULT_OK); add_async_complete (stream, p.seq, SPA_RESULT_OK);
if (spa_connection_flush (conn) < 0) if (!pinos_connection_flush (conn))
g_warning ("stream %p: error writing connection", stream); g_warning ("stream %p: error writing connection", stream);
break; break;
} }
case SPA_CONTROL_CMD_NODE_EVENT: case PINOS_CONTROL_CMD_NODE_EVENT:
{ {
SpaControlCmdNodeEvent p; PinosControlCmdNodeEvent p;
if (spa_connection_parse_cmd (conn, &p) < 0) if (!pinos_connection_parse_cmd (conn, &p))
break; break;
handle_node_event (stream, p.event); handle_node_event (stream, p.event);
break; break;
} }
case SPA_CONTROL_CMD_NODE_COMMAND: case PINOS_CONTROL_CMD_NODE_COMMAND:
{ {
SpaControlCmdNodeCommand p; PinosControlCmdNodeCommand p;
if (spa_connection_parse_cmd (conn, &p) < 0) if (!pinos_connection_parse_cmd (conn, &p))
break; break;
handle_node_command (stream, p.seq, p.command); handle_node_command (stream, p.seq, p.command);
break; break;
} }
case SPA_CONTROL_CMD_INVALID: case PINOS_CONTROL_CMD_INVALID:
g_warning ("unhandled command %d", cmd); g_warning ("unhandled command %d", cmd);
break; break;
} }
@ -1167,38 +1167,38 @@ static gboolean
parse_rtconnection (PinosStream *stream) parse_rtconnection (PinosStream *stream)
{ {
PinosStreamPrivate *priv = stream->priv; PinosStreamPrivate *priv = stream->priv;
SpaConnection *conn = priv->rtconn; PinosConnection *conn = priv->rtconn;
while (spa_connection_has_next (conn) == SPA_RESULT_OK) { while (pinos_connection_has_next (conn)) {
SpaControlCmd cmd = spa_connection_get_cmd (conn); PinosControlCmd cmd = pinos_connection_get_cmd (conn);
switch (cmd) { switch (cmd) {
case SPA_CONTROL_CMD_INVALID: case PINOS_CONTROL_CMD_INVALID:
case SPA_CONTROL_CMD_NODE_UPDATE: case PINOS_CONTROL_CMD_NODE_UPDATE:
case SPA_CONTROL_CMD_PORT_UPDATE: case PINOS_CONTROL_CMD_PORT_UPDATE:
case SPA_CONTROL_CMD_PORT_STATUS_CHANGE: case PINOS_CONTROL_CMD_PORT_STATUS_CHANGE:
case SPA_CONTROL_CMD_NODE_STATE_CHANGE: case PINOS_CONTROL_CMD_NODE_STATE_CHANGE:
case SPA_CONTROL_CMD_ADD_PORT: case PINOS_CONTROL_CMD_ADD_PORT:
case SPA_CONTROL_CMD_REMOVE_PORT: case PINOS_CONTROL_CMD_REMOVE_PORT:
case SPA_CONTROL_CMD_SET_FORMAT: case PINOS_CONTROL_CMD_SET_FORMAT:
case SPA_CONTROL_CMD_SET_PROPERTY: case PINOS_CONTROL_CMD_SET_PROPERTY:
case SPA_CONTROL_CMD_ADD_MEM: case PINOS_CONTROL_CMD_ADD_MEM:
case SPA_CONTROL_CMD_REMOVE_MEM: case PINOS_CONTROL_CMD_REMOVE_MEM:
case SPA_CONTROL_CMD_USE_BUFFERS: case PINOS_CONTROL_CMD_USE_BUFFERS:
case SPA_CONTROL_CMD_NODE_COMMAND: case PINOS_CONTROL_CMD_NODE_COMMAND:
g_warning ("got unexpected connection %d", cmd); g_warning ("got unexpected connection %d", cmd);
break; break;
case SPA_CONTROL_CMD_PROCESS_BUFFER: case PINOS_CONTROL_CMD_PROCESS_BUFFER:
{ {
SpaControlCmdProcessBuffer p; PinosControlCmdProcessBuffer p;
guint i; guint i;
BufferId *bid; BufferId *bid;
if (priv->direction != SPA_DIRECTION_INPUT) if (priv->direction != SPA_DIRECTION_INPUT)
break; break;
if (spa_connection_parse_cmd (conn, &p) < 0) if (!pinos_connection_parse_cmd (conn, &p))
break; break;
if ((bid = find_buffer (stream, p.buffer_id))) { if ((bid = find_buffer (stream, p.buffer_id))) {
@ -1211,11 +1211,11 @@ parse_rtconnection (PinosStream *stream)
} }
break; break;
} }
case SPA_CONTROL_CMD_NODE_EVENT: case PINOS_CONTROL_CMD_NODE_EVENT:
{ {
SpaControlCmdNodeEvent p; PinosControlCmdNodeEvent p;
if (spa_connection_parse_cmd (conn, &p) < 0) if (!pinos_connection_parse_cmd (conn, &p))
break; break;
handle_rtnode_event (stream, p.event); handle_rtnode_event (stream, p.event);
@ -1283,7 +1283,7 @@ on_timeout (gpointer user_data)
add_request_clock_update (stream); add_request_clock_update (stream);
if (spa_connection_flush (priv->conn) < 0) if (!pinos_connection_flush (priv->conn))
g_warning ("stream %p: error writing connection", stream); g_warning ("stream %p: error writing connection", stream);
return G_SOURCE_CONTINUE; return G_SOURCE_CONTINUE;
@ -1306,13 +1306,13 @@ handle_socket (PinosStream *stream, gint fd, gint rtfd)
priv->socket_source = g_socket_create_source (priv->socket, G_IO_IN, NULL); priv->socket_source = g_socket_create_source (priv->socket, G_IO_IN, NULL);
g_source_set_callback (priv->socket_source, (GSourceFunc) on_socket_condition, stream, NULL); g_source_set_callback (priv->socket_source, (GSourceFunc) on_socket_condition, stream, NULL);
g_source_attach (priv->socket_source, priv->context->priv->context); g_source_attach (priv->socket_source, priv->context->priv->context);
priv->conn = spa_connection_new (priv->fd); priv->conn = pinos_connection_new (priv->fd);
priv->rtfd = g_socket_get_fd (priv->rtsocket); priv->rtfd = g_socket_get_fd (priv->rtsocket);
priv->rtsocket_source = g_socket_create_source (priv->rtsocket, G_IO_IN, NULL); priv->rtsocket_source = g_socket_create_source (priv->rtsocket, G_IO_IN, NULL);
g_source_set_callback (priv->rtsocket_source, (GSourceFunc) on_rtsocket_condition, stream, NULL); g_source_set_callback (priv->rtsocket_source, (GSourceFunc) on_rtsocket_condition, stream, NULL);
g_source_attach (priv->rtsocket_source, priv->context->priv->context); g_source_attach (priv->rtsocket_source, priv->context->priv->context);
priv->rtconn = spa_connection_new (priv->rtfd); priv->rtconn = pinos_connection_new (priv->rtfd);
priv->timeout_source = g_timeout_source_new (100); priv->timeout_source = g_timeout_source_new (100);
g_source_set_callback (priv->timeout_source, (GSourceFunc) on_timeout, stream, NULL); g_source_set_callback (priv->timeout_source, (GSourceFunc) on_timeout, stream, NULL);
@ -1637,8 +1637,8 @@ pinos_stream_finish_format (PinosStream *stream,
priv->port_info.n_params = n_params; priv->port_info.n_params = n_params;
if (SPA_RESULT_IS_OK (res)) { if (SPA_RESULT_IS_OK (res)) {
add_port_update (stream, SPA_CONTROL_CMD_PORT_UPDATE_INFO | add_port_update (stream, PINOS_CONTROL_CMD_PORT_UPDATE_INFO |
SPA_CONTROL_CMD_PORT_UPDATE_FORMAT); PINOS_CONTROL_CMD_PORT_UPDATE_FORMAT);
if (priv->format) { if (priv->format) {
add_state_change (stream, SPA_NODE_STATE_READY); add_state_change (stream, SPA_NODE_STATE_READY);
} else { } else {
@ -1653,7 +1653,7 @@ pinos_stream_finish_format (PinosStream *stream,
priv->pending_seq = SPA_ID_INVALID; priv->pending_seq = SPA_ID_INVALID;
if (spa_connection_flush (priv->conn) < 0) if (!pinos_connection_flush (priv->conn))
g_warning ("stream %p: error writing connection", stream); g_warning ("stream %p: error writing connection", stream);
return TRUE; return TRUE;

View file

@ -103,11 +103,11 @@ struct _SpaProxy
SpaPollFd fds[1]; SpaPollFd fds[1];
SpaPollItem poll; SpaPollItem poll;
SpaConnection *conn; PinosConnection *conn;
SpaPollFd rtfds[1]; SpaPollFd rtfds[1];
SpaPollItem rtpoll; SpaPollItem rtpoll;
SpaConnection *rtconn; PinosConnection *rtconn;
unsigned int max_inputs; unsigned int max_inputs;
unsigned int n_inputs; unsigned int n_inputs;
@ -210,15 +210,15 @@ spa_proxy_node_send_command (SpaNode *node,
case SPA_NODE_COMMAND_DRAIN: case SPA_NODE_COMMAND_DRAIN:
case SPA_NODE_COMMAND_MARKER: case SPA_NODE_COMMAND_MARKER:
{ {
SpaControlCmdNodeCommand cnc; PinosControlCmdNodeCommand cnc;
/* send start */ /* send start */
cnc.seq = this->seq++; cnc.seq = this->seq++;
cnc.command = command; cnc.command = command;
spa_connection_add_cmd (this->conn, SPA_CONTROL_CMD_NODE_COMMAND, &cnc); pinos_connection_add_cmd (this->conn, PINOS_CONTROL_CMD_NODE_COMMAND, &cnc);
if ((res = spa_connection_flush (this->conn)) < 0) if (!pinos_connection_flush (this->conn))
spa_log_error (this->log, "proxy %p: error writing connection %d\n", this, res); spa_log_error (this->log, "proxy %p: error writing connection\n", this);
res = SPA_RESULT_RETURN_ASYNC (cnc.seq); res = SPA_RESULT_RETURN_ASYNC (cnc.seq);
break; break;
@ -226,14 +226,14 @@ spa_proxy_node_send_command (SpaNode *node,
case SPA_NODE_COMMAND_CLOCK_UPDATE: case SPA_NODE_COMMAND_CLOCK_UPDATE:
{ {
SpaControlCmdNodeCommand cnc; PinosControlCmdNodeCommand cnc;
/* send start */ /* send start */
cnc.command = command; cnc.command = command;
spa_connection_add_cmd (this->conn, SPA_CONTROL_CMD_NODE_COMMAND, &cnc); pinos_connection_add_cmd (this->conn, PINOS_CONTROL_CMD_NODE_COMMAND, &cnc);
if ((res = spa_connection_flush (this->conn)) < 0) if (!pinos_connection_flush (this->conn))
spa_log_error (this->log, "proxy %p: error writing connection %d\n", this, res); spa_log_error (this->log, "proxy %p: error writing connection\n", this);
break; break;
} }
@ -316,7 +316,7 @@ spa_proxy_node_get_port_ids (SpaNode *node,
static void static void
do_update_port (SpaProxy *this, do_update_port (SpaProxy *this,
SpaControlCmdPortUpdate *pu) PinosControlCmdPortUpdate *pu)
{ {
SpaProxyPort *port; SpaProxyPort *port;
unsigned int i; unsigned int i;
@ -328,7 +328,7 @@ do_update_port (SpaProxy *this,
port = &this->out_ports[pu->port_id]; port = &this->out_ports[pu->port_id];
} }
if (pu->change_mask & SPA_CONTROL_CMD_PORT_UPDATE_POSSIBLE_FORMATS) { if (pu->change_mask & PINOS_CONTROL_CMD_PORT_UPDATE_POSSIBLE_FORMATS) {
for (i = 0; i < port->n_formats; i++) for (i = 0; i < port->n_formats; i++)
free (port->formats[i]); free (port->formats[i]);
port->n_formats = pu->n_possible_formats; port->n_formats = pu->n_possible_formats;
@ -338,17 +338,17 @@ do_update_port (SpaProxy *this,
port->formats[i] = spa_serialize_format_copy_into (malloc (size), pu->possible_formats[i]); port->formats[i] = spa_serialize_format_copy_into (malloc (size), pu->possible_formats[i]);
} }
} }
if (pu->change_mask & SPA_CONTROL_CMD_PORT_UPDATE_FORMAT) { if (pu->change_mask & PINOS_CONTROL_CMD_PORT_UPDATE_FORMAT) {
if (port->format) if (port->format)
free (port->format); free (port->format);
size = spa_serialize_format_get_size (pu->format); size = spa_serialize_format_get_size (pu->format);
port->format = spa_serialize_format_copy_into (malloc (size), pu->format); port->format = spa_serialize_format_copy_into (malloc (size), pu->format);
} }
if (pu->change_mask & SPA_CONTROL_CMD_PORT_UPDATE_PROPS) { if (pu->change_mask & PINOS_CONTROL_CMD_PORT_UPDATE_PROPS) {
} }
if (pu->change_mask & SPA_CONTROL_CMD_PORT_UPDATE_INFO && pu->info) { if (pu->change_mask & PINOS_CONTROL_CMD_PORT_UPDATE_INFO && pu->info) {
if (port->info) if (port->info)
free (port->info); free (port->info);
size = spa_serialize_port_info_get_size (pu->info); size = spa_serialize_port_info_get_size (pu->info);
@ -373,12 +373,12 @@ clear_port (SpaProxy *this,
SpaDirection direction, SpaDirection direction,
uint32_t port_id) uint32_t port_id)
{ {
SpaControlCmdPortUpdate pu; PinosControlCmdPortUpdate pu;
pu.change_mask = SPA_CONTROL_CMD_PORT_UPDATE_POSSIBLE_FORMATS | pu.change_mask = PINOS_CONTROL_CMD_PORT_UPDATE_POSSIBLE_FORMATS |
SPA_CONTROL_CMD_PORT_UPDATE_FORMAT | PINOS_CONTROL_CMD_PORT_UPDATE_FORMAT |
SPA_CONTROL_CMD_PORT_UPDATE_PROPS | PINOS_CONTROL_CMD_PORT_UPDATE_PROPS |
SPA_CONTROL_CMD_PORT_UPDATE_INFO; PINOS_CONTROL_CMD_PORT_UPDATE_INFO;
pu.direction = direction; pu.direction = direction;
pu.port_id = port_id; pu.port_id = port_id;
pu.n_possible_formats = 0; pu.n_possible_formats = 0;
@ -492,8 +492,7 @@ spa_proxy_node_port_set_format (SpaNode *node,
const SpaFormat *format) const SpaFormat *format)
{ {
SpaProxy *this; SpaProxy *this;
SpaControlCmdSetFormat sf; PinosControlCmdSetFormat sf;
SpaResult res;
if (node == NULL) if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
@ -508,9 +507,9 @@ spa_proxy_node_port_set_format (SpaNode *node,
sf.port_id = port_id; sf.port_id = port_id;
sf.flags = flags; sf.flags = flags;
sf.format = (SpaFormat *) format; sf.format = (SpaFormat *) format;
spa_connection_add_cmd (this->conn, SPA_CONTROL_CMD_SET_FORMAT, &sf); pinos_connection_add_cmd (this->conn, PINOS_CONTROL_CMD_SET_FORMAT, &sf);
if ((res = spa_connection_flush (this->conn)) < 0) 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\n", this);
return SPA_RESULT_RETURN_ASYNC (sf.seq); return SPA_RESULT_RETURN_ASYNC (sf.seq);
@ -622,11 +621,10 @@ spa_proxy_node_port_use_buffers (SpaNode *node,
SpaProxy *this; SpaProxy *this;
SpaProxyPort *port; SpaProxyPort *port;
unsigned int i, j; unsigned int i, j;
SpaResult res; PinosControlCmdAddMem am;
SpaControlCmdAddMem am; PinosControlCmdUseBuffers ub;
SpaControlCmdUseBuffers ub;
size_t size, n_mem; size_t size, n_mem;
SpaControlMemRef *memref; PinosControlMemRef *memref;
void *p; void *p;
if (node == NULL) if (node == NULL)
@ -675,11 +673,11 @@ spa_proxy_node_port_use_buffers (SpaNode *node,
am.port_id = port_id; am.port_id = port_id;
am.mem_id = n_mem; am.mem_id = n_mem;
am.type = d->type; am.type = d->type;
am.fd_index = spa_connection_add_fd (this->conn, d->fd, false); am.fd_index = pinos_connection_add_fd (this->conn, d->fd, false);
am.flags = d->flags; am.flags = d->flags;
am.offset = d->offset; am.offset = d->offset;
am.size = d->maxsize; am.size = d->maxsize;
spa_connection_add_cmd (this->conn, SPA_CONTROL_CMD_ADD_MEM, &am); pinos_connection_add_cmd (this->conn, PINOS_CONTROL_CMD_ADD_MEM, &am);
b->buffer.datas[j].type = SPA_DATA_TYPE_ID; b->buffer.datas[j].type = SPA_DATA_TYPE_ID;
b->buffer.datas[j].data = SPA_UINT32_TO_PTR (n_mem); b->buffer.datas[j].data = SPA_UINT32_TO_PTR (n_mem);
@ -747,13 +745,13 @@ spa_proxy_node_port_use_buffers (SpaNode *node,
am.port_id = port_id; am.port_id = port_id;
am.mem_id = port->buffer_mem_id; am.mem_id = port->buffer_mem_id;
am.type = SPA_DATA_TYPE_MEMFD; am.type = SPA_DATA_TYPE_MEMFD;
am.fd_index = spa_connection_add_fd (this->conn, port->buffer_mem_fd, false); am.fd_index = pinos_connection_add_fd (this->conn, port->buffer_mem_fd, false);
am.flags = 0; am.flags = 0;
am.offset = 0; am.offset = 0;
am.size = size; am.size = size;
spa_connection_add_cmd (this->conn, SPA_CONTROL_CMD_ADD_MEM, &am); pinos_connection_add_cmd (this->conn, PINOS_CONTROL_CMD_ADD_MEM, &am);
memref = alloca (n_buffers * sizeof (SpaControlMemRef)); memref = alloca (n_buffers * sizeof (PinosControlMemRef));
for (i = 0; i < n_buffers; i++) { for (i = 0; i < n_buffers; i++) {
memref[i].mem_id = port->buffer_mem_id; memref[i].mem_id = port->buffer_mem_id;
memref[i].offset = port->buffers[i].offset; memref[i].offset = port->buffers[i].offset;
@ -769,9 +767,9 @@ spa_proxy_node_port_use_buffers (SpaNode *node,
ub.port_id = port_id; ub.port_id = port_id;
ub.n_buffers = n_buffers; ub.n_buffers = n_buffers;
ub.buffers = memref; ub.buffers = memref;
spa_connection_add_cmd (this->conn, SPA_CONTROL_CMD_USE_BUFFERS, &ub); pinos_connection_add_cmd (this->conn, PINOS_CONTROL_CMD_USE_BUFFERS, &ub);
if ((res = spa_connection_flush (this->conn)) < 0) 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\n", this);
return SPA_RESULT_RETURN_ASYNC (ub.seq); return SPA_RESULT_RETURN_ASYNC (ub.seq);
@ -855,8 +853,7 @@ spa_proxy_node_port_push_input (SpaNode *node,
unsigned int i; unsigned int i;
bool have_error = false; bool have_error = false;
bool have_enough = false; bool have_enough = false;
SpaControlCmdProcessBuffer pb; PinosControlCmdProcessBuffer pb;
SpaResult res;
if (node == NULL || n_info == 0 || info == NULL) if (node == NULL || n_info == 0 || info == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
@ -891,7 +888,7 @@ spa_proxy_node_port_push_input (SpaNode *node,
pb.direction = SPA_DIRECTION_INPUT; pb.direction = SPA_DIRECTION_INPUT;
pb.port_id = info[i].port_id; pb.port_id = info[i].port_id;
pb.buffer_id = info[i].buffer_id; pb.buffer_id = info[i].buffer_id;
spa_connection_add_cmd (this->rtconn, SPA_CONTROL_CMD_PROCESS_BUFFER, &pb); pinos_connection_add_cmd (this->rtconn, PINOS_CONTROL_CMD_PROCESS_BUFFER, &pb);
info[i].status = SPA_RESULT_OK; info[i].status = SPA_RESULT_OK;
} }
@ -901,7 +898,7 @@ spa_proxy_node_port_push_input (SpaNode *node,
if (have_enough) if (have_enough)
return SPA_RESULT_HAVE_ENOUGH_INPUT; return SPA_RESULT_HAVE_ENOUGH_INPUT;
if ((res = spa_connection_flush (this->rtconn)) < 0) 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\n", this);
return SPA_RESULT_OK; return SPA_RESULT_OK;
@ -958,8 +955,7 @@ spa_proxy_node_port_reuse_buffer (SpaNode *node,
uint32_t buffer_id) uint32_t buffer_id)
{ {
SpaProxy *this; SpaProxy *this;
SpaResult res; PinosControlCmdNodeEvent cne;
SpaControlCmdNodeEvent cne;
SpaNodeEvent ne; SpaNodeEvent ne;
SpaNodeEventReuseBuffer rb; SpaNodeEventReuseBuffer rb;
@ -978,12 +974,12 @@ spa_proxy_node_port_reuse_buffer (SpaNode *node,
ne.size = sizeof (rb); ne.size = sizeof (rb);
rb.port_id = port_id; rb.port_id = port_id;
rb.buffer_id = buffer_id; rb.buffer_id = buffer_id;
spa_connection_add_cmd (this->rtconn, SPA_CONTROL_CMD_NODE_EVENT, &cne); pinos_connection_add_cmd (this->rtconn, PINOS_CONTROL_CMD_NODE_EVENT, &cne);
if ((res = spa_connection_flush (this->rtconn)) < 0) if (!pinos_connection_flush (this->rtconn))
spa_log_error (this->log, "proxy %p: error writing connection %d\n", this, res); spa_log_error (this->log, "proxy %p: error writing connection\n", this);
return res; return SPA_RESULT_OK;
} }
static SpaResult static SpaResult
@ -1035,32 +1031,32 @@ handle_node_event (SpaProxy *this,
static SpaResult static SpaResult
parse_connection (SpaProxy *this) parse_connection (SpaProxy *this)
{ {
SpaConnection *conn = this->conn; PinosConnection *conn = this->conn;
while (spa_connection_has_next (conn) == SPA_RESULT_OK) { while (pinos_connection_has_next (conn)) {
SpaControlCmd cmd = spa_connection_get_cmd (conn); PinosControlCmd cmd = pinos_connection_get_cmd (conn);
switch (cmd) { switch (cmd) {
case SPA_CONTROL_CMD_INVALID: case PINOS_CONTROL_CMD_INVALID:
case SPA_CONTROL_CMD_ADD_PORT: case PINOS_CONTROL_CMD_ADD_PORT:
case SPA_CONTROL_CMD_REMOVE_PORT: case PINOS_CONTROL_CMD_REMOVE_PORT:
case SPA_CONTROL_CMD_SET_FORMAT: case PINOS_CONTROL_CMD_SET_FORMAT:
case SPA_CONTROL_CMD_SET_PROPERTY: case PINOS_CONTROL_CMD_SET_PROPERTY:
case SPA_CONTROL_CMD_NODE_COMMAND: case PINOS_CONTROL_CMD_NODE_COMMAND:
case SPA_CONTROL_CMD_PROCESS_BUFFER: case PINOS_CONTROL_CMD_PROCESS_BUFFER:
spa_log_error (this->log, "proxy %p: got unexpected command %d\n", this, cmd); spa_log_error (this->log, "proxy %p: got unexpected command %d\n", this, cmd);
break; break;
case SPA_CONTROL_CMD_NODE_UPDATE: case PINOS_CONTROL_CMD_NODE_UPDATE:
{ {
SpaControlCmdNodeUpdate nu; PinosControlCmdNodeUpdate nu;
if (spa_connection_parse_cmd (conn, &nu) < 0) if (!pinos_connection_parse_cmd (conn, &nu))
break; break;
if (nu.change_mask & SPA_CONTROL_CMD_NODE_UPDATE_MAX_INPUTS) if (nu.change_mask & PINOS_CONTROL_CMD_NODE_UPDATE_MAX_INPUTS)
this->max_inputs = nu.max_input_ports; this->max_inputs = nu.max_input_ports;
if (nu.change_mask & SPA_CONTROL_CMD_NODE_UPDATE_MAX_OUTPUTS) if (nu.change_mask & PINOS_CONTROL_CMD_NODE_UPDATE_MAX_OUTPUTS)
this->max_outputs = nu.max_output_ports; 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\n", this, cmd,
@ -1069,13 +1065,13 @@ parse_connection (SpaProxy *this)
break; break;
} }
case SPA_CONTROL_CMD_PORT_UPDATE: case PINOS_CONTROL_CMD_PORT_UPDATE:
{ {
SpaControlCmdPortUpdate pu; PinosControlCmdPortUpdate pu;
bool remove; bool remove;
spa_log_info (this->log, "proxy %p: got port update %d\n", this, cmd); spa_log_info (this->log, "proxy %p: got port update %d\n", this, cmd);
if (spa_connection_parse_cmd (conn, &pu) < 0) if (!pinos_connection_parse_cmd (conn, &pu))
break; break;
if (!CHECK_PORT_ID (this, pu.direction, pu.port_id)) if (!CHECK_PORT_ID (this, pu.direction, pu.port_id))
@ -1091,18 +1087,18 @@ parse_connection (SpaProxy *this)
break; break;
} }
case SPA_CONTROL_CMD_PORT_STATUS_CHANGE: case PINOS_CONTROL_CMD_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\n", this, cmd);
break; break;
} }
case SPA_CONTROL_CMD_NODE_STATE_CHANGE: case PINOS_CONTROL_CMD_NODE_STATE_CHANGE:
{ {
SpaControlCmdNodeStateChange sc; PinosControlCmdNodeStateChange sc;
SpaNodeState old = this->node.state; SpaNodeState old = this->node.state;
if (spa_connection_parse_cmd (conn, &sc) < 0) if (!pinos_connection_parse_cmd (conn, &sc))
break; 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\n", this, old, sc.state);
@ -1113,18 +1109,18 @@ parse_connection (SpaProxy *this)
break; break;
} }
case SPA_CONTROL_CMD_ADD_MEM: case PINOS_CONTROL_CMD_ADD_MEM:
break; break;
case SPA_CONTROL_CMD_REMOVE_MEM: case PINOS_CONTROL_CMD_REMOVE_MEM:
break; break;
case SPA_CONTROL_CMD_USE_BUFFERS: case PINOS_CONTROL_CMD_USE_BUFFERS:
break; break;
case SPA_CONTROL_CMD_NODE_EVENT: case PINOS_CONTROL_CMD_NODE_EVENT:
{ {
SpaControlCmdNodeEvent cne; PinosControlCmdNodeEvent cne;
if (spa_connection_parse_cmd (conn, &cne) < 0) if (!pinos_connection_parse_cmd (conn, &cne))
break; break;
handle_node_event (this, cne.event); handle_node_event (this, cne.event);
@ -1139,34 +1135,34 @@ parse_connection (SpaProxy *this)
static SpaResult static SpaResult
parse_rtconnection (SpaProxy *this) parse_rtconnection (SpaProxy *this)
{ {
SpaConnection *conn = this->rtconn; PinosConnection *conn = this->rtconn;
while (spa_connection_has_next (conn) == SPA_RESULT_OK) { while (pinos_connection_has_next (conn)) {
SpaControlCmd cmd = spa_connection_get_cmd (conn); PinosControlCmd cmd = pinos_connection_get_cmd (conn);
switch (cmd) { switch (cmd) {
case SPA_CONTROL_CMD_INVALID: case PINOS_CONTROL_CMD_INVALID:
case SPA_CONTROL_CMD_NODE_UPDATE: case PINOS_CONTROL_CMD_NODE_UPDATE:
case SPA_CONTROL_CMD_PORT_UPDATE: case PINOS_CONTROL_CMD_PORT_UPDATE:
case SPA_CONTROL_CMD_NODE_STATE_CHANGE: case PINOS_CONTROL_CMD_NODE_STATE_CHANGE:
case SPA_CONTROL_CMD_PORT_STATUS_CHANGE: case PINOS_CONTROL_CMD_PORT_STATUS_CHANGE:
case SPA_CONTROL_CMD_ADD_PORT: case PINOS_CONTROL_CMD_ADD_PORT:
case SPA_CONTROL_CMD_REMOVE_PORT: case PINOS_CONTROL_CMD_REMOVE_PORT:
case SPA_CONTROL_CMD_SET_FORMAT: case PINOS_CONTROL_CMD_SET_FORMAT:
case SPA_CONTROL_CMD_SET_PROPERTY: case PINOS_CONTROL_CMD_SET_PROPERTY:
case SPA_CONTROL_CMD_NODE_COMMAND: case PINOS_CONTROL_CMD_NODE_COMMAND:
case SPA_CONTROL_CMD_ADD_MEM: case PINOS_CONTROL_CMD_ADD_MEM:
case SPA_CONTROL_CMD_REMOVE_MEM: case PINOS_CONTROL_CMD_REMOVE_MEM:
case SPA_CONTROL_CMD_USE_BUFFERS: case PINOS_CONTROL_CMD_USE_BUFFERS:
spa_log_error (this->log, "proxy %p: got unexpected connection %d\n", this, cmd); spa_log_error (this->log, "proxy %p: got unexpected connection %d\n", this, cmd);
break; break;
case SPA_CONTROL_CMD_PROCESS_BUFFER: case PINOS_CONTROL_CMD_PROCESS_BUFFER:
{ {
SpaControlCmdProcessBuffer cmd; PinosControlCmdProcessBuffer cmd;
SpaProxyPort *port; SpaProxyPort *port;
if (spa_connection_parse_cmd (conn, &cmd) < 0) if (!pinos_connection_parse_cmd (conn, &cmd))
break; break;
if (!CHECK_PORT (this, cmd.direction, cmd.port_id)) if (!CHECK_PORT (this, cmd.direction, cmd.port_id))
@ -1182,11 +1178,11 @@ parse_rtconnection (SpaProxy *this)
port->buffer_id = cmd.buffer_id; port->buffer_id = cmd.buffer_id;
break; break;
} }
case SPA_CONTROL_CMD_NODE_EVENT: case PINOS_CONTROL_CMD_NODE_EVENT:
{ {
SpaControlCmdNodeEvent cne; PinosControlCmdNodeEvent cne;
if (spa_connection_parse_cmd (conn, &cne) < 0) if (!pinos_connection_parse_cmd (conn, &cne))
break; break;
handle_node_event (this, cne.event); handle_node_event (this, cne.event);
@ -1485,7 +1481,7 @@ pinos_client_node_get_socket_pair (PinosClientNode *this,
goto create_failed; goto create_failed;
priv->proxy->fds[0].fd = g_socket_get_fd (priv->sockets[0]); priv->proxy->fds[0].fd = g_socket_get_fd (priv->sockets[0]);
priv->proxy->conn = spa_connection_new (priv->proxy->fds[0].fd); priv->proxy->conn = pinos_connection_new (priv->proxy->fds[0].fd);
spa_poll_add_item (priv->proxy->main_loop, &priv->proxy->poll); spa_poll_add_item (priv->proxy->main_loop, &priv->proxy->poll);
@ -1543,7 +1539,7 @@ pinos_client_node_get_rtsocket_pair (PinosClientNode *this,
goto create_failed; goto create_failed;
priv->proxy->rtfds[0].fd = g_socket_get_fd (priv->rtsockets[0]); priv->proxy->rtfds[0].fd = g_socket_get_fd (priv->rtsockets[0]);
priv->proxy->rtconn = spa_connection_new (priv->proxy->rtfds[0].fd); priv->proxy->rtconn = pinos_connection_new (priv->proxy->rtfds[0].fd);
spa_poll_add_item (priv->proxy->data_loop, &priv->proxy->rtpoll); spa_poll_add_item (priv->proxy->data_loop, &priv->proxy->rtpoll);
} }