bluez5: fix decode-buffer buffering threshold

The minimum is the number of requested samples, not duration, which can
be different when resampling.
This commit is contained in:
Pauli Virtanen 2025-07-06 18:22:33 +03:00 committed by Wim Taymans
parent ff81fc9f7b
commit cee0c39b00

View file

@ -259,7 +259,7 @@ static inline void spa_bt_decode_buffer_process(struct spa_bt_decode_buffer *thi
spa_log_trace(this->log, "%p buffering size:%d", this, (int)size);
if (size >= SPA_MAX((int)duration, target))
if (size >= SPA_MAX((int)samples, target))
this->buffering = false;
else
return;
@ -275,7 +275,7 @@ static inline void spa_bt_decode_buffer_process(struct spa_bt_decode_buffer *thi
spa_bt_ptp_update(&this->spike, (int32_t)this->ctl.avg - this->level, duration);
if (this->level > SPA_MAX(4 * target, 3*(int32_t)duration) &&
if (this->level > SPA_MAX(4 * target, 3*(int32_t)samples) &&
avail > data_size) {
/* Lagging too much: drop data */
uint32_t size = SPA_MIN(avail - data_size,
@ -307,7 +307,7 @@ static inline void spa_bt_decode_buffer_process(struct spa_bt_decode_buffer *thi
this->level, target, duration, avg_period,
BUFFERING_RATE_DIFF_MAX);
this->level -= duration;
this->level -= samples;
spa_bt_decode_buffer_get_read(this, &avail);
if (avail < data_size) {