sco-sink: adjust data flush timeout for msbc according to packet size

Instead of using a hardcoded value for the minimum delay between writes,
select it according to the mtu/packet size that is currently used.

This is necessary for correct playback with lower mtu values.
This commit is contained in:
Pauli Virtanen 2020-12-21 01:54:34 +02:00
parent 4144427655
commit f1d9b2317c

View file

@ -401,8 +401,12 @@ next_write:
processed = written;
next_timeout = get_next_timeout(this, now_time, processed / port->frame_size);
if (this->transport->codec == HFP_AUDIO_CODEC_MSBC && next_timeout < 7500000)
next_timeout = 7500000;
if (this->transport->codec == HFP_AUDIO_CODEC_MSBC) {
uint64_t min_delay = (this->transport->write_mtu / port->frame_size
* SPA_NSEC_PER_SEC / port->current_format.info.raw.rate);
next_timeout = SPA_MAX(next_timeout, min_delay);
}
if (this->clock) {
this->clock->nsec = now_time;