mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-31 22:25:38 -04:00
plugins: simplify target_ handling
Drivers should only read the target_ values in the timeout, update the timeout with the new duration and then update the position. For the position we simply need to add the previous duration to the position and then set the new duration + rate. Otherwise, everything else should read the duration/rate and not use the target_ values.
This commit is contained in:
parent
f309543810
commit
7b6680ba57
13 changed files with 132 additions and 154 deletions
|
|
@ -702,19 +702,24 @@ 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);
|
||||
if (SPA_LIKELY(this->node_position_io != NULL)) {
|
||||
this->cycle_duration = this->node_position_io->clock.target_duration;
|
||||
this->cycle_rate = this->node_position_io->clock.target_rate.denom;
|
||||
} else {
|
||||
/* This can happen at the very beginning if node_position_io
|
||||
* isn't passed to this node in time. */
|
||||
this->cycle_duration = 1024;
|
||||
this->cycle_rate = 48000;
|
||||
}
|
||||
|
||||
current_time = this->next_driver_time;
|
||||
|
||||
this->next_driver_time += ((uint64_t)(this->cycle_duration)) * 1000000000ULL / this->cycle_rate;
|
||||
if (this->node_clock_io != NULL) {
|
||||
this->node_clock_io->nsec = current_time;
|
||||
this->node_clock_io->position += this->cycle_duration;
|
||||
this->node_clock_io->rate = this->node_clock_io->target_rate;
|
||||
this->node_clock_io->position += this->node_clock_io->duration;
|
||||
this->node_clock_io->duration = this->cycle_duration;
|
||||
this->node_clock_io->delay = 0;
|
||||
this->node_clock_io->rate_diff = 1.0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue