mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2026-01-01 11:08:43 -05:00
simplify events and commands
This commit is contained in:
parent
0373f73bac
commit
d3dd90bb05
25 changed files with 220 additions and 252 deletions
|
|
@ -140,8 +140,6 @@ connection_parse_node_event (PinosConnection *conn, PinosControlCmdNodeEvent *cm
|
|||
memcpy (cmd, p, sizeof (PinosControlCmdNodeEvent));
|
||||
if (cmd->event)
|
||||
cmd->event = SPA_MEMBER (p, SPA_PTR_TO_INT (cmd->event), SpaNodeEvent);
|
||||
if (cmd->event->data)
|
||||
cmd->event->data = SPA_MEMBER (p, SPA_PTR_TO_INT (cmd->event->data), void);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -151,8 +149,6 @@ connection_parse_node_command (PinosConnection *conn, PinosControlCmdNodeCommand
|
|||
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);
|
||||
}
|
||||
|
||||
static void *
|
||||
|
|
@ -331,11 +327,9 @@ connection_add_node_event (PinosConnection *conn, PinosControlCmdNodeEvent *ev)
|
|||
size_t len;
|
||||
void *p;
|
||||
PinosControlCmdNodeEvent *d;
|
||||
SpaNodeEvent *ne;
|
||||
|
||||
/* calculate length */
|
||||
len = sizeof (PinosControlCmdNodeEvent);
|
||||
len += sizeof (SpaNodeEvent);
|
||||
len += ev->event->size;
|
||||
|
||||
p = connection_add_cmd (conn, PINOS_CONTROL_CMD_NODE_EVENT, len);
|
||||
|
|
@ -345,25 +339,18 @@ connection_add_node_event (PinosConnection *conn, PinosControlCmdNodeEvent *ev)
|
|||
p = SPA_MEMBER (d, sizeof (PinosControlCmdNodeEvent), void);
|
||||
d->event = SPA_INT_TO_PTR (SPA_PTRDIFF (p, d));
|
||||
|
||||
ne = p;
|
||||
memcpy (p, ev->event, sizeof (SpaNodeEvent));
|
||||
p = SPA_MEMBER (p, sizeof (SpaNodeEvent), void);
|
||||
ne->data = SPA_INT_TO_PTR (SPA_PTRDIFF (p, d));
|
||||
memcpy (p, ev->event->data, ev->event->size);
|
||||
memcpy (p, ev->event, ev->event->size);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
connection_add_node_command (PinosConnection *conn, PinosControlCmdNodeCommand *cm)
|
||||
{
|
||||
size_t len;
|
||||
void *p;
|
||||
PinosControlCmdNodeCommand *d;
|
||||
SpaNodeCommand *nc;
|
||||
|
||||
/* calculate length */
|
||||
len = sizeof (PinosControlCmdNodeCommand);
|
||||
len += sizeof (SpaNodeCommand);
|
||||
len += cm->command->size;
|
||||
|
||||
p = connection_add_cmd (conn, PINOS_CONTROL_CMD_NODE_COMMAND, len);
|
||||
|
|
@ -373,11 +360,7 @@ connection_add_node_command (PinosConnection *conn, PinosControlCmdNodeCommand *
|
|||
p = SPA_MEMBER (d, sizeof (PinosControlCmdNodeCommand), void);
|
||||
d->command = SPA_INT_TO_PTR (SPA_PTRDIFF (p, d));
|
||||
|
||||
nc = p;
|
||||
memcpy (p, cm->command, sizeof (SpaNodeCommand));
|
||||
p = SPA_MEMBER (p, sizeof (SpaNodeCommand), void);
|
||||
nc->data = SPA_INT_TO_PTR (SPA_PTRDIFF (p, d));
|
||||
memcpy (p, cm->command->data, cm->command->size);
|
||||
memcpy (p, cm->command, cm->command->size);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
|
|||
|
|
@ -665,13 +665,11 @@ send_need_input (PinosStream *stream, uint32_t port_id)
|
|||
{
|
||||
PinosStreamPrivate *priv = stream->priv;
|
||||
PinosControlCmdNodeEvent cne;
|
||||
SpaNodeEvent ne;
|
||||
SpaNodeEventNeedInput ni;
|
||||
|
||||
cne.event = ≠
|
||||
ne.type = SPA_NODE_EVENT_TYPE_NEED_INPUT;
|
||||
ne.data = ∋
|
||||
ne.size = sizeof (ni);
|
||||
cne.event = &ni.event;
|
||||
ni.event.type = SPA_NODE_EVENT_TYPE_NEED_INPUT;
|
||||
ni.event.size = sizeof (ni);
|
||||
ni.port_id = port_id;
|
||||
pinos_connection_add_cmd (priv->rtconn, PINOS_CONTROL_CMD_NODE_EVENT, &cne);
|
||||
|
||||
|
|
@ -684,13 +682,11 @@ add_request_clock_update (PinosStream *stream)
|
|||
{
|
||||
PinosStreamPrivate *priv = stream->priv;
|
||||
PinosControlCmdNodeEvent cne;
|
||||
SpaNodeEvent ne;
|
||||
SpaNodeEventRequestClockUpdate rcu;
|
||||
|
||||
cne.event = ≠
|
||||
ne.type = SPA_NODE_EVENT_TYPE_REQUEST_CLOCK_UPDATE;
|
||||
ne.data = &rcu;
|
||||
ne.size = sizeof (rcu);
|
||||
cne.event = &rcu.event;
|
||||
rcu.event.type = SPA_NODE_EVENT_TYPE_REQUEST_CLOCK_UPDATE;
|
||||
rcu.event.size = sizeof (rcu);
|
||||
rcu.update_mask = SPA_NODE_EVENT_REQUEST_CLOCK_UPDATE_TIME;
|
||||
rcu.timestamp = 0;
|
||||
rcu.offset = 0;
|
||||
|
|
@ -704,13 +700,11 @@ add_async_complete (PinosStream *stream,
|
|||
{
|
||||
PinosStreamPrivate *priv = stream->priv;
|
||||
PinosControlCmdNodeEvent cne;
|
||||
SpaNodeEvent ne;
|
||||
SpaNodeEventAsyncComplete ac;
|
||||
|
||||
cne.event = ≠
|
||||
ne.type = SPA_NODE_EVENT_TYPE_ASYNC_COMPLETE;
|
||||
ne.data = ∾
|
||||
ne.size = sizeof (ac);
|
||||
cne.event = &ac.event;
|
||||
ac.event.type = SPA_NODE_EVENT_TYPE_ASYNC_COMPLETE;
|
||||
ac.event.size = sizeof (ac);
|
||||
ac.seq = seq;
|
||||
ac.res = res;
|
||||
pinos_connection_add_cmd (priv->conn, PINOS_CONTROL_CMD_NODE_EVENT, &cne);
|
||||
|
|
@ -721,13 +715,11 @@ send_reuse_buffer (PinosStream *stream, uint32_t port_id, uint32_t buffer_id)
|
|||
{
|
||||
PinosStreamPrivate *priv = stream->priv;
|
||||
PinosControlCmdNodeEvent cne;
|
||||
SpaNodeEvent ne;
|
||||
SpaNodeEventReuseBuffer rb;
|
||||
|
||||
cne.event = ≠
|
||||
ne.type = SPA_NODE_EVENT_TYPE_REUSE_BUFFER;
|
||||
ne.data = &rb;
|
||||
ne.size = sizeof (rb);
|
||||
cne.event = &rb.event;
|
||||
rb.event.type = SPA_NODE_EVENT_TYPE_REUSE_BUFFER;
|
||||
rb.event.size = sizeof (rb);
|
||||
rb.port_id = port_id;
|
||||
rb.buffer_id = buffer_id;
|
||||
pinos_connection_add_cmd (priv->rtconn, PINOS_CONTROL_CMD_NODE_EVENT, &cne);
|
||||
|
|
@ -742,7 +734,6 @@ send_process_buffer (PinosStream *stream, uint32_t port_id, uint32_t buffer_id)
|
|||
PinosStreamPrivate *priv = stream->priv;
|
||||
PinosControlCmdProcessBuffer pb;
|
||||
PinosControlCmdNodeEvent cne;
|
||||
SpaNodeEvent ne;
|
||||
SpaNodeEventHaveOutput ho;
|
||||
|
||||
pb.direction = priv->direction;
|
||||
|
|
@ -750,10 +741,9 @@ send_process_buffer (PinosStream *stream, uint32_t port_id, uint32_t buffer_id)
|
|||
pb.buffer_id = buffer_id;
|
||||
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);
|
||||
cne.event = &ho.event;
|
||||
ho.event.type = SPA_NODE_EVENT_TYPE_HAVE_OUTPUT;
|
||||
ho.event.size = sizeof (ho);
|
||||
ho.port_id = port_id;
|
||||
pinos_connection_add_cmd (priv->rtconn, PINOS_CONTROL_CMD_NODE_EVENT, &cne);
|
||||
|
||||
|
|
@ -854,7 +844,7 @@ handle_rtnode_event (PinosStream *stream,
|
|||
|
||||
case SPA_NODE_EVENT_TYPE_REUSE_BUFFER:
|
||||
{
|
||||
SpaNodeEventReuseBuffer *p = event->data;
|
||||
SpaNodeEventReuseBuffer *p = (SpaNodeEventReuseBuffer *) event;
|
||||
BufferId *bid;
|
||||
|
||||
if (p->port_id != priv->port_id)
|
||||
|
|
@ -924,7 +914,7 @@ handle_node_command (PinosStream *stream,
|
|||
|
||||
case SPA_NODE_COMMAND_CLOCK_UPDATE:
|
||||
{
|
||||
SpaNodeCommandClockUpdate *cu = command->data;
|
||||
SpaNodeCommandClockUpdate *cu = (SpaNodeCommandClockUpdate *) command;
|
||||
if (cu->flags & SPA_NODE_COMMAND_CLOCK_UPDATE_FLAG_LIVE) {
|
||||
pinos_properties_set (priv->properties,
|
||||
"pinos.latency.is-live", "1");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue