mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-24 07:00:05 -05:00
event: make events dynamic
Use uri for the events.
This commit is contained in:
parent
5bccb1aeea
commit
4d9f2c5161
23 changed files with 299 additions and 285 deletions
|
|
@ -129,8 +129,10 @@ typedef struct
|
|||
static void
|
||||
send_async_complete (SpaProxy *this, uint32_t seq, SpaResult res)
|
||||
{
|
||||
SpaNodeEventAsyncComplete ac = SPA_NODE_EVENT_ASYNC_COMPLETE_INIT (seq, res);
|
||||
this->event_cb (&this->node, (SpaNodeEvent *)&ac, this->user_data);
|
||||
PinosCore *core = this->pnode->core;
|
||||
SpaNodeEventAsyncComplete ac = SPA_NODE_EVENT_ASYNC_COMPLETE_INIT (core->uri.node_events.AsyncComplete,
|
||||
seq, res);
|
||||
this->event_cb (&this->node, (SpaEvent *)&ac, this->user_data);
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
|
|
@ -164,7 +166,7 @@ static void
|
|||
send_need_input (SpaProxy *this)
|
||||
{
|
||||
PinosNode *pnode = this->pnode;
|
||||
SpaNodeEvent event = SPA_NODE_EVENT_INIT (SPA_NODE_EVENT_NEED_INPUT);
|
||||
SpaEvent event = SPA_EVENT_INIT (pnode->core->uri.node_events.NeedInput);
|
||||
uint64_t cmd = 1;
|
||||
|
||||
pinos_transport_add_event (pnode->transport, &event);
|
||||
|
|
@ -175,7 +177,7 @@ static void
|
|||
send_have_output (SpaProxy *this)
|
||||
{
|
||||
PinosNode *pnode = this->pnode;
|
||||
SpaNodeEvent event = SPA_NODE_EVENT_INIT (SPA_NODE_EVENT_HAVE_OUTPUT);
|
||||
SpaEvent event = SPA_EVENT_INIT (pnode->core->uri.node_events.HaveOutput);
|
||||
uint64_t cmd = 1;
|
||||
|
||||
pinos_transport_add_event (pnode->transport, &event);
|
||||
|
|
@ -775,8 +777,9 @@ spa_proxy_node_port_reuse_buffer (SpaNode *node,
|
|||
return SPA_RESULT_INVALID_PORT;
|
||||
|
||||
{
|
||||
SpaNodeEventReuseBuffer rb = SPA_NODE_EVENT_REUSE_BUFFER_INIT (port_id, buffer_id);
|
||||
pinos_transport_add_event (pnode->transport, (SpaNodeEvent *)&rb);
|
||||
SpaNodeEventReuseBuffer rb = SPA_NODE_EVENT_REUSE_BUFFER_INIT (pnode->core->uri.node_events.ReuseBuffer,
|
||||
port_id, buffer_id);
|
||||
pinos_transport_add_event (pnode->transport, (SpaEvent *)&rb);
|
||||
//write (this->data_source.fd, &cmd, 8);
|
||||
}
|
||||
|
||||
|
|
@ -847,25 +850,10 @@ spa_proxy_node_process_output (SpaNode *node)
|
|||
}
|
||||
|
||||
static SpaResult
|
||||
handle_node_event (SpaProxy *this,
|
||||
SpaNodeEvent *event)
|
||||
handle_node_event (SpaProxy *this,
|
||||
SpaEvent *event)
|
||||
{
|
||||
switch (SPA_NODE_EVENT_TYPE (event)) {
|
||||
case SPA_NODE_EVENT_INVALID:
|
||||
break;
|
||||
|
||||
case SPA_NODE_EVENT_ASYNC_COMPLETE:
|
||||
case SPA_NODE_EVENT_HAVE_OUTPUT:
|
||||
case SPA_NODE_EVENT_NEED_INPUT:
|
||||
case SPA_NODE_EVENT_REUSE_BUFFER:
|
||||
case SPA_NODE_EVENT_ERROR:
|
||||
case SPA_NODE_EVENT_BUFFERING:
|
||||
case SPA_NODE_EVENT_REQUEST_REFRESH:
|
||||
case SPA_NODE_EVENT_REQUEST_CLOCK_UPDATE:
|
||||
this->event_cb (&this->node, event, this->user_data);
|
||||
break;
|
||||
}
|
||||
|
||||
this->event_cb (&this->node, event, this->user_data);
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
|
|
@ -945,8 +933,8 @@ client_node_state_change (void *object,
|
|||
}
|
||||
|
||||
static void
|
||||
client_node_event (void *object,
|
||||
SpaNodeEvent *event)
|
||||
client_node_event (void *object,
|
||||
SpaEvent *event)
|
||||
{
|
||||
PinosResource *resource = object;
|
||||
PinosClientNode *node = resource->object;
|
||||
|
|
@ -984,13 +972,13 @@ proxy_on_data_fd_events (SpaSource *source)
|
|||
}
|
||||
|
||||
if (source->rmask & SPA_IO_IN) {
|
||||
SpaNodeEvent event;
|
||||
SpaEvent event;
|
||||
uint64_t cmd;
|
||||
|
||||
read (this->data_source.fd, &cmd, 8);
|
||||
|
||||
while (pinos_transport_next_event (pnode->transport, &event) == SPA_RESULT_OK) {
|
||||
SpaNodeEvent *ev = alloca (SPA_POD_SIZE (&event));
|
||||
SpaEvent *ev = alloca (SPA_POD_SIZE (&event));
|
||||
pinos_transport_parse_event (pnode->transport, ev);
|
||||
this->event_cb (&this->node, ev, this->user_data);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -250,126 +250,108 @@ send_clock_update (PinosNode *this)
|
|||
}
|
||||
|
||||
static void
|
||||
on_node_event (SpaNode *node, SpaNodeEvent *event, void *user_data)
|
||||
on_node_event (SpaNode *node, SpaEvent *event, void *user_data)
|
||||
{
|
||||
PinosNode *this = user_data;
|
||||
PinosNodeImpl *impl = SPA_CONTAINER_OF (this, PinosNodeImpl, this);
|
||||
|
||||
switch (SPA_NODE_EVENT_TYPE (event)) {
|
||||
case SPA_NODE_EVENT_INVALID:
|
||||
case SPA_NODE_EVENT_ERROR:
|
||||
case SPA_NODE_EVENT_BUFFERING:
|
||||
case SPA_NODE_EVENT_REQUEST_REFRESH:
|
||||
break;
|
||||
if (SPA_EVENT_TYPE (event) == this->core->uri.node_events.AsyncComplete) {
|
||||
SpaNodeEventAsyncComplete *ac = (SpaNodeEventAsyncComplete *) event;
|
||||
|
||||
case SPA_NODE_EVENT_ASYNC_COMPLETE:
|
||||
{
|
||||
SpaNodeEventAsyncComplete *ac = (SpaNodeEventAsyncComplete *) event;
|
||||
|
||||
pinos_log_debug ("node %p: async complete event %d %d", this, ac->body.seq.value, ac->body.res.value);
|
||||
if (!pinos_work_queue_complete (impl->work, this, ac->body.seq.value, ac->body.res.value)) {
|
||||
pinos_signal_emit (&this->async_complete, this, ac->body.seq.value, ac->body.res.value);
|
||||
}
|
||||
break;
|
||||
pinos_log_debug ("node %p: async complete event %d %d", this, ac->body.seq.value, ac->body.res.value);
|
||||
if (!pinos_work_queue_complete (impl->work, this, ac->body.seq.value, ac->body.res.value)) {
|
||||
pinos_signal_emit (&this->async_complete, this, ac->body.seq.value, ac->body.res.value);
|
||||
}
|
||||
}
|
||||
else if (SPA_EVENT_TYPE (event) == this->core->uri.node_events.NeedInput) {
|
||||
SpaResult res;
|
||||
int i;
|
||||
bool processed = false;
|
||||
|
||||
case SPA_NODE_EVENT_NEED_INPUT:
|
||||
{
|
||||
SpaResult res;
|
||||
int i;
|
||||
bool processed = false;
|
||||
for (i = 0; i < this->transport->area->n_inputs; i++) {
|
||||
PinosLink *link;
|
||||
PinosPort *inport, *outport;
|
||||
SpaPortInput *pi;
|
||||
SpaPortOutput *po;
|
||||
|
||||
for (i = 0; i < this->transport->area->n_inputs; i++) {
|
||||
PinosLink *link;
|
||||
PinosPort *inport, *outport;
|
||||
SpaPortInput *pi;
|
||||
SpaPortOutput *po;
|
||||
pi = &this->transport->inputs[i];
|
||||
if (pi->buffer_id != SPA_ID_INVALID)
|
||||
continue;
|
||||
|
||||
pi = &this->transport->inputs[i];
|
||||
if (pi->buffer_id != SPA_ID_INVALID)
|
||||
inport = this->input_port_map[i];
|
||||
spa_list_for_each (link, &inport->rt.links, rt.input_link) {
|
||||
if (link->rt.input == NULL || link->rt.output == NULL)
|
||||
continue;
|
||||
|
||||
inport = this->input_port_map[i];
|
||||
spa_list_for_each (link, &inport->rt.links, rt.input_link) {
|
||||
if (link->rt.input == NULL || link->rt.output == NULL)
|
||||
continue;
|
||||
|
||||
outport = link->rt.output;
|
||||
po = &outport->node->transport->outputs[outport->port_id];
|
||||
|
||||
if (po->buffer_id != SPA_ID_INVALID) {
|
||||
processed = true;
|
||||
|
||||
pi->buffer_id = po->buffer_id;
|
||||
if ((res = spa_node_port_reuse_buffer (outport->node->node,
|
||||
outport->port_id,
|
||||
po->buffer_id)) < 0)
|
||||
pinos_log_warn ("node %p: error reuse buffer: %d", outport->node, res);
|
||||
|
||||
po->buffer_id = SPA_ID_INVALID;
|
||||
}
|
||||
|
||||
if ((res = spa_node_process_output (outport->node->node)) < 0)
|
||||
pinos_log_warn ("node %p: got process output %d", outport->node, res);
|
||||
}
|
||||
}
|
||||
if (processed) {
|
||||
if ((res = spa_node_process_input (this->node)) < 0)
|
||||
pinos_log_warn ("node %p: got process input %d", this, res);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SPA_NODE_EVENT_HAVE_OUTPUT:
|
||||
{
|
||||
SpaResult res;
|
||||
int i;
|
||||
bool processed = false;
|
||||
|
||||
for (i = 0; i < this->transport->area->n_outputs; i++) {
|
||||
PinosLink *link;
|
||||
PinosPort *inport, *outport;
|
||||
SpaPortInput *pi;
|
||||
SpaPortOutput *po;
|
||||
|
||||
po = &this->transport->outputs[i];
|
||||
if (po->buffer_id == SPA_ID_INVALID)
|
||||
continue;
|
||||
|
||||
outport = this->output_port_map[i];
|
||||
spa_list_for_each (link, &outport->rt.links, rt.output_link) {
|
||||
if (link->rt.input == NULL || link->rt.output == NULL)
|
||||
continue;
|
||||
|
||||
inport = link->rt.input;
|
||||
pi = &inport->node->transport->inputs[inport->port_id];
|
||||
outport = link->rt.output;
|
||||
po = &outport->node->transport->outputs[outport->port_id];
|
||||
|
||||
if (po->buffer_id != SPA_ID_INVALID) {
|
||||
processed = true;
|
||||
|
||||
pi->buffer_id = po->buffer_id;
|
||||
if ((res = spa_node_port_reuse_buffer (outport->node->node,
|
||||
outport->port_id,
|
||||
po->buffer_id)) < 0)
|
||||
pinos_log_warn ("node %p: error reuse buffer: %d", outport->node, res);
|
||||
|
||||
if ((res = spa_node_process_input (inport->node->node)) < 0)
|
||||
pinos_log_warn ("node %p: got process input %d", inport->node, res);
|
||||
po->buffer_id = SPA_ID_INVALID;
|
||||
}
|
||||
|
||||
if ((res = spa_node_port_reuse_buffer (this->node,
|
||||
outport->port_id,
|
||||
po->buffer_id)) < 0)
|
||||
pinos_log_warn ("node %p: error reuse buffer: %d", this, res);
|
||||
|
||||
po->buffer_id = SPA_ID_INVALID;
|
||||
if ((res = spa_node_process_output (outport->node->node)) < 0)
|
||||
pinos_log_warn ("node %p: got process output %d", outport->node, res);
|
||||
}
|
||||
if (processed) {
|
||||
if ((res = spa_node_process_output (this->node)) < 0)
|
||||
pinos_log_warn ("node %p: got process output %d", this, res);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SPA_NODE_EVENT_REUSE_BUFFER:
|
||||
break;
|
||||
if (processed) {
|
||||
if ((res = spa_node_process_input (this->node)) < 0)
|
||||
pinos_log_warn ("node %p: got process input %d", this, res);
|
||||
}
|
||||
}
|
||||
else if (SPA_EVENT_TYPE (event) == this->core->uri.node_events.HaveOutput) {
|
||||
SpaResult res;
|
||||
int i;
|
||||
bool processed = false;
|
||||
|
||||
case SPA_NODE_EVENT_REQUEST_CLOCK_UPDATE:
|
||||
send_clock_update (this);
|
||||
break;
|
||||
for (i = 0; i < this->transport->area->n_outputs; i++) {
|
||||
PinosLink *link;
|
||||
PinosPort *inport, *outport;
|
||||
SpaPortInput *pi;
|
||||
SpaPortOutput *po;
|
||||
|
||||
po = &this->transport->outputs[i];
|
||||
if (po->buffer_id == SPA_ID_INVALID)
|
||||
continue;
|
||||
|
||||
outport = this->output_port_map[i];
|
||||
spa_list_for_each (link, &outport->rt.links, rt.output_link) {
|
||||
if (link->rt.input == NULL || link->rt.output == NULL)
|
||||
continue;
|
||||
|
||||
inport = link->rt.input;
|
||||
pi = &inport->node->transport->inputs[inport->port_id];
|
||||
|
||||
processed = true;
|
||||
|
||||
pi->buffer_id = po->buffer_id;
|
||||
|
||||
if ((res = spa_node_process_input (inport->node->node)) < 0)
|
||||
pinos_log_warn ("node %p: got process input %d", inport->node, res);
|
||||
}
|
||||
|
||||
if ((res = spa_node_port_reuse_buffer (this->node,
|
||||
outport->port_id,
|
||||
po->buffer_id)) < 0)
|
||||
pinos_log_warn ("node %p: error reuse buffer: %d", this, res);
|
||||
|
||||
po->buffer_id = SPA_ID_INVALID;
|
||||
}
|
||||
if (processed) {
|
||||
if ((res = spa_node_process_output (this->node)) < 0)
|
||||
pinos_log_warn ("node %p: got process output %d", this, res);
|
||||
}
|
||||
}
|
||||
else if (SPA_EVENT_TYPE (event) == this->core->uri.node_events.RequestClockUpdate) {
|
||||
send_clock_update (this);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -546,8 +546,8 @@ client_node_marshal_done (void *object,
|
|||
}
|
||||
|
||||
static void
|
||||
client_node_marshal_event (void *object,
|
||||
const SpaNodeEvent *event)
|
||||
client_node_marshal_event (void *object,
|
||||
const SpaEvent *event)
|
||||
{
|
||||
PinosResource *resource = object;
|
||||
PinosConnection *connection = resource->client->protocol_private;
|
||||
|
|
@ -930,7 +930,7 @@ client_node_demarshal_event (void *object,
|
|||
{
|
||||
PinosResource *resource = object;
|
||||
SpaPODIter it;
|
||||
SpaNodeEvent *event;
|
||||
SpaEvent *event;
|
||||
|
||||
if (!spa_pod_iter_struct (&it, data, size) ||
|
||||
!spa_pod_iter_get (&it, SPA_POD_TYPE_OBJECT, &event, 0))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue