stream: prepare output before signaling ready

Just prepare the output on the port and signal ready. When the graph
completes we will be signaled again to recycle the buffer and
prepare more output if we can.

Improve the bookkeeping a little when activating nodes.

Fix race with moving nodes between drivers.
This commit is contained in:
Wim Taymans 2019-03-07 23:01:32 +01:00
parent 94ce6d528c
commit 1d3ce5a9d9
5 changed files with 112 additions and 74 deletions

View file

@ -980,14 +980,13 @@ static int impl_node_process(struct spa_node *node)
struct impl *impl = this->impl;
struct pw_node *n = impl->this.node;
struct timespec ts;
uint64_t cmd = 1, nsec;
uint64_t cmd = 1;
spa_log_trace(this->log, "%p: send process %p", this, impl->this.node->driver_node);
clock_gettime(CLOCK_MONOTONIC, &ts);
nsec = SPA_TIMESPEC_TO_NSEC(&ts);
n->rt.activation->status = TRIGGERED;
n->rt.activation->signal_time = nsec;
n->rt.activation->signal_time = SPA_TIMESPEC_TO_NSEC(&ts);
if (write(this->writefd, &cmd, sizeof(cmd)) != sizeof(cmd))
spa_log_warn(this->log, "node %p: error %m", this);

View file

@ -835,8 +835,10 @@ static int impl_node_process(struct spa_node *node)
struct spa_io_position *q = impl->this.node->driver_node->rt.position;
int status, trigger;
if (impl->driver)
if (impl->driver) {
impl->client_node->node->rt.target.signal(impl->client_node->node->rt.target.data);
return SPA_STATUS_OK;
}
if (!impl->active)
return SPA_STATUS_HAVE_BUFFER;

View file

@ -27,6 +27,7 @@
#include <sys/socket.h>
#include <sys/un.h>
#include <errno.h>
#include <time.h>
#include <sys/mman.h>
#include <spa/pod/parser.h>
@ -950,7 +951,14 @@ static int link_signal_func(void *user_data)
{
struct link *link = user_data;
uint64_t cmd = 1;
struct timespec ts;
pw_log_trace("link %p: signal", link);
clock_gettime(CLOCK_MONOTONIC, &ts);
link->target.activation->status = TRIGGERED;
link->target.activation->signal_time = SPA_TIMESPEC_TO_NSEC(&ts);
if (write(link->signalfd, &cmd, sizeof(cmd)) != sizeof(cmd))
pw_log_warn("link %p: write failed %m", link);
return 0;
@ -1176,14 +1184,21 @@ static int node_ready(void *d, int status)
{
struct node_data *data = d;
struct pw_node *node = data->node;
struct timespec ts;
struct pw_port *p;
uint64_t cmd = 1;
pw_log_trace("node %p: ready driver:%d exported:%d status:%d", node,
node->driver, node->exported, status);
spa_list_for_each(p, &node->rt.output_mix, rt.node_link)
spa_node_process(p->mix);
if (status == SPA_STATUS_HAVE_BUFFER) {
spa_list_for_each(p, &node->rt.output_mix, rt.node_link)
spa_node_process(p->mix);
}
clock_gettime(CLOCK_MONOTONIC, &ts);
node->rt.activation->status = TRIGGERED;
node->rt.activation->signal_time = SPA_TIMESPEC_TO_NSEC(&ts);
if (write(data->rtwritefd, &cmd, sizeof(cmd)) != sizeof(cmd))
pw_log_warn("node %p: write failed %m", node);