bluez: introduce media.min-latency-ms for media source

Target number of samples stored in buffer is calculated by
target = SPA_CLAMP(SPA_ROUND_UP(SPA_MAX(spike * 3/2, duration),
		SPA_CLAMP((int)this->rate / 50, 1, INT32_MAX)),
			duration, max_buf - 2*packet_size);
At beginning of the playback is spike == 0, so the target is set to
duration. Our BT is not able to maintain such low latency and drops
so spike is increased. This can happens multiple times until playback
is stable.

This strategy causes few dropouts at the beginning of a new playback,
in my case on each new track.

Add min-latency-ms property to reduces spikes and the likelihood of
dropouts at the beginning.
This commit is contained in:
Martin Geier 2026-05-26 12:34:03 +02:00 committed by Carlos Rafael Giani
parent 943bce9c85
commit 32fe4dbda3
3 changed files with 18 additions and 0 deletions

View file

@ -121,6 +121,8 @@ extern "C" {
#define SPA_KEY_API_BLUEZ5_CLASS "api.bluez5.class" /**< a bluetooth class */
#define SPA_KEY_API_BLUEZ5_ICON "api.bluez5.icon" /**< a bluetooth icon */
#define SPA_KEY_API_BLUEZ5_ROLE "api.bluez5.role" /**< "client" or "server" */
#define SPA_KEY_API_BLUEZ5_MIN_LATENCY_MS \
"api.bluez5.min-latency-ms" /**< minimum possible latency, in milliseconds */
/** keys for jack api */
#define SPA_KEY_API_JACK "api.jack" /**< key for the JACK api */