mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-01 22:58:50 -04:00
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:
parent
87d64f5cad
commit
2adf8d38d5
4 changed files with 35 additions and 23 deletions
|
|
@ -124,7 +124,13 @@ struct spa_io_clock {
|
|||
* positive for capture, negative for playback */
|
||||
double rate_diff; /**< rate difference between clock and monotonic time */
|
||||
uint64_t next_nsec; /**< estimated next wakeup time in nanoseconds */
|
||||
uint32_t padding[8];
|
||||
|
||||
struct spa_fraction target_rate; /**< target rate of next cycle */
|
||||
uint64_t target_duration; /**< target duration of next cycle */
|
||||
uint32_t target_seq; /**< seq counter. must be equal at start and
|
||||
* end of read and lower bit must be 0 */
|
||||
|
||||
uint32_t padding[3];
|
||||
};
|
||||
|
||||
/* the size of the video in this cycle */
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue