node: add target_rate and target_duration in io_clock

Place the target rate and duration in the io clock area.

The driver is meant to read these new values at the start of the cycle
and update the position rate and duration.

This used to be done by the pipewire server when it received the ready
callback from the driver but this is in fact too late. Most driver would
start processing and set the next timeout based on the old rate/duration
instead of the new pending ones.

There is still a fallback for the old behaviour (with a warning) when
the driver doesn't yet update the position.
This commit is contained in:
Wim Taymans 2023-03-23 17:57:16 +01:00
parent 87d64f5cad
commit 2adf8d38d5
4 changed files with 35 additions and 23 deletions

View file

@ -2466,6 +2466,8 @@ static void alsa_on_timeout_event(struct spa_source *source)
return;
}
}
state->position->clock.duration = state->position->clock.target_duration;
state->position->clock.rate = state->position->clock.target_rate;
check_position_config(state);
@ -2550,6 +2552,8 @@ int spa_alsa_start(struct state *state)
return 0;
if (state->position) {
state->position->clock.duration = state->position->clock.target_duration;
state->position->clock.rate = state->position->clock.target_rate;
state->duration = state->position->clock.duration;
state->rate_denom = state->position->clock.rate.denom;
}