mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
node: update the duration/rate from the target
Before scheduling the graph from the driver, update the duration and rate with the new targets.
This commit is contained in:
parent
1bdd5eee69
commit
6e8625cf96
13 changed files with 87 additions and 3 deletions
|
|
@ -702,6 +702,10 @@ static void on_driver_timeout(struct spa_source *source)
|
|||
return;
|
||||
}
|
||||
}
|
||||
if (SPA_LIKELY(this->node_position_io != NULL)) {
|
||||
this->node_position_io->clock.duration = this->node_position_io->clock.target_duration;
|
||||
this->node_position_io->clock.rate = this->node_position_io->clock.target_rate;
|
||||
}
|
||||
|
||||
check_position_and_clock_config(this);
|
||||
|
||||
|
|
|
|||
|
|
@ -682,9 +682,18 @@ static int process_write(struct seq_state *state)
|
|||
return res;
|
||||
}
|
||||
|
||||
static void update_target(struct seq_state *state)
|
||||
{
|
||||
if (SPA_LIKELY(state->position)) {
|
||||
struct spa_io_clock *clock = &state->position->clock;
|
||||
clock->duration = clock->target_duration;
|
||||
clock->rate = clock->target_rate;
|
||||
}
|
||||
}
|
||||
|
||||
static void update_position(struct seq_state *state)
|
||||
{
|
||||
if (state->position) {
|
||||
if (SPA_LIKELY(state->position)) {
|
||||
struct spa_io_clock *clock = &state->position->clock;
|
||||
state->rate = clock->rate;
|
||||
if (state->rate.num == 0 || state->rate.denom == 0)
|
||||
|
|
@ -789,6 +798,8 @@ static void alsa_on_timeout_event(struct spa_source *source)
|
|||
}
|
||||
}
|
||||
|
||||
update_target(state);
|
||||
|
||||
state->current_time = state->next_time;
|
||||
|
||||
spa_log_trace(state->log, "timeout %"PRIu64, state->current_time);
|
||||
|
|
|
|||
|
|
@ -345,6 +345,14 @@ static int read_timer(struct impl *this)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void update_target(struct impl *this)
|
||||
{
|
||||
if (this->position) {
|
||||
this->position->clock.duration = this->position->clock.target_duration;
|
||||
this->position->clock.rate = this->position->clock.target_rate;
|
||||
}
|
||||
}
|
||||
|
||||
static int make_buffer(struct impl *this)
|
||||
{
|
||||
struct buffer *b;
|
||||
|
|
@ -424,6 +432,8 @@ static void on_output(struct spa_source *source)
|
|||
struct impl *this = source->data;
|
||||
int res;
|
||||
|
||||
update_target(this);
|
||||
|
||||
res = make_buffer(this);
|
||||
|
||||
if (res == SPA_STATUS_HAVE_DATA)
|
||||
|
|
|
|||
|
|
@ -1042,6 +1042,9 @@ static void avb_on_timeout_event(struct spa_source *source)
|
|||
|
||||
current_time = state->next_time;
|
||||
if (SPA_LIKELY(state->position)) {
|
||||
state->position->clock.duration = state->position->clock.target_duration;
|
||||
state->position->clock.rate = state->position->clock.target_rate;
|
||||
|
||||
duration = state->position->clock.duration;
|
||||
rate = state->position->clock.rate.denom;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -989,6 +989,9 @@ static void media_on_timeout(struct spa_source *source)
|
|||
now_time, now_time - prev_time);
|
||||
|
||||
if (SPA_LIKELY(this->position)) {
|
||||
this->position->clock.duration = this->position->clock.target_duration;
|
||||
this->position->clock.rate = this->position->clock.target_rate;
|
||||
|
||||
duration = this->position->clock.duration;
|
||||
rate = this->position->clock.rate.denom;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -612,6 +612,9 @@ static void media_on_timeout(struct spa_source *source)
|
|||
now_time, now_time - prev_time);
|
||||
|
||||
if (SPA_LIKELY(this->position)) {
|
||||
this->position->clock.duration = this->position->clock.target_duration;
|
||||
this->position->clock.rate = this->position->clock.target_rate;
|
||||
|
||||
duration = this->position->clock.duration;
|
||||
rate = this->position->clock.rate.denom;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -838,6 +838,14 @@ static int process_input(struct impl *this)
|
|||
return SPA_STATUS_HAVE_DATA;
|
||||
}
|
||||
|
||||
static void update_target(struct impl *this)
|
||||
{
|
||||
if (SPA_LIKELY(this->position)) {
|
||||
this->position->clock.duration = this->position->clock.target_duration;
|
||||
this->position->clock.rate = this->position->clock.target_rate;
|
||||
}
|
||||
}
|
||||
|
||||
static void update_position(struct impl *this)
|
||||
{
|
||||
if (SPA_LIKELY(this->position)) {
|
||||
|
|
@ -868,6 +876,8 @@ static void on_timeout(struct spa_source *source)
|
|||
spa_log_trace(this->log, "%p: timer %"PRIu64" %"PRIu64"", this,
|
||||
now_time, now_time - prev_time);
|
||||
|
||||
update_target(this);
|
||||
|
||||
update_position(this);
|
||||
|
||||
this->next_time = now_time + this->duration * SPA_NSEC_PER_SEC / this->rate;
|
||||
|
|
@ -1161,6 +1171,9 @@ static int do_start(struct impl *this)
|
|||
|
||||
this->following = is_following(this);
|
||||
|
||||
if (!this->following)
|
||||
update_target(this);
|
||||
|
||||
update_position(this);
|
||||
|
||||
spa_log_debug(this->log, "%p: start following:%d",
|
||||
|
|
|
|||
|
|
@ -603,6 +603,9 @@ static void sco_on_timeout(struct spa_source *source)
|
|||
now_time, now_time - prev_time);
|
||||
|
||||
if (SPA_LIKELY(this->position)) {
|
||||
this->position->clock.duration = this->position->clock.target_duration;
|
||||
this->position->clock.rate = this->position->clock.target_rate;
|
||||
|
||||
duration = this->position->clock.duration;
|
||||
rate = this->position->clock.rate.denom;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -611,6 +611,9 @@ static void sco_on_timeout(struct spa_source *source)
|
|||
now_time, now_time - prev_time);
|
||||
|
||||
if (SPA_LIKELY(this->position)) {
|
||||
this->position->clock.duration = this->position->clock.target_duration;
|
||||
this->position->clock.rate = this->position->clock.target_rate;
|
||||
|
||||
duration = this->position->clock.duration;
|
||||
rate = this->position->clock.rate.denom;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -247,6 +247,9 @@ static void on_timeout(struct spa_source *source)
|
|||
return;
|
||||
}
|
||||
if (SPA_LIKELY(this->position)) {
|
||||
this->position->clock.duration = this->position->clock.target_duration;
|
||||
this->position->clock.rate = this->position->clock.target_rate;
|
||||
|
||||
duration = this->position->clock.duration;
|
||||
rate = this->position->clock.rate.denom;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -280,6 +280,9 @@ static void on_timeout(struct spa_source *source)
|
|||
nsec = this->next_time;
|
||||
|
||||
if (SPA_LIKELY(this->position)) {
|
||||
this->position->clock.duration = this->position->clock.target_duration;
|
||||
this->position->clock.rate = this->position->clock.target_rate;
|
||||
|
||||
duration = this->position->clock.duration;
|
||||
rate = this->position->clock.rate.denom;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -951,6 +951,15 @@ static int impl_port_reuse_buffer(void *object, uint32_t port_id, uint32_t buffe
|
|||
return 0;
|
||||
}
|
||||
|
||||
static inline void update_target(struct filter *impl)
|
||||
{
|
||||
struct spa_io_position *p = impl->rt.position;
|
||||
if (SPA_LIKELY(p != NULL)) {
|
||||
p->clock.duration = p->clock.target_duration;
|
||||
p->clock.rate = p->clock.target_rate;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void copy_position(struct filter *impl)
|
||||
{
|
||||
struct spa_io_position *p = impl->rt.position;
|
||||
|
|
@ -1954,7 +1963,10 @@ do_trigger_process(struct spa_loop *loop,
|
|||
bool async, uint32_t seq, const void *data, size_t size, void *user_data)
|
||||
{
|
||||
struct filter *impl = user_data;
|
||||
int res = impl_node_process(impl);
|
||||
int res;
|
||||
|
||||
update_target(impl);
|
||||
res = impl_node_process(impl);
|
||||
return spa_node_call_ready(&impl->callbacks, res);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -572,6 +572,15 @@ static int impl_set_param(void *object, uint32_t id, uint32_t flags, const struc
|
|||
return 0;
|
||||
}
|
||||
|
||||
static inline void update_target(struct stream *impl)
|
||||
{
|
||||
struct spa_io_position *p = impl->rt.position;
|
||||
if (SPA_LIKELY(p != NULL)) {
|
||||
p->clock.duration = p->clock.target_duration;
|
||||
p->clock.rate = p->clock.target_rate;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void copy_position(struct stream *impl, int64_t queued)
|
||||
{
|
||||
struct spa_io_position *p = impl->rt.position;
|
||||
|
|
@ -2263,7 +2272,9 @@ do_trigger_deprecated(struct spa_loop *loop,
|
|||
bool async, uint32_t seq, const void *data, size_t size, void *user_data)
|
||||
{
|
||||
struct stream *impl = user_data;
|
||||
int res = impl->node_methods.process(impl);
|
||||
int res;
|
||||
update_target(impl);
|
||||
res = impl->node_methods.process(impl);
|
||||
return spa_node_call_ready(&impl->callbacks, res);
|
||||
}
|
||||
|
||||
|
|
@ -2414,6 +2425,8 @@ int pw_stream_trigger_process(struct pw_stream *stream)
|
|||
if (!impl->driving && !impl->trigger) {
|
||||
res = trigger_request_process(impl);
|
||||
} else {
|
||||
update_target(impl);
|
||||
|
||||
if (!impl->process_rt)
|
||||
call_process(impl);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue