Remove wrong adjustment to the write timeout with mSBC.
The time between writes should be the 7.5ms at which we encode, which is
correct even when the frames get fragmented to incommensurate tx packets
(on USB BT adapters).
Fixes sound on RTL8176B. This adapter has large reported write_mtu, so
the wrong delay affected it.
Move SCO polling to a single place, and abstract mtu handling.
Autodetect suitable tx packet size based on rx, instead of relying on
the kernel providing correct values.
Since the data thread accesses the spa_bt_transport, its destroy event
needs to sync with data thread to avoid races.
Also check transport is present in places that need it.
When reusing buffers, do it in the same way as the other sinks.
The previous code did not set a valid next buffer for the i/o,
possibly causing it to hang.
Backends don't necessarily allow for opening the same device multiple
times, and it shouldn't be necessary.
Since source and sink are not necessarily both running at the same time,
refcount the transport acquire/release so that it knows to close the fd
only when no source/sink is running.
Let the transport manage the fd lifecycle, also closing it once it is
not needed.
Don't return the fd from acquire(), since each transport is associated
with a single socket fd.
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.
It seems that some BT adapters don't return correct SCO MTU, see
https://marc.info/?t=148586768600002&r=1&w=2
Do not try to autodetect the MTU and use a fix MTU size of 48 bytes.
This is more in line with wayland and it allows us to create new
interfaces in modules without having to add anything to the type
enum. It also removes some lookups to map type_id to readable
name in debug.