bluez5: iso-io: sync to ISO RX clock, align stream RX in group

Align RX of streams in same ISO group:

- Ensure all streams in ISO group have same target latency also for BAP
  Client

- Determine rate matching to ISO group clock from RX times of all
  streams in the group

- Based on this, compute nominal packet RX times, and feed them to
  decode-buffer instead of the real RX time. This is enough for
  sub-sample level sync.

- Customise buffer overrun handling for ISO so that it drops data to
  arrive exactly at the target, for faster convergence at RX start

The ISO clock matching is done based on kernel-provided packet RX times,
so it has unknown offset from the actual ISO clock, probably a few ms.

Current kernels (6.17) do not provide anything better to use for the
clock matching, and doing it properly appears to be controller
vendor-defined (if possible at all).
This commit is contained in:
Pauli Virtanen 2025-09-07 17:04:08 +03:00 committed by Wim Taymans
parent 94c354c290
commit 589bc4b6f4
3 changed files with 305 additions and 49 deletions

View file

@ -48,6 +48,8 @@ void spa_bt_iso_io_set_cb(struct spa_bt_iso_io *io, spa_bt_iso_io_pull_t pull, v
int spa_bt_iso_io_recv_errqueue(struct spa_bt_iso_io *io);
void spa_bt_iso_io_set_source_buffer(struct spa_bt_iso_io *io, struct spa_bt_decode_buffer *buffer);
void spa_bt_iso_io_update_source_latency(struct spa_bt_iso_io *io);
int32_t spa_bt_iso_io_get_source_target_latency(struct spa_bt_iso_io *io);
void spa_bt_iso_io_check_rx_sync(struct spa_bt_iso_io *io, uint64_t position);
int64_t spa_bt_iso_io_recv(struct spa_bt_iso_io *io, int64_t now);
#endif