mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-31 22:25:38 -04:00
bluez5: media-source: account for driver clock rate difference in rate match
The rate matching calculations are done in the system clock domain. If the driver ticks at a different rate, the correction factor needs to be adjusted by the rate_diff. setup_matching() also needs to be before spa_bt_decode_buffer_process(): as follower we should use rate matching value calculated on the *previous* cycle, because this is what driver is doing when it adjusts it tick rate.
This commit is contained in:
parent
f48a72a504
commit
e446e3aac5
1 changed files with 6 additions and 2 deletions
|
|
@ -713,6 +713,10 @@ static int setup_matching(struct impl *this)
|
||||||
this->matching = this->following;
|
this->matching = this->following;
|
||||||
this->resampling = this->matching ||
|
this->resampling = this->matching ||
|
||||||
(port->current_format.info.raw.rate != this->position->clock.target_rate.denom);
|
(port->current_format.info.raw.rate != this->position->clock.target_rate.denom);
|
||||||
|
|
||||||
|
/* Rate match in system clock domain also when follower */
|
||||||
|
if (this->matching && this->position->clock.rate_diff > 0)
|
||||||
|
port->rate_match->rate *= this->position->clock.rate_diff;
|
||||||
} else {
|
} else {
|
||||||
this->matching = false;
|
this->matching = false;
|
||||||
this->resampling = false;
|
this->resampling = false;
|
||||||
|
|
@ -1720,12 +1724,12 @@ static void process_buffering(struct impl *this)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setup_matching(this);
|
||||||
|
|
||||||
spa_bt_decode_buffer_process(&port->buffer, samples, duration,
|
spa_bt_decode_buffer_process(&port->buffer, samples, duration,
|
||||||
this->position ? this->position->clock.rate_diff : 1.0,
|
this->position ? this->position->clock.rate_diff : 1.0,
|
||||||
this->position ? this->position->clock.next_nsec : 0);
|
this->position ? this->position->clock.next_nsec : 0);
|
||||||
|
|
||||||
setup_matching(this);
|
|
||||||
|
|
||||||
/* copy data to buffers */
|
/* copy data to buffers */
|
||||||
if (!spa_list_is_empty(&port->free)) {
|
if (!spa_list_is_empty(&port->free)) {
|
||||||
struct buffer *buffer;
|
struct buffer *buffer;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue