mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-04 13:30:12 -05:00
node: add support for transport
Move some things around. Move the duration of the current cycle to the clock. Also add the estimated next timeout to the clock. Add a generic media specific counter to the clock. Clean up the position_bar info. We can do with only a double beat value and make the signature in floats. Flesh out the io_position info. This has now the information needed to convert a raw clock time into a stream time. It basically has the same kind of features as GStreamer segments such as looping, variable rate playback etc.. It also contains the state of the timeline (paused/playing) and it can be used to update the position and state from clients. There is also extended information in the position field that clients can update when they can. Plugins basically only update the clock info they get (and use the position info to check if they are slaved or not). Before each cycle, check if there is a pending position update and apply it.
This commit is contained in:
parent
f36daaedea
commit
b356c83d32
10 changed files with 168 additions and 60 deletions
|
|
@ -1093,8 +1093,8 @@ static int collect_nodes(struct pw_node *driver)
|
|||
}
|
||||
quantum = SPA_MAX(quantum, MIN_QUANTUM);
|
||||
|
||||
if (driver->rt.position && quantum != driver->rt.position->size)
|
||||
driver->rt.position->size = quantum;
|
||||
if (driver->rt.position && quantum != driver->rt.position->clock.duration)
|
||||
driver->rt.position->clock.duration = quantum;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1161,8 +1161,8 @@ int pw_core_recalc_graph(struct pw_core *core)
|
|||
spa_list_for_each(n, &core->driver_list, driver_link) {
|
||||
if (!n->master)
|
||||
continue;
|
||||
pw_log_info(NAME" %p: master %p quantum:%d '%s'", core, n,
|
||||
n->rt.position ? n->rt.position->size : 0, n->name);
|
||||
pw_log_info(NAME" %p: master %p quantum:%"PRIu64" '%s'", core, n,
|
||||
n->rt.position ? n->rt.position->clock.duration : 0, n->name);
|
||||
spa_list_for_each(s, &n->slave_list, slave_link)
|
||||
pw_log_info(NAME" %p: slave %p: active:%d '%s'",
|
||||
core, s, s->active, s->name);
|
||||
|
|
|
|||
|
|
@ -962,7 +962,8 @@ struct pw_node *pw_node_new(struct pw_core *core,
|
|||
this->rt.driver_target.signal = process_node;
|
||||
|
||||
this->rt.activation->position.clock.rate = SPA_FRACTION(1, 48000);
|
||||
this->rt.activation->position.size = DEFAULT_QUANTUM;
|
||||
this->rt.activation->position.clock.duration = DEFAULT_QUANTUM;
|
||||
this->rt.activation->position.rate = 1.0;
|
||||
|
||||
check_properties(this);
|
||||
|
||||
|
|
@ -1160,6 +1161,52 @@ static const struct spa_node_events node_events = {
|
|||
.event = node_event,
|
||||
};
|
||||
|
||||
static void update_position(struct pw_node *node)
|
||||
{
|
||||
struct pw_node_activation *a = node->rt.activation;
|
||||
struct spa_io_position position;
|
||||
uint32_t seq1, seq2, change_mask;
|
||||
enum spa_io_position_state state;
|
||||
|
||||
seq1 = SEQ_READ(&a->pending.seq);
|
||||
change_mask = a->pending.change_mask;
|
||||
state = a->pending.state;
|
||||
position = a->pending.position;
|
||||
seq2 = SEQ_READ(&a->pending.seq);
|
||||
|
||||
if (SEQ_READ_SUCCESS(seq1, seq2))
|
||||
a->pending.change_mask = 0;
|
||||
else
|
||||
change_mask = 0;
|
||||
|
||||
if (change_mask & UPDATE_POSITION) {
|
||||
pw_log_debug("update position:%lu", position.position);
|
||||
a->position.position = position.position;
|
||||
a->position.clock_start = position.clock_start;
|
||||
a->position.clock_duration = position.clock_duration;
|
||||
a->position.rate = position.rate;
|
||||
}
|
||||
if (change_mask & UPDATE_STATE) {
|
||||
switch (state) {
|
||||
case SPA_IO_POSITION_STATE_STOPPED:
|
||||
a->position.state = state;
|
||||
break;
|
||||
case SPA_IO_POSITION_STATE_STARTING:
|
||||
a->position.state = SPA_IO_POSITION_STATE_RUNNING;
|
||||
break;
|
||||
case SPA_IO_POSITION_STATE_RUNNING:
|
||||
case SPA_IO_POSITION_STATE_LOOPING:
|
||||
a->position.state = state;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (a->position.clock_start == 0)
|
||||
a->position.clock_start = a->position.clock.position;
|
||||
|
||||
if (a->position.state == SPA_IO_POSITION_STATE_STOPPED)
|
||||
a->position.clock_start += a->position.clock.duration;
|
||||
}
|
||||
|
||||
static int node_ready(void *data, int status)
|
||||
{
|
||||
struct pw_node *node = data;
|
||||
|
|
@ -1183,6 +1230,8 @@ static int node_ready(void *data, int status)
|
|||
t->activation->status = NOT_TRIGGERED;
|
||||
}
|
||||
a->prev_signal_time = a->signal_time;
|
||||
|
||||
update_position(node);
|
||||
}
|
||||
if (node->driver && !node->master)
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -368,6 +368,15 @@ struct pw_node_activation {
|
|||
uint64_t xrun_time; /* time of last xrun in microseconds */
|
||||
uint64_t xrun_delay; /* delay of last xrun in microseconds */
|
||||
uint64_t max_delay; /* max of all xruns in microseconds */
|
||||
|
||||
struct {
|
||||
uint32_t seq;
|
||||
#define UPDATE_STATE (1<<0)
|
||||
#define UPDATE_POSITION (1<<1)
|
||||
uint32_t change_mask;
|
||||
enum spa_io_position_state state;
|
||||
struct spa_io_position position;
|
||||
} pending;
|
||||
};
|
||||
|
||||
#define SEQ_WRITE(s) __atomic_add_fetch((s), 1, __ATOMIC_SEQ_CST)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue