mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-02 09:01:50 -05:00
SpaConnection -> PinosConnection
This commit is contained in:
parent
7ee66cfc35
commit
70fb53cdc6
4 changed files with 458 additions and 474 deletions
|
|
@ -38,7 +38,7 @@ typedef struct {
|
|||
int fds[MAX_FDS];
|
||||
unsigned int n_fds;
|
||||
|
||||
SpaControlCmd cmd;
|
||||
PinosControlCmd cmd;
|
||||
off_t offset;
|
||||
void *data;
|
||||
size_t size;
|
||||
|
|
@ -46,15 +46,15 @@ typedef struct {
|
|||
bool update;
|
||||
} ConnectionBuffer;
|
||||
|
||||
struct _SpaConnection {
|
||||
struct _PinosConnection {
|
||||
ConnectionBuffer in, out;
|
||||
int fd;
|
||||
};
|
||||
|
||||
#if 0
|
||||
#define SPA_DEBUG_CONTROL(format,args...) fprintf(stderr,format,##args)
|
||||
#define PINOS_DEBUG_CONTROL(format,args...) g_debug(format,##args)
|
||||
#else
|
||||
#define SPA_DEBUG_CONTROL(format,args...)
|
||||
#define PINOS_DEBUG_CONTROL(format,args...)
|
||||
#endif
|
||||
|
||||
static bool
|
||||
|
|
@ -80,20 +80,20 @@ read_length (uint8_t * data, unsigned int size, size_t * length, size_t * skip)
|
|||
}
|
||||
|
||||
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)
|
||||
nu->props = spa_serialize_props_deserialize (conn->in.data, SPA_PTR_TO_INT (nu->props));
|
||||
}
|
||||
|
||||
static void
|
||||
connection_parse_port_update (SpaConnection *conn, SpaControlCmdPortUpdate *pu)
|
||||
connection_parse_port_update (PinosConnection *conn, PinosControlCmdPortUpdate *pu)
|
||||
{
|
||||
void *p;
|
||||
unsigned int i;
|
||||
|
||||
memcpy (pu, conn->in.data, sizeof (SpaControlCmdPortUpdate));
|
||||
memcpy (pu, conn->in.data, sizeof (PinosControlCmdPortUpdate));
|
||||
|
||||
p = conn->in.data;
|
||||
|
||||
|
|
@ -115,29 +115,29 @@ connection_parse_port_update (SpaConnection *conn, SpaControlCmdPortUpdate *pu)
|
|||
}
|
||||
|
||||
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)
|
||||
cmd->format = spa_serialize_format_deserialize (conn->in.data, SPA_PTR_TO_INT (cmd->format));
|
||||
}
|
||||
|
||||
static void
|
||||
connection_parse_use_buffers (SpaConnection *conn, SpaControlCmdUseBuffers *cmd)
|
||||
connection_parse_use_buffers (PinosConnection *conn, PinosControlCmdUseBuffers *cmd)
|
||||
{
|
||||
void *p;
|
||||
|
||||
p = conn->in.data;
|
||||
memcpy (cmd, p, sizeof (SpaControlCmdUseBuffers));
|
||||
memcpy (cmd, p, sizeof (PinosControlCmdUseBuffers));
|
||||
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
|
||||
connection_parse_node_event (SpaConnection *conn, SpaControlCmdNodeEvent *cmd)
|
||||
connection_parse_node_event (PinosConnection *conn, PinosControlCmdNodeEvent *cmd)
|
||||
{
|
||||
void *p = conn->in.data;
|
||||
memcpy (cmd, p, sizeof (SpaControlCmdNodeEvent));
|
||||
memcpy (cmd, p, sizeof (PinosControlCmdNodeEvent));
|
||||
if (cmd->event)
|
||||
cmd->event = SPA_MEMBER (p, SPA_PTR_TO_INT (cmd->event), SpaNodeEvent);
|
||||
if (cmd->event->data)
|
||||
|
|
@ -145,31 +145,29 @@ connection_parse_node_event (SpaConnection *conn, SpaControlCmdNodeEvent *cmd)
|
|||
}
|
||||
|
||||
static void
|
||||
connection_parse_node_command (SpaConnection *conn, SpaControlCmdNodeCommand *cmd)
|
||||
connection_parse_node_command (PinosConnection *conn, PinosControlCmdNodeCommand *cmd)
|
||||
{
|
||||
void *p = conn->in.data;
|
||||
memcpy (cmd, p, sizeof (SpaControlCmdNodeCommand));
|
||||
memcpy (cmd, p, sizeof (PinosControlCmdNodeCommand));
|
||||
if (cmd->command)
|
||||
cmd->command = SPA_MEMBER (p, SPA_PTR_TO_INT (cmd->command), SpaNodeCommand);
|
||||
if (cmd->command->data)
|
||||
cmd->command->data = SPA_MEMBER (p, SPA_PTR_TO_INT (cmd->command->data), void);
|
||||
}
|
||||
|
||||
#define MAX(a,b) ((a) > (b) ? (a) : (b))
|
||||
|
||||
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) {
|
||||
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);
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
unsigned int plen;
|
||||
|
|
@ -196,21 +194,21 @@ connection_add_cmd (SpaConnection *conn, SpaControlCmd cmd, size_t size)
|
|||
}
|
||||
|
||||
static void
|
||||
connection_add_node_update (SpaConnection *conn, SpaControlCmdNodeUpdate *nu)
|
||||
connection_add_node_update (PinosConnection *conn, PinosControlCmdNodeUpdate *nu)
|
||||
{
|
||||
size_t len;
|
||||
void *p;
|
||||
SpaControlCmdNodeUpdate *d;
|
||||
PinosControlCmdNodeUpdate *d;
|
||||
|
||||
/* calc len */
|
||||
len = sizeof (SpaControlCmdNodeUpdate);
|
||||
len = sizeof (PinosControlCmdNodeUpdate);
|
||||
len += spa_serialize_props_get_size (nu->props);
|
||||
|
||||
p = connection_add_cmd (conn, SPA_CONTROL_CMD_NODE_UPDATE, len);
|
||||
memcpy (p, nu, sizeof (SpaControlCmdNodeUpdate));
|
||||
p = connection_add_cmd (conn, PINOS_CONTROL_CMD_NODE_UPDATE, len);
|
||||
memcpy (p, nu, sizeof (PinosControlCmdNodeUpdate));
|
||||
d = p;
|
||||
|
||||
p = SPA_MEMBER (d, sizeof (SpaControlCmdNodeUpdate), void);
|
||||
p = SPA_MEMBER (d, sizeof (PinosControlCmdNodeUpdate), void);
|
||||
if (nu->props) {
|
||||
len = spa_serialize_props_serialize (p, nu->props);
|
||||
d->props = SPA_INT_TO_PTR (SPA_PTRDIFF (p, d));
|
||||
|
|
@ -220,16 +218,16 @@ connection_add_node_update (SpaConnection *conn, SpaControlCmdNodeUpdate *nu)
|
|||
}
|
||||
|
||||
static void
|
||||
connection_add_port_update (SpaConnection *conn, SpaControlCmdPortUpdate *pu)
|
||||
connection_add_port_update (PinosConnection *conn, PinosControlCmdPortUpdate *pu)
|
||||
{
|
||||
size_t len;
|
||||
void *p;
|
||||
int i;
|
||||
SpaFormat **bfa;
|
||||
SpaControlCmdPortUpdate *d;
|
||||
PinosControlCmdPortUpdate *d;
|
||||
|
||||
/* calc len */
|
||||
len = sizeof (SpaControlCmdPortUpdate);
|
||||
len = sizeof (PinosControlCmdPortUpdate);
|
||||
len += pu->n_possible_formats * sizeof (SpaFormat *);
|
||||
for (i = 0; i < pu->n_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)
|
||||
len += spa_serialize_port_info_get_size (pu->info);
|
||||
|
||||
p = connection_add_cmd (conn, SPA_CONTROL_CMD_PORT_UPDATE, len);
|
||||
memcpy (p, pu, sizeof (SpaControlCmdPortUpdate));
|
||||
p = connection_add_cmd (conn, PINOS_CONTROL_CMD_PORT_UPDATE, len);
|
||||
memcpy (p, pu, sizeof (PinosControlCmdPortUpdate));
|
||||
d = p;
|
||||
|
||||
p = SPA_MEMBER (d, sizeof (SpaControlCmdPortUpdate), void);
|
||||
p = SPA_MEMBER (d, sizeof (PinosControlCmdPortUpdate), void);
|
||||
bfa = p;
|
||||
if (pu->n_possible_formats)
|
||||
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
|
||||
connection_add_set_format (SpaConnection *conn, SpaControlCmdSetFormat *sf)
|
||||
connection_add_set_format (PinosConnection *conn, PinosControlCmdSetFormat *sf)
|
||||
{
|
||||
size_t len;
|
||||
void *p;
|
||||
|
||||
/* calculate length */
|
||||
/* port_id + format + mask */
|
||||
len = sizeof (SpaControlCmdSetFormat) + spa_serialize_format_get_size (sf->format);
|
||||
p = connection_add_cmd (conn, SPA_CONTROL_CMD_SET_FORMAT, len);
|
||||
memcpy (p, sf, sizeof (SpaControlCmdSetFormat));
|
||||
len = sizeof (PinosControlCmdSetFormat) + spa_serialize_format_get_size (sf->format);
|
||||
p = connection_add_cmd (conn, PINOS_CONTROL_CMD_SET_FORMAT, len);
|
||||
memcpy (p, sf, sizeof (PinosControlCmdSetFormat));
|
||||
sf = p;
|
||||
|
||||
p = SPA_MEMBER (sf, sizeof (SpaControlCmdSetFormat), void);
|
||||
p = SPA_MEMBER (sf, sizeof (PinosControlCmdSetFormat), void);
|
||||
if (sf->format) {
|
||||
len = spa_serialize_format_serialize (p, sf->format);
|
||||
sf->format = SPA_INT_TO_PTR (SPA_PTRDIFF (p, sf));
|
||||
|
|
@ -302,21 +300,21 @@ connection_add_set_format (SpaConnection *conn, SpaControlCmdSetFormat *sf)
|
|||
}
|
||||
|
||||
static void
|
||||
connection_add_use_buffers (SpaConnection *conn, SpaControlCmdUseBuffers *ub)
|
||||
connection_add_use_buffers (PinosConnection *conn, PinosControlCmdUseBuffers *ub)
|
||||
{
|
||||
size_t len;
|
||||
int i;
|
||||
SpaControlCmdUseBuffers *d;
|
||||
SpaControlMemRef *mr;
|
||||
PinosControlCmdUseBuffers *d;
|
||||
PinosControlMemRef *mr;
|
||||
|
||||
/* calculate length */
|
||||
len = sizeof (SpaControlCmdUseBuffers);
|
||||
len += ub->n_buffers * sizeof (SpaControlMemRef);
|
||||
len = sizeof (PinosControlCmdUseBuffers);
|
||||
len += ub->n_buffers * sizeof (PinosControlMemRef);
|
||||
|
||||
d = connection_add_cmd (conn, SPA_CONTROL_CMD_USE_BUFFERS, len);
|
||||
memcpy (d, ub, sizeof (SpaControlCmdUseBuffers));
|
||||
d = connection_add_cmd (conn, PINOS_CONTROL_CMD_USE_BUFFERS, len);
|
||||
memcpy (d, ub, sizeof (PinosControlCmdUseBuffers));
|
||||
|
||||
mr = SPA_MEMBER (d, sizeof (SpaControlCmdUseBuffers), void);
|
||||
mr = SPA_MEMBER (d, sizeof (PinosControlCmdUseBuffers), void);
|
||||
|
||||
if (d->n_buffers)
|
||||
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;
|
||||
|
||||
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
|
||||
connection_add_node_event (SpaConnection *conn, SpaControlCmdNodeEvent *ev)
|
||||
connection_add_node_event (PinosConnection *conn, PinosControlCmdNodeEvent *ev)
|
||||
{
|
||||
size_t len;
|
||||
void *p;
|
||||
SpaControlCmdNodeEvent *d;
|
||||
PinosControlCmdNodeEvent *d;
|
||||
SpaNodeEvent *ne;
|
||||
|
||||
/* calculate length */
|
||||
len = sizeof (SpaControlCmdNodeEvent);
|
||||
len = sizeof (PinosControlCmdNodeEvent);
|
||||
len += sizeof (SpaNodeEvent);
|
||||
len += ev->event->size;
|
||||
|
||||
p = connection_add_cmd (conn, SPA_CONTROL_CMD_NODE_EVENT, len);
|
||||
memcpy (p, ev, sizeof (SpaControlCmdNodeEvent));
|
||||
p = connection_add_cmd (conn, PINOS_CONTROL_CMD_NODE_EVENT, len);
|
||||
memcpy (p, ev, sizeof (PinosControlCmdNodeEvent));
|
||||
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));
|
||||
|
||||
ne = p;
|
||||
|
|
@ -356,23 +354,23 @@ connection_add_node_event (SpaConnection *conn, SpaControlCmdNodeEvent *ev)
|
|||
|
||||
|
||||
static void
|
||||
connection_add_node_command (SpaConnection *conn, SpaControlCmdNodeCommand *cm)
|
||||
connection_add_node_command (PinosConnection *conn, PinosControlCmdNodeCommand *cm)
|
||||
{
|
||||
size_t len;
|
||||
void *p;
|
||||
SpaControlCmdNodeCommand *d;
|
||||
PinosControlCmdNodeCommand *d;
|
||||
SpaNodeCommand *nc;
|
||||
|
||||
/* calculate length */
|
||||
len = sizeof (SpaControlCmdNodeCommand);
|
||||
len = sizeof (PinosControlCmdNodeCommand);
|
||||
len += sizeof (SpaNodeCommand);
|
||||
len += cm->command->size;
|
||||
|
||||
p = connection_add_cmd (conn, SPA_CONTROL_CMD_NODE_COMMAND, len);
|
||||
memcpy (p, cm, sizeof (SpaControlCmdNodeCommand));
|
||||
p = connection_add_cmd (conn, PINOS_CONTROL_CMD_NODE_COMMAND, len);
|
||||
memcpy (p, cm, sizeof (PinosControlCmdNodeCommand));
|
||||
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));
|
||||
|
||||
nc = p;
|
||||
|
|
@ -382,8 +380,8 @@ connection_add_node_command (SpaConnection *conn, SpaControlCmdNodeCommand *cm)
|
|||
memcpy (p, cm->command->data, cm->command->size);
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
refill_buffer (SpaConnection *conn, ConnectionBuffer *buf)
|
||||
static gboolean
|
||||
refill_buffer (PinosConnection *conn, ConnectionBuffer *buf)
|
||||
{
|
||||
ssize_t len;
|
||||
struct cmsghdr *cmsg;
|
||||
|
|
@ -411,7 +409,7 @@ refill_buffer (SpaConnection *conn, ConnectionBuffer *buf)
|
|||
}
|
||||
|
||||
if (len < 4)
|
||||
return SPA_RESULT_ERROR;
|
||||
return FALSE;
|
||||
|
||||
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);
|
||||
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 */
|
||||
recv_error:
|
||||
{
|
||||
fprintf (stderr, "could not recvmsg on fd %d: %s\n", conn->fd, strerror (errno));
|
||||
return SPA_RESULT_ERROR;
|
||||
g_warning ("could not recvmsg on fd %d: %s\n", conn->fd, strerror (errno));
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -447,18 +445,18 @@ clear_buffer (ConnectionBuffer *buf)
|
|||
}
|
||||
}
|
||||
buf->n_fds = 0;
|
||||
buf->cmd = SPA_CONTROL_CMD_INVALID;
|
||||
buf->cmd = PINOS_CONTROL_CMD_INVALID;
|
||||
buf->offset = 0;
|
||||
buf->size = 0;
|
||||
buf->buffer_size = 0;
|
||||
}
|
||||
|
||||
SpaConnection *
|
||||
spa_connection_new (int fd)
|
||||
PinosConnection *
|
||||
pinos_connection_new (int fd)
|
||||
{
|
||||
SpaConnection *c;
|
||||
PinosConnection *c;
|
||||
|
||||
c = calloc (1, sizeof (SpaConnection));
|
||||
c = calloc (1, sizeof (PinosConnection));
|
||||
c->fd = fd;
|
||||
c->out.buffer_data = malloc (MAX_BUFFER_SIZE);
|
||||
c->out.buffer_maxsize = MAX_BUFFER_SIZE;
|
||||
|
|
@ -470,7 +468,7 @@ spa_connection_new (int fd)
|
|||
}
|
||||
|
||||
void
|
||||
spa_connection_free (SpaConnection *conn)
|
||||
pinos_connection_free (PinosConnection *conn)
|
||||
{
|
||||
free (conn->out.buffer_data);
|
||||
free (conn->in.buffer_data);
|
||||
|
|
@ -478,22 +476,21 @@ spa_connection_free (SpaConnection *conn)
|
|||
}
|
||||
|
||||
/**
|
||||
* spa_connection_has_next:
|
||||
* @iter: a #SpaConnection
|
||||
* pinos_connection_has_next:
|
||||
* @iter: a #PinosConnection
|
||||
*
|
||||
* Move to the next packet in @conn.
|
||||
*
|
||||
* Returns: %SPA_RESULT_OK if more packets are available.
|
||||
* Returns: %TRUE if more packets are available.
|
||||
*/
|
||||
SpaResult
|
||||
spa_connection_has_next (SpaConnection *conn)
|
||||
gboolean
|
||||
pinos_connection_has_next (PinosConnection *conn)
|
||||
{
|
||||
size_t len, size, skip;
|
||||
uint8_t *data;
|
||||
ConnectionBuffer *buf;
|
||||
|
||||
if (conn == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
g_return_val_if_fail (conn != NULL, FALSE);
|
||||
|
||||
buf = &conn->in;
|
||||
|
||||
|
|
@ -513,7 +510,7 @@ again:
|
|||
if (buf->offset >= size) {
|
||||
clear_buffer (buf);
|
||||
buf->update = true;
|
||||
return SPA_RESULT_ERROR;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
data += buf->offset;
|
||||
|
|
@ -532,108 +529,104 @@ again:
|
|||
buf->data = data + skip;
|
||||
buf->offset += 1 + skip;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
SpaControlCmd
|
||||
spa_connection_get_cmd (SpaConnection *conn)
|
||||
PinosControlCmd
|
||||
pinos_connection_get_cmd (PinosConnection *conn)
|
||||
{
|
||||
if (conn == NULL)
|
||||
return SPA_CONTROL_CMD_INVALID;
|
||||
g_return_val_if_fail (conn != NULL, PINOS_CONTROL_CMD_INVALID);
|
||||
|
||||
return conn->in.cmd;
|
||||
}
|
||||
|
||||
SpaResult
|
||||
spa_connection_parse_cmd (SpaConnection *conn,
|
||||
void *command)
|
||||
gboolean
|
||||
pinos_connection_parse_cmd (PinosConnection *conn,
|
||||
gpointer command)
|
||||
{
|
||||
SpaResult res = SPA_RESULT_OK;
|
||||
|
||||
if (conn == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
g_return_val_if_fail (conn != NULL, FALSE);
|
||||
|
||||
switch (conn->in.cmd) {
|
||||
/* C -> S */
|
||||
case SPA_CONTROL_CMD_NODE_UPDATE:
|
||||
case PINOS_CONTROL_CMD_NODE_UPDATE:
|
||||
connection_parse_node_update (conn, command);
|
||||
break;
|
||||
|
||||
case SPA_CONTROL_CMD_PORT_UPDATE:
|
||||
case PINOS_CONTROL_CMD_PORT_UPDATE:
|
||||
connection_parse_port_update (conn, command);
|
||||
break;
|
||||
|
||||
case SPA_CONTROL_CMD_PORT_STATUS_CHANGE:
|
||||
fprintf (stderr, "implement iter of %d\n", conn->in.cmd);
|
||||
case PINOS_CONTROL_CMD_PORT_STATUS_CHANGE:
|
||||
g_warning ("implement iter of %d\n", conn->in.cmd);
|
||||
break;
|
||||
|
||||
case SPA_CONTROL_CMD_NODE_STATE_CHANGE:
|
||||
if (conn->in.size < sizeof (SpaControlCmdNodeStateChange))
|
||||
return SPA_RESULT_ERROR;
|
||||
memcpy (command, conn->in.data, sizeof (SpaControlCmdNodeStateChange));
|
||||
case PINOS_CONTROL_CMD_NODE_STATE_CHANGE:
|
||||
if (conn->in.size < sizeof (PinosControlCmdNodeStateChange))
|
||||
return FALSE;
|
||||
memcpy (command, conn->in.data, sizeof (PinosControlCmdNodeStateChange));
|
||||
break;
|
||||
|
||||
/* S -> C */
|
||||
case SPA_CONTROL_CMD_ADD_PORT:
|
||||
if (conn->in.size < sizeof (SpaControlCmdAddPort))
|
||||
return SPA_RESULT_ERROR;
|
||||
memcpy (command, conn->in.data, sizeof (SpaControlCmdAddPort));
|
||||
case PINOS_CONTROL_CMD_ADD_PORT:
|
||||
if (conn->in.size < sizeof (PinosControlCmdAddPort))
|
||||
return FALSE;
|
||||
memcpy (command, conn->in.data, sizeof (PinosControlCmdAddPort));
|
||||
break;
|
||||
|
||||
case SPA_CONTROL_CMD_REMOVE_PORT:
|
||||
if (conn->in.size < sizeof (SpaControlCmdRemovePort))
|
||||
return SPA_RESULT_ERROR;
|
||||
memcpy (command, conn->in.data, sizeof (SpaControlCmdRemovePort));
|
||||
case PINOS_CONTROL_CMD_REMOVE_PORT:
|
||||
if (conn->in.size < sizeof (PinosControlCmdRemovePort))
|
||||
return FALSE;
|
||||
memcpy (command, conn->in.data, sizeof (PinosControlCmdRemovePort));
|
||||
break;
|
||||
|
||||
case SPA_CONTROL_CMD_SET_FORMAT:
|
||||
case PINOS_CONTROL_CMD_SET_FORMAT:
|
||||
connection_parse_set_format (conn, command);
|
||||
break;
|
||||
|
||||
case SPA_CONTROL_CMD_SET_PROPERTY:
|
||||
fprintf (stderr, "implement iter of %d\n", conn->in.cmd);
|
||||
case PINOS_CONTROL_CMD_SET_PROPERTY:
|
||||
g_warning ("implement iter of %d\n", conn->in.cmd);
|
||||
break;
|
||||
|
||||
/* bidirectional */
|
||||
case SPA_CONTROL_CMD_ADD_MEM:
|
||||
if (conn->in.size < sizeof (SpaControlCmdAddMem))
|
||||
return SPA_RESULT_ERROR;
|
||||
memcpy (command, conn->in.data, sizeof (SpaControlCmdAddMem));
|
||||
case PINOS_CONTROL_CMD_ADD_MEM:
|
||||
if (conn->in.size < sizeof (PinosControlCmdAddMem))
|
||||
return FALSE;
|
||||
memcpy (command, conn->in.data, sizeof (PinosControlCmdAddMem));
|
||||
break;
|
||||
|
||||
case SPA_CONTROL_CMD_REMOVE_MEM:
|
||||
if (conn->in.size < sizeof (SpaControlCmdRemoveMem))
|
||||
return SPA_RESULT_ERROR;
|
||||
memcpy (command, conn->in.data, sizeof (SpaControlCmdRemoveMem));
|
||||
case PINOS_CONTROL_CMD_REMOVE_MEM:
|
||||
if (conn->in.size < sizeof (PinosControlCmdRemoveMem))
|
||||
return FALSE;
|
||||
memcpy (command, conn->in.data, sizeof (PinosControlCmdRemoveMem));
|
||||
break;
|
||||
|
||||
case SPA_CONTROL_CMD_USE_BUFFERS:
|
||||
case PINOS_CONTROL_CMD_USE_BUFFERS:
|
||||
connection_parse_use_buffers (conn, command);
|
||||
break;
|
||||
|
||||
case SPA_CONTROL_CMD_PROCESS_BUFFER:
|
||||
if (conn->in.size < sizeof (SpaControlCmdProcessBuffer))
|
||||
return SPA_RESULT_ERROR;
|
||||
memcpy (command, conn->in.data, sizeof (SpaControlCmdProcessBuffer));
|
||||
case PINOS_CONTROL_CMD_PROCESS_BUFFER:
|
||||
if (conn->in.size < sizeof (PinosControlCmdProcessBuffer))
|
||||
return FALSE;
|
||||
memcpy (command, conn->in.data, sizeof (PinosControlCmdProcessBuffer));
|
||||
break;
|
||||
|
||||
case SPA_CONTROL_CMD_NODE_EVENT:
|
||||
case PINOS_CONTROL_CMD_NODE_EVENT:
|
||||
connection_parse_node_event (conn, command);
|
||||
break;
|
||||
|
||||
case SPA_CONTROL_CMD_NODE_COMMAND:
|
||||
case PINOS_CONTROL_CMD_NODE_COMMAND:
|
||||
connection_parse_node_command (conn, command);
|
||||
break;
|
||||
|
||||
case SPA_CONTROL_CMD_INVALID:
|
||||
return SPA_RESULT_ERROR;
|
||||
case PINOS_CONTROL_CMD_INVALID:
|
||||
return FALSE;
|
||||
}
|
||||
return res;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* spa_connection_get_fd:
|
||||
* @conn: a #SpaConnection
|
||||
* pinos_connection_get_fd:
|
||||
* @conn: a #PinosConnection
|
||||
* @index: an index
|
||||
* @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.
|
||||
*/
|
||||
int
|
||||
spa_connection_get_fd (SpaConnection *conn,
|
||||
unsigned int index,
|
||||
bool close)
|
||||
pinos_connection_get_fd (PinosConnection *conn,
|
||||
guint index,
|
||||
gboolean close)
|
||||
{
|
||||
int fd;
|
||||
|
||||
if (conn == NULL || conn->in.n_fds < index)
|
||||
return -1;
|
||||
g_return_val_if_fail (conn != NULL, -1);
|
||||
g_return_val_if_fail (index < conn->in.n_fds, -1);
|
||||
|
||||
fd = conn->in.fds[index];
|
||||
if (fd < 0)
|
||||
|
|
@ -661,8 +654,8 @@ spa_connection_get_fd (SpaConnection *conn,
|
|||
}
|
||||
|
||||
/**
|
||||
* spa_connection_add_fd:
|
||||
* @conn: a #SpaConnection
|
||||
* pinos_connection_add_fd:
|
||||
* @conn: a #PinosConnection
|
||||
* @fd: a valid fd
|
||||
* @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.
|
||||
*/
|
||||
int
|
||||
spa_connection_add_fd (SpaConnection *conn,
|
||||
int fd,
|
||||
bool close)
|
||||
pinos_connection_add_fd (PinosConnection *conn,
|
||||
int fd,
|
||||
gboolean close)
|
||||
{
|
||||
int index, i;
|
||||
|
||||
if (conn == NULL)
|
||||
return -1;
|
||||
g_return_val_if_fail (conn != NULL, -1);
|
||||
|
||||
for (i = 0; i < conn->out.n_fds; i++) {
|
||||
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:
|
||||
* @conn: a #SpaConnection
|
||||
* @cmd: a #SpaControlCmd
|
||||
* pinos_connection_add_cmd:
|
||||
* @conn: a #PinosConnection
|
||||
* @cmd: a #PinosControlCmd
|
||||
* @command: a command
|
||||
*
|
||||
* Add a @cmd to @conn with data from @command.
|
||||
*
|
||||
* Returns: %SPA_RESULT_OK on success.
|
||||
* Returns: %TRUE on success.
|
||||
*/
|
||||
SpaResult
|
||||
spa_connection_add_cmd (SpaConnection *conn,
|
||||
SpaControlCmd cmd,
|
||||
void *command)
|
||||
gboolean
|
||||
pinos_connection_add_cmd (PinosConnection *conn,
|
||||
PinosControlCmd cmd,
|
||||
gpointer command)
|
||||
{
|
||||
void *p;
|
||||
|
||||
if (conn == NULL || command == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
g_return_val_if_fail (conn != NULL, FALSE);
|
||||
g_return_val_if_fail (command != NULL, FALSE);
|
||||
|
||||
switch (cmd) {
|
||||
/* C -> S */
|
||||
case SPA_CONTROL_CMD_NODE_UPDATE:
|
||||
case PINOS_CONTROL_CMD_NODE_UPDATE:
|
||||
connection_add_node_update (conn, command);
|
||||
break;
|
||||
|
||||
case SPA_CONTROL_CMD_PORT_UPDATE:
|
||||
case PINOS_CONTROL_CMD_PORT_UPDATE:
|
||||
connection_add_port_update (conn, command);
|
||||
break;
|
||||
|
||||
case SPA_CONTROL_CMD_PORT_STATUS_CHANGE:
|
||||
case PINOS_CONTROL_CMD_PORT_STATUS_CHANGE:
|
||||
p = connection_add_cmd (conn, cmd, 0);
|
||||
break;
|
||||
|
||||
case SPA_CONTROL_CMD_NODE_STATE_CHANGE:
|
||||
p = connection_add_cmd (conn, cmd, sizeof (SpaControlCmdNodeStateChange));
|
||||
memcpy (p, command, sizeof (SpaControlCmdNodeStateChange));
|
||||
case PINOS_CONTROL_CMD_NODE_STATE_CHANGE:
|
||||
p = connection_add_cmd (conn, cmd, sizeof (PinosControlCmdNodeStateChange));
|
||||
memcpy (p, command, sizeof (PinosControlCmdNodeStateChange));
|
||||
break;
|
||||
|
||||
/* S -> C */
|
||||
case SPA_CONTROL_CMD_ADD_PORT:
|
||||
p = connection_add_cmd (conn, cmd, sizeof (SpaControlCmdAddPort));
|
||||
memcpy (p, command, sizeof (SpaControlCmdAddPort));
|
||||
case PINOS_CONTROL_CMD_ADD_PORT:
|
||||
p = connection_add_cmd (conn, cmd, sizeof (PinosControlCmdAddPort));
|
||||
memcpy (p, command, sizeof (PinosControlCmdAddPort));
|
||||
break;
|
||||
|
||||
case SPA_CONTROL_CMD_REMOVE_PORT:
|
||||
p = connection_add_cmd (conn, cmd, sizeof (SpaControlCmdRemovePort));
|
||||
memcpy (p, command, sizeof (SpaControlCmdRemovePort));
|
||||
case PINOS_CONTROL_CMD_REMOVE_PORT:
|
||||
p = connection_add_cmd (conn, cmd, sizeof (PinosControlCmdRemovePort));
|
||||
memcpy (p, command, sizeof (PinosControlCmdRemovePort));
|
||||
break;
|
||||
|
||||
case SPA_CONTROL_CMD_SET_FORMAT:
|
||||
case PINOS_CONTROL_CMD_SET_FORMAT:
|
||||
connection_add_set_format (conn, command);
|
||||
break;
|
||||
|
||||
case SPA_CONTROL_CMD_SET_PROPERTY:
|
||||
fprintf (stderr, "implement builder of %d\n", cmd);
|
||||
case PINOS_CONTROL_CMD_SET_PROPERTY:
|
||||
g_warning ("implement builder of %d\n", cmd);
|
||||
break;
|
||||
|
||||
/* bidirectional */
|
||||
case SPA_CONTROL_CMD_ADD_MEM:
|
||||
p = connection_add_cmd (conn, cmd, sizeof (SpaControlCmdAddMem));
|
||||
memcpy (p, command, sizeof (SpaControlCmdAddMem));
|
||||
case PINOS_CONTROL_CMD_ADD_MEM:
|
||||
p = connection_add_cmd (conn, cmd, sizeof (PinosControlCmdAddMem));
|
||||
memcpy (p, command, sizeof (PinosControlCmdAddMem));
|
||||
break;
|
||||
|
||||
case SPA_CONTROL_CMD_REMOVE_MEM:
|
||||
p = connection_add_cmd (conn, cmd, sizeof (SpaControlCmdRemoveMem));
|
||||
memcpy (p, command, sizeof (SpaControlCmdRemoveMem));
|
||||
case PINOS_CONTROL_CMD_REMOVE_MEM:
|
||||
p = connection_add_cmd (conn, cmd, sizeof (PinosControlCmdRemoveMem));
|
||||
memcpy (p, command, sizeof (PinosControlCmdRemoveMem));
|
||||
break;
|
||||
|
||||
case SPA_CONTROL_CMD_USE_BUFFERS:
|
||||
case PINOS_CONTROL_CMD_USE_BUFFERS:
|
||||
connection_add_use_buffers (conn, command);
|
||||
break;
|
||||
|
||||
case SPA_CONTROL_CMD_PROCESS_BUFFER:
|
||||
p = connection_add_cmd (conn, cmd, sizeof (SpaControlCmdProcessBuffer));
|
||||
memcpy (p, command, sizeof (SpaControlCmdProcessBuffer));
|
||||
case PINOS_CONTROL_CMD_PROCESS_BUFFER:
|
||||
p = connection_add_cmd (conn, cmd, sizeof (PinosControlCmdProcessBuffer));
|
||||
memcpy (p, command, sizeof (PinosControlCmdProcessBuffer));
|
||||
break;
|
||||
|
||||
case SPA_CONTROL_CMD_NODE_EVENT:
|
||||
case PINOS_CONTROL_CMD_NODE_EVENT:
|
||||
connection_add_node_event (conn, command);
|
||||
break;
|
||||
|
||||
case SPA_CONTROL_CMD_NODE_COMMAND:
|
||||
case PINOS_CONTROL_CMD_NODE_COMMAND:
|
||||
connection_add_node_command (conn, command);
|
||||
break;
|
||||
|
||||
case SPA_CONTROL_CMD_INVALID:
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
case PINOS_CONTROL_CMD_INVALID:
|
||||
return FALSE;
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
SpaResult
|
||||
spa_connection_flush (SpaConnection *conn)
|
||||
gboolean
|
||||
pinos_connection_flush (PinosConnection *conn)
|
||||
{
|
||||
ssize_t len;
|
||||
struct msghdr msg = {0};
|
||||
|
|
@ -795,13 +787,12 @@ spa_connection_flush (SpaConnection *conn)
|
|||
int *cm, i, fds_len;
|
||||
ConnectionBuffer *buf;
|
||||
|
||||
if (conn == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
g_return_val_if_fail (conn != NULL, FALSE);
|
||||
|
||||
buf = &conn->out;
|
||||
|
||||
if (buf->buffer_size == 0)
|
||||
return SPA_RESULT_OK;
|
||||
return TRUE;
|
||||
|
||||
fds_len = buf->n_fds * sizeof (int);
|
||||
|
||||
|
|
@ -839,27 +830,26 @@ spa_connection_flush (SpaConnection *conn)
|
|||
buf->buffer_size -= len;
|
||||
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 */
|
||||
send_error:
|
||||
{
|
||||
fprintf (stderr, "could not sendmsg: %s\n", strerror (errno));
|
||||
return SPA_RESULT_ERROR;
|
||||
g_warning ("could not sendmsg: %s\n", strerror (errno));
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
SpaResult
|
||||
spa_connection_clear (SpaConnection *conn)
|
||||
gboolean
|
||||
pinos_connection_clear (PinosConnection *conn)
|
||||
{
|
||||
if (conn == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
g_return_val_if_fail (conn != NULL, FALSE);
|
||||
|
||||
clear_buffer (&conn->out);
|
||||
clear_buffer (&conn->in);
|
||||
conn->in.update = true;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,12 +17,12 @@
|
|||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __SPA_CONTROL_H__
|
||||
#define __SPA_CONTROL_H__
|
||||
#ifndef __PINOS_CONTROL_H__
|
||||
#define __PINOS_CONTROL_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#include <glib-object.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#include <spa/defs.h>
|
||||
#include <spa/props.h>
|
||||
|
|
@ -30,95 +30,95 @@ extern "C" {
|
|||
#include <spa/port.h>
|
||||
#include <spa/node.h>
|
||||
|
||||
typedef struct _SpaConnection SpaConnection;
|
||||
typedef struct _PinosConnection PinosConnection;
|
||||
|
||||
typedef enum {
|
||||
SPA_CONTROL_CMD_INVALID = 0,
|
||||
PINOS_CONTROL_CMD_INVALID = 0,
|
||||
/* client to server */
|
||||
SPA_CONTROL_CMD_NODE_UPDATE = 1,
|
||||
SPA_CONTROL_CMD_PORT_UPDATE = 2,
|
||||
SPA_CONTROL_CMD_NODE_STATE_CHANGE = 3,
|
||||
PINOS_CONTROL_CMD_NODE_UPDATE = 1,
|
||||
PINOS_CONTROL_CMD_PORT_UPDATE = 2,
|
||||
PINOS_CONTROL_CMD_NODE_STATE_CHANGE = 3,
|
||||
|
||||
SPA_CONTROL_CMD_PORT_STATUS_CHANGE = 4,
|
||||
PINOS_CONTROL_CMD_PORT_STATUS_CHANGE = 4,
|
||||
|
||||
/* server to client */
|
||||
SPA_CONTROL_CMD_ADD_PORT = 32,
|
||||
SPA_CONTROL_CMD_REMOVE_PORT = 33,
|
||||
PINOS_CONTROL_CMD_ADD_PORT = 32,
|
||||
PINOS_CONTROL_CMD_REMOVE_PORT = 33,
|
||||
|
||||
SPA_CONTROL_CMD_SET_FORMAT = 34,
|
||||
SPA_CONTROL_CMD_SET_PROPERTY = 35,
|
||||
PINOS_CONTROL_CMD_SET_FORMAT = 34,
|
||||
PINOS_CONTROL_CMD_SET_PROPERTY = 35,
|
||||
|
||||
SPA_CONTROL_CMD_NODE_COMMAND = 36,
|
||||
PINOS_CONTROL_CMD_NODE_COMMAND = 36,
|
||||
|
||||
/* both */
|
||||
SPA_CONTROL_CMD_ADD_MEM = 64,
|
||||
SPA_CONTROL_CMD_REMOVE_MEM = 65,
|
||||
PINOS_CONTROL_CMD_ADD_MEM = 64,
|
||||
PINOS_CONTROL_CMD_REMOVE_MEM = 65,
|
||||
|
||||
SPA_CONTROL_CMD_USE_BUFFERS = 66,
|
||||
SPA_CONTROL_CMD_PROCESS_BUFFER = 67,
|
||||
PINOS_CONTROL_CMD_USE_BUFFERS = 66,
|
||||
PINOS_CONTROL_CMD_PROCESS_BUFFER = 67,
|
||||
|
||||
SPA_CONTROL_CMD_NODE_EVENT = 68,
|
||||
} SpaControlCmd;
|
||||
PINOS_CONTROL_CMD_NODE_EVENT = 68,
|
||||
} PinosControlCmd;
|
||||
|
||||
/* SPA_CONTROL_CMD_NODE_UPDATE */
|
||||
/* PINOS_CONTROL_CMD_NODE_UPDATE */
|
||||
typedef struct {
|
||||
#define SPA_CONTROL_CMD_NODE_UPDATE_MAX_INPUTS (1 << 0)
|
||||
#define SPA_CONTROL_CMD_NODE_UPDATE_MAX_OUTPUTS (1 << 1)
|
||||
#define SPA_CONTROL_CMD_NODE_UPDATE_PROPS (1 << 2)
|
||||
#define PINOS_CONTROL_CMD_NODE_UPDATE_MAX_INPUTS (1 << 0)
|
||||
#define PINOS_CONTROL_CMD_NODE_UPDATE_MAX_OUTPUTS (1 << 1)
|
||||
#define PINOS_CONTROL_CMD_NODE_UPDATE_PROPS (1 << 2)
|
||||
uint32_t change_mask;
|
||||
unsigned int max_input_ports;
|
||||
unsigned int max_output_ports;
|
||||
const SpaProps *props;
|
||||
} SpaControlCmdNodeUpdate;
|
||||
} PinosControlCmdNodeUpdate;
|
||||
|
||||
/* SPA_CONTROL_CMD_PORT_UPDATE */
|
||||
/* PINOS_CONTROL_CMD_PORT_UPDATE */
|
||||
typedef struct {
|
||||
SpaDirection direction;
|
||||
uint32_t port_id;
|
||||
#define SPA_CONTROL_CMD_PORT_UPDATE_POSSIBLE_FORMATS (1 << 0)
|
||||
#define SPA_CONTROL_CMD_PORT_UPDATE_FORMAT (1 << 1)
|
||||
#define SPA_CONTROL_CMD_PORT_UPDATE_PROPS (1 << 2)
|
||||
#define SPA_CONTROL_CMD_PORT_UPDATE_INFO (1 << 3)
|
||||
#define PINOS_CONTROL_CMD_PORT_UPDATE_POSSIBLE_FORMATS (1 << 0)
|
||||
#define PINOS_CONTROL_CMD_PORT_UPDATE_FORMAT (1 << 1)
|
||||
#define PINOS_CONTROL_CMD_PORT_UPDATE_PROPS (1 << 2)
|
||||
#define PINOS_CONTROL_CMD_PORT_UPDATE_INFO (1 << 3)
|
||||
uint32_t change_mask;
|
||||
unsigned int n_possible_formats;
|
||||
SpaFormat **possible_formats;
|
||||
SpaFormat *format;
|
||||
const SpaProps *props;
|
||||
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 {
|
||||
SpaNodeState state;
|
||||
} SpaControlCmdNodeStateChange;
|
||||
} PinosControlCmdNodeStateChange;
|
||||
|
||||
/* SPA_CONTROL_CMD_ADD_PORT */
|
||||
/* PINOS_CONTROL_CMD_ADD_PORT */
|
||||
typedef struct {
|
||||
uint32_t seq;
|
||||
SpaDirection direction;
|
||||
uint32_t port_id;
|
||||
} SpaControlCmdAddPort;
|
||||
} PinosControlCmdAddPort;
|
||||
|
||||
/* SPA_CONTROL_CMD_REMOVE_PORT */
|
||||
/* PINOS_CONTROL_CMD_REMOVE_PORT */
|
||||
typedef struct {
|
||||
uint32_t seq;
|
||||
SpaDirection direction;
|
||||
uint32_t port_id;
|
||||
} SpaControlCmdRemovePort;
|
||||
} PinosControlCmdRemovePort;
|
||||
|
||||
|
||||
/* SPA_CONTROL_CMD_SET_FORMAT */
|
||||
/* PINOS_CONTROL_CMD_SET_FORMAT */
|
||||
typedef struct {
|
||||
uint32_t seq;
|
||||
SpaDirection direction;
|
||||
uint32_t port_id;
|
||||
SpaPortFormatFlags flags;
|
||||
SpaFormat *format;
|
||||
} SpaControlCmdSetFormat;
|
||||
} PinosControlCmdSetFormat;
|
||||
|
||||
/* SPA_CONTROL_CMD_SET_PROPERTY */
|
||||
/* PINOS_CONTROL_CMD_SET_PROPERTY */
|
||||
typedef struct {
|
||||
uint32_t seq;
|
||||
SpaDirection direction;
|
||||
|
|
@ -126,15 +126,15 @@ typedef struct {
|
|||
uint32_t id;
|
||||
size_t size;
|
||||
void *value;
|
||||
} SpaControlCmdSetProperty;
|
||||
} PinosControlCmdSetProperty;
|
||||
|
||||
/* SPA_CONTROL_CMD_NODE_COMMAND */
|
||||
/* PINOS_CONTROL_CMD_NODE_COMMAND */
|
||||
typedef struct {
|
||||
uint32_t seq;
|
||||
SpaNodeCommand *command;
|
||||
} SpaControlCmdNodeCommand;
|
||||
} PinosControlCmdNodeCommand;
|
||||
|
||||
/* SPA_CONTROL_CMD_ADD_MEM */
|
||||
/* PINOS_CONTROL_CMD_ADD_MEM */
|
||||
typedef struct {
|
||||
SpaDirection direction;
|
||||
uint32_t port_id;
|
||||
|
|
@ -144,66 +144,64 @@ typedef struct {
|
|||
uint32_t flags;
|
||||
off_t offset;
|
||||
size_t size;
|
||||
} SpaControlCmdAddMem;
|
||||
} PinosControlCmdAddMem;
|
||||
|
||||
/* SPA_CONTROL_CMD_REMOVE_MEM */
|
||||
/* PINOS_CONTROL_CMD_REMOVE_MEM */
|
||||
typedef struct {
|
||||
SpaDirection direction;
|
||||
uint32_t port_id;
|
||||
uint32_t mem_id;
|
||||
} SpaControlCmdRemoveMem;
|
||||
} PinosControlCmdRemoveMem;
|
||||
|
||||
typedef struct {
|
||||
uint32_t mem_id;
|
||||
off_t offset;
|
||||
size_t size;
|
||||
} SpaControlMemRef;
|
||||
} PinosControlMemRef;
|
||||
|
||||
/* SPA_CONTROL_CMD_USE_BUFFERS */
|
||||
/* PINOS_CONTROL_CMD_USE_BUFFERS */
|
||||
typedef struct {
|
||||
uint32_t seq;
|
||||
SpaDirection direction;
|
||||
uint32_t port_id;
|
||||
unsigned int n_buffers;
|
||||
SpaControlMemRef *buffers;
|
||||
} SpaControlCmdUseBuffers;
|
||||
uint32_t seq;
|
||||
SpaDirection direction;
|
||||
uint32_t port_id;
|
||||
unsigned int n_buffers;
|
||||
PinosControlMemRef *buffers;
|
||||
} PinosControlCmdUseBuffers;
|
||||
|
||||
/* SPA_CONTROL_CMD_PROCESS_BUFFER */
|
||||
/* PINOS_CONTROL_CMD_PROCESS_BUFFER */
|
||||
typedef struct {
|
||||
SpaDirection direction;
|
||||
uint32_t port_id;
|
||||
uint32_t buffer_id;
|
||||
} SpaControlCmdProcessBuffer;
|
||||
} PinosControlCmdProcessBuffer;
|
||||
|
||||
/* SPA_CONTROL_CMD_NODE_EVENT */
|
||||
/* PINOS_CONTROL_CMD_NODE_EVENT */
|
||||
typedef struct {
|
||||
SpaNodeEvent *event;
|
||||
} SpaControlCmdNodeEvent;
|
||||
} PinosControlCmdNodeEvent;
|
||||
|
||||
|
||||
SpaConnection * spa_connection_new (int fd);
|
||||
void spa_connection_free (SpaConnection *conn);
|
||||
PinosConnection * pinos_connection_new (int fd);
|
||||
void pinos_connection_free (PinosConnection *conn);
|
||||
|
||||
SpaResult spa_connection_has_next (SpaConnection *conn);
|
||||
SpaControlCmd spa_connection_get_cmd (SpaConnection *conn);
|
||||
SpaResult spa_connection_parse_cmd (SpaConnection *conn,
|
||||
void *command);
|
||||
int spa_connection_get_fd (SpaConnection *conn,
|
||||
unsigned int index,
|
||||
bool close);
|
||||
gboolean pinos_connection_has_next (PinosConnection *conn);
|
||||
PinosControlCmd pinos_connection_get_cmd (PinosConnection *conn);
|
||||
gboolean pinos_connection_parse_cmd (PinosConnection *conn,
|
||||
gpointer command);
|
||||
int pinos_connection_get_fd (PinosConnection *conn,
|
||||
guint index,
|
||||
gboolean close);
|
||||
|
||||
int spa_connection_add_fd (SpaConnection *conn,
|
||||
int fd,
|
||||
bool close);
|
||||
SpaResult spa_connection_add_cmd (SpaConnection *conn,
|
||||
SpaControlCmd cmd,
|
||||
void *command);
|
||||
int pinos_connection_add_fd (PinosConnection *conn,
|
||||
int fd,
|
||||
gboolean close);
|
||||
gboolean pinos_connection_add_cmd (PinosConnection *conn,
|
||||
PinosControlCmd cmd,
|
||||
gpointer command);
|
||||
|
||||
SpaResult spa_connection_flush (SpaConnection *conn);
|
||||
SpaResult spa_connection_clear (SpaConnection *conn);
|
||||
gboolean pinos_connection_flush (PinosConnection *conn);
|
||||
gboolean pinos_connection_clear (PinosConnection *conn);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __SPA_CONTROL_H__ */
|
||||
#endif /* __PINOS_CONTROL_H__ */
|
||||
|
|
|
|||
|
|
@ -95,8 +95,8 @@ struct _PinosStreamPrivate
|
|||
GSource *rtsocket_source;
|
||||
int rtfd;
|
||||
|
||||
SpaConnection *conn;
|
||||
SpaConnection *rtconn;
|
||||
PinosConnection *conn;
|
||||
PinosConnection *rtconn;
|
||||
|
||||
GSource *timeout_source;
|
||||
|
||||
|
|
@ -614,26 +614,26 @@ static void
|
|||
add_node_update (PinosStream *stream, uint32_t change_mask)
|
||||
{
|
||||
PinosStreamPrivate *priv = stream->priv;
|
||||
SpaControlCmdNodeUpdate nu = { 0, };
|
||||
PinosControlCmdNodeUpdate nu = { 0, };
|
||||
|
||||
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;
|
||||
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.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
|
||||
add_state_change (PinosStream *stream, SpaNodeState state)
|
||||
{
|
||||
PinosStreamPrivate *priv = stream->priv;
|
||||
SpaControlCmdNodeStateChange sc;
|
||||
PinosControlCmdNodeStateChange sc;
|
||||
|
||||
if (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)
|
||||
{
|
||||
PinosStreamPrivate *priv = stream->priv;
|
||||
SpaControlCmdPortUpdate pu = { 0, };;
|
||||
PinosControlCmdPortUpdate pu = { 0, };;
|
||||
|
||||
pu.direction = priv->direction;
|
||||
pu.port_id = priv->port_id;
|
||||
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.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.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;
|
||||
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
|
||||
send_need_input (PinosStream *stream, uint32_t port_id)
|
||||
{
|
||||
PinosStreamPrivate *priv = stream->priv;
|
||||
SpaControlCmdNodeEvent cne;
|
||||
PinosControlCmdNodeEvent cne;
|
||||
SpaNodeEvent ne;
|
||||
SpaNodeEventNeedInput ni;
|
||||
|
||||
|
|
@ -674,9 +674,9 @@ send_need_input (PinosStream *stream, uint32_t port_id)
|
|||
ne.data = ∋
|
||||
ne.size = sizeof (ni);
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
@ -684,7 +684,7 @@ static void
|
|||
add_request_clock_update (PinosStream *stream)
|
||||
{
|
||||
PinosStreamPrivate *priv = stream->priv;
|
||||
SpaControlCmdNodeEvent cne;
|
||||
PinosControlCmdNodeEvent cne;
|
||||
SpaNodeEvent ne;
|
||||
SpaNodeEventRequestClockUpdate rcu;
|
||||
|
||||
|
|
@ -695,7 +695,7 @@ add_request_clock_update (PinosStream *stream)
|
|||
rcu.update_mask = SPA_NODE_EVENT_REQUEST_CLOCK_UPDATE_TIME;
|
||||
rcu.timestamp = 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
|
||||
|
|
@ -704,7 +704,7 @@ add_async_complete (PinosStream *stream,
|
|||
SpaResult res)
|
||||
{
|
||||
PinosStreamPrivate *priv = stream->priv;
|
||||
SpaControlCmdNodeEvent cne;
|
||||
PinosControlCmdNodeEvent cne;
|
||||
SpaNodeEvent ne;
|
||||
SpaNodeEventAsyncComplete ac;
|
||||
|
||||
|
|
@ -714,14 +714,14 @@ add_async_complete (PinosStream *stream,
|
|||
ne.size = sizeof (ac);
|
||||
ac.seq = seq;
|
||||
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
|
||||
send_reuse_buffer (PinosStream *stream, uint32_t port_id, uint32_t buffer_id)
|
||||
{
|
||||
PinosStreamPrivate *priv = stream->priv;
|
||||
SpaControlCmdNodeEvent cne;
|
||||
PinosControlCmdNodeEvent cne;
|
||||
SpaNodeEvent ne;
|
||||
SpaNodeEventReuseBuffer rb;
|
||||
|
||||
|
|
@ -731,9 +731,9 @@ send_reuse_buffer (PinosStream *stream, uint32_t port_id, uint32_t buffer_id)
|
|||
ne.size = sizeof (rb);
|
||||
rb.port_id = port_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);
|
||||
}
|
||||
|
||||
|
|
@ -741,24 +741,24 @@ static void
|
|||
send_process_buffer (PinosStream *stream, uint32_t port_id, uint32_t buffer_id)
|
||||
{
|
||||
PinosStreamPrivate *priv = stream->priv;
|
||||
SpaControlCmdProcessBuffer pb;
|
||||
SpaControlCmdNodeEvent cne;
|
||||
PinosControlCmdProcessBuffer pb;
|
||||
PinosControlCmdNodeEvent cne;
|
||||
SpaNodeEvent ne;
|
||||
SpaNodeEventHaveOutput ho;
|
||||
|
||||
pb.direction = priv->direction;
|
||||
pb.port_id = port_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.type = SPA_NODE_EVENT_TYPE_HAVE_OUTPUT;
|
||||
ne.data = &ho;
|
||||
ne.size = sizeof (ho);
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
@ -767,16 +767,16 @@ do_node_init (PinosStream *stream)
|
|||
{
|
||||
PinosStreamPrivate *priv = stream->priv;
|
||||
|
||||
add_node_update (stream, SPA_CONTROL_CMD_NODE_UPDATE_MAX_INPUTS |
|
||||
SPA_CONTROL_CMD_NODE_UPDATE_MAX_OUTPUTS);
|
||||
add_node_update (stream, PINOS_CONTROL_CMD_NODE_UPDATE_MAX_INPUTS |
|
||||
PINOS_CONTROL_CMD_NODE_UPDATE_MAX_OUTPUTS);
|
||||
|
||||
priv->port_info.flags = SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS;
|
||||
add_port_update (stream, SPA_CONTROL_CMD_PORT_UPDATE_POSSIBLE_FORMATS |
|
||||
SPA_CONTROL_CMD_PORT_UPDATE_INFO);
|
||||
add_port_update (stream, PINOS_CONTROL_CMD_PORT_UPDATE_POSSIBLE_FORMATS |
|
||||
PINOS_CONTROL_CMD_PORT_UPDATE_INFO);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
@ -894,7 +894,7 @@ handle_node_command (PinosStream *stream,
|
|||
add_state_change (stream, SPA_NODE_STATE_PAUSED);
|
||||
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);
|
||||
|
||||
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_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);
|
||||
|
||||
if (priv->direction == SPA_DIRECTION_INPUT)
|
||||
|
|
@ -922,7 +922,7 @@ handle_node_command (PinosStream *stream,
|
|||
g_warning ("unhandled node command %d", command->type);
|
||||
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);
|
||||
break;
|
||||
}
|
||||
|
|
@ -949,31 +949,31 @@ static gboolean
|
|||
parse_connection (PinosStream *stream)
|
||||
{
|
||||
PinosStreamPrivate *priv = stream->priv;
|
||||
SpaConnection *conn = priv->conn;
|
||||
PinosConnection *conn = priv->conn;
|
||||
|
||||
while (spa_connection_has_next (conn) == SPA_RESULT_OK) {
|
||||
SpaControlCmd cmd = spa_connection_get_cmd (conn);
|
||||
while (pinos_connection_has_next (conn)) {
|
||||
PinosControlCmd cmd = pinos_connection_get_cmd (conn);
|
||||
|
||||
switch (cmd) {
|
||||
case SPA_CONTROL_CMD_NODE_UPDATE:
|
||||
case SPA_CONTROL_CMD_PORT_UPDATE:
|
||||
case SPA_CONTROL_CMD_PORT_STATUS_CHANGE:
|
||||
case SPA_CONTROL_CMD_NODE_STATE_CHANGE:
|
||||
case SPA_CONTROL_CMD_PROCESS_BUFFER:
|
||||
case PINOS_CONTROL_CMD_NODE_UPDATE:
|
||||
case PINOS_CONTROL_CMD_PORT_UPDATE:
|
||||
case PINOS_CONTROL_CMD_PORT_STATUS_CHANGE:
|
||||
case PINOS_CONTROL_CMD_NODE_STATE_CHANGE:
|
||||
case PINOS_CONTROL_CMD_PROCESS_BUFFER:
|
||||
g_warning ("got unexpected connection %d", cmd);
|
||||
break;
|
||||
|
||||
case SPA_CONTROL_CMD_ADD_PORT:
|
||||
case SPA_CONTROL_CMD_REMOVE_PORT:
|
||||
case PINOS_CONTROL_CMD_ADD_PORT:
|
||||
case PINOS_CONTROL_CMD_REMOVE_PORT:
|
||||
g_warning ("add/remove port not supported");
|
||||
break;
|
||||
|
||||
case SPA_CONTROL_CMD_SET_FORMAT:
|
||||
case PINOS_CONTROL_CMD_SET_FORMAT:
|
||||
{
|
||||
SpaControlCmdSetFormat p;
|
||||
PinosControlCmdSetFormat p;
|
||||
gpointer mem;
|
||||
|
||||
if (spa_connection_parse_cmd (conn, &p) < 0)
|
||||
if (!pinos_connection_parse_cmd (conn, &p))
|
||||
break;
|
||||
|
||||
if (priv->format)
|
||||
|
|
@ -986,20 +986,20 @@ parse_connection (PinosStream *stream)
|
|||
g_object_notify (G_OBJECT (stream), "format");
|
||||
break;
|
||||
}
|
||||
case SPA_CONTROL_CMD_SET_PROPERTY:
|
||||
case PINOS_CONTROL_CMD_SET_PROPERTY:
|
||||
g_warning ("set property not implemented");
|
||||
break;
|
||||
|
||||
case SPA_CONTROL_CMD_ADD_MEM:
|
||||
case PINOS_CONTROL_CMD_ADD_MEM:
|
||||
{
|
||||
SpaControlCmdAddMem p;
|
||||
PinosControlCmdAddMem p;
|
||||
int fd;
|
||||
MemId mid;
|
||||
|
||||
if (spa_connection_parse_cmd (conn, &p) < 0)
|
||||
if (!pinos_connection_parse_cmd (conn, &p))
|
||||
break;
|
||||
|
||||
fd = spa_connection_get_fd (conn, p.fd_index, false);
|
||||
fd = pinos_connection_get_fd (conn, p.fd_index, false);
|
||||
if (fd == -1)
|
||||
break;
|
||||
|
||||
|
|
@ -1013,12 +1013,12 @@ parse_connection (PinosStream *stream)
|
|||
g_array_append_val (priv->mem_ids, mid);
|
||||
break;
|
||||
}
|
||||
case SPA_CONTROL_CMD_REMOVE_MEM:
|
||||
case PINOS_CONTROL_CMD_REMOVE_MEM:
|
||||
{
|
||||
SpaControlCmdRemoveMem p;
|
||||
PinosControlCmdRemoveMem p;
|
||||
MemId *mid;
|
||||
|
||||
if (spa_connection_parse_cmd (conn, &p) < 0)
|
||||
if (!pinos_connection_parse_cmd (conn, &p))
|
||||
break;
|
||||
|
||||
g_debug ("stream %p: remove mem %d", stream, p.mem_id);
|
||||
|
|
@ -1026,14 +1026,14 @@ parse_connection (PinosStream *stream)
|
|||
mid->cleanup = true;
|
||||
break;
|
||||
}
|
||||
case SPA_CONTROL_CMD_USE_BUFFERS:
|
||||
case PINOS_CONTROL_CMD_USE_BUFFERS:
|
||||
{
|
||||
SpaControlCmdUseBuffers p;
|
||||
PinosControlCmdUseBuffers p;
|
||||
BufferId bid;
|
||||
unsigned int i, j;
|
||||
SpaBuffer *b;
|
||||
|
||||
if (spa_connection_parse_cmd (conn, &p) < 0)
|
||||
if (!pinos_connection_parse_cmd (conn, &p))
|
||||
break;
|
||||
|
||||
/* clear previous buffers */
|
||||
|
|
@ -1130,32 +1130,32 @@ parse_connection (PinosStream *stream)
|
|||
}
|
||||
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);
|
||||
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;
|
||||
|
||||
handle_node_event (stream, p.event);
|
||||
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;
|
||||
|
||||
handle_node_command (stream, p.seq, p.command);
|
||||
break;
|
||||
}
|
||||
|
||||
case SPA_CONTROL_CMD_INVALID:
|
||||
case PINOS_CONTROL_CMD_INVALID:
|
||||
g_warning ("unhandled command %d", cmd);
|
||||
break;
|
||||
}
|
||||
|
|
@ -1167,38 +1167,38 @@ static gboolean
|
|||
parse_rtconnection (PinosStream *stream)
|
||||
{
|
||||
PinosStreamPrivate *priv = stream->priv;
|
||||
SpaConnection *conn = priv->rtconn;
|
||||
PinosConnection *conn = priv->rtconn;
|
||||
|
||||
while (spa_connection_has_next (conn) == SPA_RESULT_OK) {
|
||||
SpaControlCmd cmd = spa_connection_get_cmd (conn);
|
||||
while (pinos_connection_has_next (conn)) {
|
||||
PinosControlCmd cmd = pinos_connection_get_cmd (conn);
|
||||
|
||||
switch (cmd) {
|
||||
case SPA_CONTROL_CMD_INVALID:
|
||||
case SPA_CONTROL_CMD_NODE_UPDATE:
|
||||
case SPA_CONTROL_CMD_PORT_UPDATE:
|
||||
case SPA_CONTROL_CMD_PORT_STATUS_CHANGE:
|
||||
case SPA_CONTROL_CMD_NODE_STATE_CHANGE:
|
||||
case SPA_CONTROL_CMD_ADD_PORT:
|
||||
case SPA_CONTROL_CMD_REMOVE_PORT:
|
||||
case SPA_CONTROL_CMD_SET_FORMAT:
|
||||
case SPA_CONTROL_CMD_SET_PROPERTY:
|
||||
case SPA_CONTROL_CMD_ADD_MEM:
|
||||
case SPA_CONTROL_CMD_REMOVE_MEM:
|
||||
case SPA_CONTROL_CMD_USE_BUFFERS:
|
||||
case SPA_CONTROL_CMD_NODE_COMMAND:
|
||||
case PINOS_CONTROL_CMD_INVALID:
|
||||
case PINOS_CONTROL_CMD_NODE_UPDATE:
|
||||
case PINOS_CONTROL_CMD_PORT_UPDATE:
|
||||
case PINOS_CONTROL_CMD_PORT_STATUS_CHANGE:
|
||||
case PINOS_CONTROL_CMD_NODE_STATE_CHANGE:
|
||||
case PINOS_CONTROL_CMD_ADD_PORT:
|
||||
case PINOS_CONTROL_CMD_REMOVE_PORT:
|
||||
case PINOS_CONTROL_CMD_SET_FORMAT:
|
||||
case PINOS_CONTROL_CMD_SET_PROPERTY:
|
||||
case PINOS_CONTROL_CMD_ADD_MEM:
|
||||
case PINOS_CONTROL_CMD_REMOVE_MEM:
|
||||
case PINOS_CONTROL_CMD_USE_BUFFERS:
|
||||
case PINOS_CONTROL_CMD_NODE_COMMAND:
|
||||
g_warning ("got unexpected connection %d", cmd);
|
||||
break;
|
||||
|
||||
case SPA_CONTROL_CMD_PROCESS_BUFFER:
|
||||
case PINOS_CONTROL_CMD_PROCESS_BUFFER:
|
||||
{
|
||||
SpaControlCmdProcessBuffer p;
|
||||
PinosControlCmdProcessBuffer p;
|
||||
guint i;
|
||||
BufferId *bid;
|
||||
|
||||
if (priv->direction != SPA_DIRECTION_INPUT)
|
||||
break;
|
||||
|
||||
if (spa_connection_parse_cmd (conn, &p) < 0)
|
||||
if (!pinos_connection_parse_cmd (conn, &p))
|
||||
break;
|
||||
|
||||
if ((bid = find_buffer (stream, p.buffer_id))) {
|
||||
|
|
@ -1211,11 +1211,11 @@ parse_rtconnection (PinosStream *stream)
|
|||
}
|
||||
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;
|
||||
|
||||
handle_rtnode_event (stream, p.event);
|
||||
|
|
@ -1283,7 +1283,7 @@ on_timeout (gpointer user_data)
|
|||
|
||||
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);
|
||||
|
||||
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);
|
||||
g_source_set_callback (priv->socket_source, (GSourceFunc) on_socket_condition, stream, NULL);
|
||||
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->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_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);
|
||||
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;
|
||||
|
||||
if (SPA_RESULT_IS_OK (res)) {
|
||||
add_port_update (stream, SPA_CONTROL_CMD_PORT_UPDATE_INFO |
|
||||
SPA_CONTROL_CMD_PORT_UPDATE_FORMAT);
|
||||
add_port_update (stream, PINOS_CONTROL_CMD_PORT_UPDATE_INFO |
|
||||
PINOS_CONTROL_CMD_PORT_UPDATE_FORMAT);
|
||||
if (priv->format) {
|
||||
add_state_change (stream, SPA_NODE_STATE_READY);
|
||||
} else {
|
||||
|
|
@ -1653,7 +1653,7 @@ pinos_stream_finish_format (PinosStream *stream,
|
|||
|
||||
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);
|
||||
|
||||
return TRUE;
|
||||
|
|
|
|||
|
|
@ -103,11 +103,11 @@ struct _SpaProxy
|
|||
|
||||
SpaPollFd fds[1];
|
||||
SpaPollItem poll;
|
||||
SpaConnection *conn;
|
||||
PinosConnection *conn;
|
||||
|
||||
SpaPollFd rtfds[1];
|
||||
SpaPollItem rtpoll;
|
||||
SpaConnection *rtconn;
|
||||
PinosConnection *rtconn;
|
||||
|
||||
unsigned int max_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_MARKER:
|
||||
{
|
||||
SpaControlCmdNodeCommand cnc;
|
||||
PinosControlCmdNodeCommand cnc;
|
||||
|
||||
/* send start */
|
||||
cnc.seq = this->seq++;
|
||||
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)
|
||||
spa_log_error (this->log, "proxy %p: error writing connection %d\n", this, res);
|
||||
if (!pinos_connection_flush (this->conn))
|
||||
spa_log_error (this->log, "proxy %p: error writing connection\n", this);
|
||||
|
||||
res = SPA_RESULT_RETURN_ASYNC (cnc.seq);
|
||||
break;
|
||||
|
|
@ -226,14 +226,14 @@ spa_proxy_node_send_command (SpaNode *node,
|
|||
|
||||
case SPA_NODE_COMMAND_CLOCK_UPDATE:
|
||||
{
|
||||
SpaControlCmdNodeCommand cnc;
|
||||
PinosControlCmdNodeCommand cnc;
|
||||
|
||||
/* send start */
|
||||
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)
|
||||
spa_log_error (this->log, "proxy %p: error writing connection %d\n", this, res);
|
||||
if (!pinos_connection_flush (this->conn))
|
||||
spa_log_error (this->log, "proxy %p: error writing connection\n", this);
|
||||
|
||||
break;
|
||||
}
|
||||
|
|
@ -316,7 +316,7 @@ spa_proxy_node_get_port_ids (SpaNode *node,
|
|||
|
||||
static void
|
||||
do_update_port (SpaProxy *this,
|
||||
SpaControlCmdPortUpdate *pu)
|
||||
PinosControlCmdPortUpdate *pu)
|
||||
{
|
||||
SpaProxyPort *port;
|
||||
unsigned int i;
|
||||
|
|
@ -328,7 +328,7 @@ do_update_port (SpaProxy *this,
|
|||
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++)
|
||||
free (port->formats[i]);
|
||||
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]);
|
||||
}
|
||||
}
|
||||
if (pu->change_mask & SPA_CONTROL_CMD_PORT_UPDATE_FORMAT) {
|
||||
if (pu->change_mask & PINOS_CONTROL_CMD_PORT_UPDATE_FORMAT) {
|
||||
if (port->format)
|
||||
free (port->format);
|
||||
size = spa_serialize_format_get_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)
|
||||
free (port->info);
|
||||
size = spa_serialize_port_info_get_size (pu->info);
|
||||
|
|
@ -373,12 +373,12 @@ clear_port (SpaProxy *this,
|
|||
SpaDirection direction,
|
||||
uint32_t port_id)
|
||||
{
|
||||
SpaControlCmdPortUpdate pu;
|
||||
PinosControlCmdPortUpdate pu;
|
||||
|
||||
pu.change_mask = SPA_CONTROL_CMD_PORT_UPDATE_POSSIBLE_FORMATS |
|
||||
SPA_CONTROL_CMD_PORT_UPDATE_FORMAT |
|
||||
SPA_CONTROL_CMD_PORT_UPDATE_PROPS |
|
||||
SPA_CONTROL_CMD_PORT_UPDATE_INFO;
|
||||
pu.change_mask = PINOS_CONTROL_CMD_PORT_UPDATE_POSSIBLE_FORMATS |
|
||||
PINOS_CONTROL_CMD_PORT_UPDATE_FORMAT |
|
||||
PINOS_CONTROL_CMD_PORT_UPDATE_PROPS |
|
||||
PINOS_CONTROL_CMD_PORT_UPDATE_INFO;
|
||||
pu.direction = direction;
|
||||
pu.port_id = port_id;
|
||||
pu.n_possible_formats = 0;
|
||||
|
|
@ -492,8 +492,7 @@ spa_proxy_node_port_set_format (SpaNode *node,
|
|||
const SpaFormat *format)
|
||||
{
|
||||
SpaProxy *this;
|
||||
SpaControlCmdSetFormat sf;
|
||||
SpaResult res;
|
||||
PinosControlCmdSetFormat sf;
|
||||
|
||||
if (node == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
|
@ -508,9 +507,9 @@ spa_proxy_node_port_set_format (SpaNode *node,
|
|||
sf.port_id = port_id;
|
||||
sf.flags = flags;
|
||||
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);
|
||||
|
||||
return SPA_RESULT_RETURN_ASYNC (sf.seq);
|
||||
|
|
@ -622,11 +621,10 @@ spa_proxy_node_port_use_buffers (SpaNode *node,
|
|||
SpaProxy *this;
|
||||
SpaProxyPort *port;
|
||||
unsigned int i, j;
|
||||
SpaResult res;
|
||||
SpaControlCmdAddMem am;
|
||||
SpaControlCmdUseBuffers ub;
|
||||
PinosControlCmdAddMem am;
|
||||
PinosControlCmdUseBuffers ub;
|
||||
size_t size, n_mem;
|
||||
SpaControlMemRef *memref;
|
||||
PinosControlMemRef *memref;
|
||||
void *p;
|
||||
|
||||
if (node == NULL)
|
||||
|
|
@ -675,11 +673,11 @@ spa_proxy_node_port_use_buffers (SpaNode *node,
|
|||
am.port_id = port_id;
|
||||
am.mem_id = n_mem;
|
||||
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.offset = d->offset;
|
||||
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].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.mem_id = port->buffer_mem_id;
|
||||
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.offset = 0;
|
||||
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++) {
|
||||
memref[i].mem_id = port->buffer_mem_id;
|
||||
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.n_buffers = n_buffers;
|
||||
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);
|
||||
|
||||
return SPA_RESULT_RETURN_ASYNC (ub.seq);
|
||||
|
|
@ -855,8 +853,7 @@ spa_proxy_node_port_push_input (SpaNode *node,
|
|||
unsigned int i;
|
||||
bool have_error = false;
|
||||
bool have_enough = false;
|
||||
SpaControlCmdProcessBuffer pb;
|
||||
SpaResult res;
|
||||
PinosControlCmdProcessBuffer pb;
|
||||
|
||||
if (node == NULL || n_info == 0 || info == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
|
@ -891,7 +888,7 @@ spa_proxy_node_port_push_input (SpaNode *node,
|
|||
pb.direction = SPA_DIRECTION_INPUT;
|
||||
pb.port_id = info[i].port_id;
|
||||
pb.buffer_id = info[i].buffer_id;
|
||||
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;
|
||||
}
|
||||
|
|
@ -901,7 +898,7 @@ spa_proxy_node_port_push_input (SpaNode *node,
|
|||
if (have_enough)
|
||||
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);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
|
|
@ -958,8 +955,7 @@ spa_proxy_node_port_reuse_buffer (SpaNode *node,
|
|||
uint32_t buffer_id)
|
||||
{
|
||||
SpaProxy *this;
|
||||
SpaResult res;
|
||||
SpaControlCmdNodeEvent cne;
|
||||
PinosControlCmdNodeEvent cne;
|
||||
SpaNodeEvent ne;
|
||||
SpaNodeEventReuseBuffer rb;
|
||||
|
||||
|
|
@ -978,12 +974,12 @@ spa_proxy_node_port_reuse_buffer (SpaNode *node,
|
|||
ne.size = sizeof (rb);
|
||||
rb.port_id = port_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)
|
||||
spa_log_error (this->log, "proxy %p: error writing connection %d\n", this, res);
|
||||
if (!pinos_connection_flush (this->rtconn))
|
||||
spa_log_error (this->log, "proxy %p: error writing connection\n", this);
|
||||
|
||||
return res;
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
|
|
@ -1035,32 +1031,32 @@ handle_node_event (SpaProxy *this,
|
|||
static SpaResult
|
||||
parse_connection (SpaProxy *this)
|
||||
{
|
||||
SpaConnection *conn = this->conn;
|
||||
PinosConnection *conn = this->conn;
|
||||
|
||||
while (spa_connection_has_next (conn) == SPA_RESULT_OK) {
|
||||
SpaControlCmd cmd = spa_connection_get_cmd (conn);
|
||||
while (pinos_connection_has_next (conn)) {
|
||||
PinosControlCmd cmd = pinos_connection_get_cmd (conn);
|
||||
|
||||
switch (cmd) {
|
||||
case SPA_CONTROL_CMD_INVALID:
|
||||
case SPA_CONTROL_CMD_ADD_PORT:
|
||||
case SPA_CONTROL_CMD_REMOVE_PORT:
|
||||
case SPA_CONTROL_CMD_SET_FORMAT:
|
||||
case SPA_CONTROL_CMD_SET_PROPERTY:
|
||||
case SPA_CONTROL_CMD_NODE_COMMAND:
|
||||
case SPA_CONTROL_CMD_PROCESS_BUFFER:
|
||||
case PINOS_CONTROL_CMD_INVALID:
|
||||
case PINOS_CONTROL_CMD_ADD_PORT:
|
||||
case PINOS_CONTROL_CMD_REMOVE_PORT:
|
||||
case PINOS_CONTROL_CMD_SET_FORMAT:
|
||||
case PINOS_CONTROL_CMD_SET_PROPERTY:
|
||||
case PINOS_CONTROL_CMD_NODE_COMMAND:
|
||||
case PINOS_CONTROL_CMD_PROCESS_BUFFER:
|
||||
spa_log_error (this->log, "proxy %p: got unexpected command %d\n", this, cmd);
|
||||
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;
|
||||
|
||||
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;
|
||||
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;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
case SPA_CONTROL_CMD_PORT_UPDATE:
|
||||
case PINOS_CONTROL_CMD_PORT_UPDATE:
|
||||
{
|
||||
SpaControlCmdPortUpdate pu;
|
||||
PinosControlCmdPortUpdate pu;
|
||||
bool remove;
|
||||
|
||||
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;
|
||||
|
||||
if (!CHECK_PORT_ID (this, pu.direction, pu.port_id))
|
||||
|
|
@ -1091,18 +1087,18 @@ parse_connection (SpaProxy *this)
|
|||
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);
|
||||
break;
|
||||
}
|
||||
|
||||
case SPA_CONTROL_CMD_NODE_STATE_CHANGE:
|
||||
case PINOS_CONTROL_CMD_NODE_STATE_CHANGE:
|
||||
{
|
||||
SpaControlCmdNodeStateChange sc;
|
||||
PinosControlCmdNodeStateChange sc;
|
||||
SpaNodeState old = this->node.state;
|
||||
|
||||
if (spa_connection_parse_cmd (conn, &sc) < 0)
|
||||
if (!pinos_connection_parse_cmd (conn, &sc))
|
||||
break;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
case SPA_CONTROL_CMD_ADD_MEM:
|
||||
case PINOS_CONTROL_CMD_ADD_MEM:
|
||||
break;
|
||||
case SPA_CONTROL_CMD_REMOVE_MEM:
|
||||
case PINOS_CONTROL_CMD_REMOVE_MEM:
|
||||
break;
|
||||
case SPA_CONTROL_CMD_USE_BUFFERS:
|
||||
case PINOS_CONTROL_CMD_USE_BUFFERS:
|
||||
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;
|
||||
|
||||
handle_node_event (this, cne.event);
|
||||
|
|
@ -1139,34 +1135,34 @@ parse_connection (SpaProxy *this)
|
|||
static SpaResult
|
||||
parse_rtconnection (SpaProxy *this)
|
||||
{
|
||||
SpaConnection *conn = this->rtconn;
|
||||
PinosConnection *conn = this->rtconn;
|
||||
|
||||
while (spa_connection_has_next (conn) == SPA_RESULT_OK) {
|
||||
SpaControlCmd cmd = spa_connection_get_cmd (conn);
|
||||
while (pinos_connection_has_next (conn)) {
|
||||
PinosControlCmd cmd = pinos_connection_get_cmd (conn);
|
||||
|
||||
switch (cmd) {
|
||||
case SPA_CONTROL_CMD_INVALID:
|
||||
case SPA_CONTROL_CMD_NODE_UPDATE:
|
||||
case SPA_CONTROL_CMD_PORT_UPDATE:
|
||||
case SPA_CONTROL_CMD_NODE_STATE_CHANGE:
|
||||
case SPA_CONTROL_CMD_PORT_STATUS_CHANGE:
|
||||
case SPA_CONTROL_CMD_ADD_PORT:
|
||||
case SPA_CONTROL_CMD_REMOVE_PORT:
|
||||
case SPA_CONTROL_CMD_SET_FORMAT:
|
||||
case SPA_CONTROL_CMD_SET_PROPERTY:
|
||||
case SPA_CONTROL_CMD_NODE_COMMAND:
|
||||
case SPA_CONTROL_CMD_ADD_MEM:
|
||||
case SPA_CONTROL_CMD_REMOVE_MEM:
|
||||
case SPA_CONTROL_CMD_USE_BUFFERS:
|
||||
case PINOS_CONTROL_CMD_INVALID:
|
||||
case PINOS_CONTROL_CMD_NODE_UPDATE:
|
||||
case PINOS_CONTROL_CMD_PORT_UPDATE:
|
||||
case PINOS_CONTROL_CMD_NODE_STATE_CHANGE:
|
||||
case PINOS_CONTROL_CMD_PORT_STATUS_CHANGE:
|
||||
case PINOS_CONTROL_CMD_ADD_PORT:
|
||||
case PINOS_CONTROL_CMD_REMOVE_PORT:
|
||||
case PINOS_CONTROL_CMD_SET_FORMAT:
|
||||
case PINOS_CONTROL_CMD_SET_PROPERTY:
|
||||
case PINOS_CONTROL_CMD_NODE_COMMAND:
|
||||
case PINOS_CONTROL_CMD_ADD_MEM:
|
||||
case PINOS_CONTROL_CMD_REMOVE_MEM:
|
||||
case PINOS_CONTROL_CMD_USE_BUFFERS:
|
||||
spa_log_error (this->log, "proxy %p: got unexpected connection %d\n", this, cmd);
|
||||
break;
|
||||
|
||||
case SPA_CONTROL_CMD_PROCESS_BUFFER:
|
||||
case PINOS_CONTROL_CMD_PROCESS_BUFFER:
|
||||
{
|
||||
SpaControlCmdProcessBuffer cmd;
|
||||
PinosControlCmdProcessBuffer cmd;
|
||||
SpaProxyPort *port;
|
||||
|
||||
if (spa_connection_parse_cmd (conn, &cmd) < 0)
|
||||
if (!pinos_connection_parse_cmd (conn, &cmd))
|
||||
break;
|
||||
|
||||
if (!CHECK_PORT (this, cmd.direction, cmd.port_id))
|
||||
|
|
@ -1182,11 +1178,11 @@ parse_rtconnection (SpaProxy *this)
|
|||
port->buffer_id = cmd.buffer_id;
|
||||
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;
|
||||
|
||||
handle_node_event (this, cne.event);
|
||||
|
|
@ -1485,7 +1481,7 @@ pinos_client_node_get_socket_pair (PinosClientNode *this,
|
|||
goto create_failed;
|
||||
|
||||
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);
|
||||
|
||||
|
|
@ -1543,7 +1539,7 @@ pinos_client_node_get_rtsocket_pair (PinosClientNode *this,
|
|||
goto create_failed;
|
||||
|
||||
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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue