Commit graph

10 commits

Author SHA1 Message Date
Wim Taymans
1ae4374ccf Fix compilation with -Werror=float-conversion
Better make the conversions explicit so that we don't get any surprises.

Fixes #4065
2024-06-18 12:17:56 +02:00
Pauli Virtanen
a6dcdfae0c bluez5: iso-io: track and apply corrections to tx latency
Use TX timestamps to get accurate reading of queue length and latency on
kernel + controller side.

This is new kernel BT feature, so requires kernel with the necessary
patches, available currently only in bluetooth-next/master branch.
Enabling Poll Errqueue kernel experimental Bluetooth feature is also
required for this.

Use the latency information to mitigate controller issues where ISO
streams are desynchronized due to tx problems or spontaneously when some
packets that should have been sent are left sitting in the queue, and
transmission is off by a multiple of the ISO interval.  This state is
visible in the latency information, so if we see streams in a group have
persistently different latencies, drop packets to resynchronize them.

Also make corrections if the kernel/controller queues get too long, so
that we don't have too big latency there.

Since BlueZ watches the same socket for errors, and TX timestamps arrive
via the socket error queue, we need to set BT_POLL_ERRQUEUE in addition
to SO_TIMESTAMPING so that BlueZ doesn't think TX timestamps are errors.

Link: https://github.com/bluez/bluez/issues/515
Link: https://lore.kernel.org/linux-bluetooth/cover.1710440392.git.pav@iki.fi/
Link: https://lore.kernel.org/linux-bluetooth/f57e065bb571d633f811610d273711c7047af335.1712499936.git.pav@iki.fi/
2024-04-12 18:50:15 +03:00
Pauli Virtanen
4f91f0bcb0 bluez5: move spa_bt_ptp to rate-control.h 2024-04-12 18:31:26 +03:00
Pauli Virtanen
41c155bb4c bluez5: split rate control out of decode-buffer 2023-04-03 16:35:22 +00:00
Pauli Virtanen
15e4b3d500 bluez5: media-source: allow using bigger A2DP receive buffers
The maximum receive buffer target of 6 packets may be too small when
there's huge jitter in reception.  Increase it so that we may use all
buffer available if needed (2*quantum_limit = 370 ms @ 44100).

For SCO, explicitly set maximum buffer to 40 ms, so that latency cannot
grow too large there.  For A2DP duplex, set it to 80 ms for same reason.
These are close to the old 6*packet limit.
2023-02-22 20:20:07 +02:00
Pauli Virtanen
b9d7ecb5b2 bluez5: handle BAP presentation delay and transport latency
For BAP server audio sink, set buffering target so that we try to match
the target presentation delay.  Also adjust requested node latency to be
smaller than the delay.

Also fix BAP transport presentation delay value parsing, and parse also
the other BAP transport properties. Of these, transport latency value
needs to be taken into account in the total sink latency.
2023-02-19 22:44:23 +02:00
Barnabás Pőcze
934ab3036e treewide: use SPDX tags to specify copyright information
SPDX tags make the licensing information easy to understand and clear,
and they are machine parseable.

See https://spdx.dev for more information.
2023-02-16 10:54:48 +00:00
Pauli Virtanen
c0e8b397f6 bluez5: avoid (harmless) integer overflow
If no packets have been received and spa_bt_decode_buffer_process is
called, this->packet_size.max == INT32_MIN, which can give overflows.

Guard against this condition, although it should be harmless.
2022-08-24 16:59:21 +00:00
Pauli Virtanen
6e37110efd bluez5: adjust source rate control
Use different filter function than spa_dll for the rate control.
Also use a longer window for spike determination.
2022-07-12 13:55:54 +00:00
Pauli Virtanen
51356ea3d0 bluez5: a2dp-source: separate clock from recv + handle buffering
a2dp-source as driver does not produce regularly spaced graph cycles,
because A2DP is not isochronous. This causes e.g. crackling for alsa
etc. that expect regular timings. It also does not rate match.

Change a2dp-source to trigger graph on regular intervals. Change recv to
only accumulate data to a buffer, and put data to buffers in process().

Rate match with DLL, keeping average buffer level constant.  Keep track
of jitter to determine a safe target value.
2022-07-05 14:21:04 +00:00