Commit graph

3126 commits

Author SHA1 Message Date
Pauli Virtanen
2bc48e1c18 bluez5: backend-native: make SCO acquire asynchronous
Don't block main loop in connect() for SCO sockets, as we can now do it
asynchronously.  Can be useful if connecting runs into problems.
2023-03-18 16:10:18 +02:00
Pauli Virtanen
73d7252f24 bluez5: use nonblocking i/o for SCO
Although SCO sockets usually don't block, they could, so do nonblocking
reads/writes.
2023-03-18 16:08:36 +02:00
Pauli Virtanen
13a9964a71 bluez5: don't try to acquire if we are getting errors
If transport goes into error state too often, fail instead of trying to
acquire it again.

This avoids getting into a tight acquire->fail->reacquire loop.
2023-03-18 15:39:56 +02:00
Pauli Virtanen
397059017b bluez5: don't rely on bluez event ordering for acquire
Don't assume that transport State property update arrives after acquire
completion callback.

It currently does, but best to not rely on it.
2023-03-18 14:11:54 +02:00
Pauli Virtanen
eb12a3dfca bluez5: acquire all BAP transports in a CIG at the same time
We need to acquire and release all transports in the same CIG at the
same time.

Due to current kernel ISO socket limitations, this cannot be done one by
one.
2023-03-17 16:56:31 +00:00
Pauli Virtanen
dfd30f37dc bluez5: parse BAP transport CIG/CIS properties 2023-03-17 16:56:31 +00:00
Pauli Virtanen
3236d706ba bluez5: hsphfpd: make transport acquire async
Now that sinks/sources can do transport acquire asynchronously, remove
the workaround that made it synchronous.  Do release still synchronously
however.
2023-03-17 16:56:31 +00:00
Pauli Virtanen
4d844ee1c6 bluez5: backend-native: set state on synchronous acquire/release
Sinks/sources now expect transport state is set on acquire+release.
It doesn't need to be done async, so do it still synchronously.
2023-03-17 16:56:31 +00:00
Pauli Virtanen
b69f3fc19e bluez5: ofono: set transport state on synchronous acquire/release
The sinks/sources now expect transport state is set in acquire and
release.  It does not need to be async, so we still do it synchronously.
2023-03-17 16:56:31 +00:00
Pauli Virtanen
63118b130e bluez5: make A2DP/BAP transport acquire/release async
Change A2DP/BAP transport acquire and release to be async.

Since BlueZ acquiring ISO sockets blocks until all sockets in same CIG
are acquired, BAP transports must be acquired asynchronously.
2023-03-17 16:56:31 +00:00
Pauli Virtanen
1d5c693d33 bluez5: change sink/source run state follow transport state
Allow asynchronous changes in transport state in the sinks/sources.

Also allow transport acquire to be actually synchronous, in this case it
must set transport state during acquire call.

Separate driver start/stop from transport start/stop.
2023-03-17 16:56:31 +00:00
Pauli Virtanen
fa3ee2e20b bluez5: allow disabling sink or source endpoints
Add option bluez5.roles that selects which endpoints (A2DP, BAP, HFP,
HSP) will be enabled.

This extends and deprecates bluez5.headset-roles.
2023-03-16 20:58:55 +02:00
Pauli Virtanen
a49d2d41af bluez5: ensure nodes are removed on disconnect
Emit any remove node events before resetting initial profile.  It
indicates to the session manager that nodes if any went away before
device disconnected.

Usually the profile is removed first which removes the nodes. This
depends on ordering of events from bluez, which apparently can be
different depending on how remote device disconnects.
2023-03-16 19:42:31 +02:00
Wim Taymans
49304ec522 alsa: fix uninitialized value 2023-03-16 13:02:54 +01:00
Wim Taymans
689184a5e7 audioconvert: check return value of pod parse 2023-03-16 12:33:08 +01:00
Wim Taymans
98a214891d handle some uninitialized variables 2023-03-16 12:29:15 +01:00
Wim Taymans
c88f841a58 audioconvert: fix passthrough PortConfig enum 2023-03-16 11:59:07 +01:00
Gleb Popov
a83d3b0249 Fix node-driver.c build on FreeBSD. 2023-03-15 16:53:41 +00:00
Gleb Popov
01096bf669 Disable alsa plugin on !Linux platforms.
It now includes Linux-specific headers.
2023-03-15 16:53:41 +00:00
Pauli Virtanen
1664df2c85 bluez5: guard against processing when errored or not started
Add some guards against doing processing when there has been an error or
the node is not started. Set error status to IO.  Continue driving on IO
errors.
2023-03-11 11:11:08 +00:00
Wim Taymans
54cf394b1b wav: fix build 2023-03-09 17:09:47 +01:00
Wim Taymans
670bf8fe8f echo-cancel: add wav debug file support 2023-03-09 16:31:30 +01:00
Wim Taymans
0563e1da52 audioconvert: add debug.wav-path to save wav 2023-03-09 16:22:55 +01:00
Wim Taymans
a2b391b5c7 Improve debug log a little 2023-03-07 19:11:38 +01:00
Pauli Virtanen
04eb709619 bluez5: don't set unnecessary socket options
In media-sink, there's no need to set RCVBUF.

In media-source, we don't need to set NONBLOCK, as reads are done with
DONTWAIT. Don't set SNDBUF as it's not needed there. Don't set RCVBUF,
but use the (big) kernel default value: decode-buffer will handle any
overruns. Small values of RCVBUF might cause problems if kernel is
sending packets in a burst faster than we wake up.
2023-03-05 17:55:24 +00:00
Wim Taymans
a7322d5043 alsa: improve target delay in ALSA
Don't just limit the max delay of samples we keep in the ALSA ringbuffer
to the buffer_size but to half of it. Make this into a max_delay
variable.

If we have a buffer size of 8192 samples and a headroom of 8192 samples,
when capturing, we would wait for the ringbuffer to contain at least
8192 samples, which would always xrun. When we limit the size to
half, we can still read the data without xruns.

Fixes #2972
2023-03-03 14:59:38 +01:00
Pauli Virtanen
34d8466c8c bluez5: sources should produce full buffer every cycle
On underflow in sources, pad with explicit silence.  This avoids the
audioadapter from getting off sync from the cycle. That causes problems
as driver when we want to produce a buffer only a the start of the
cycle.

In some cases, it's also possible that the io already has buffer at the
start of the cycle when rate matching as driver. Currently, we don't
produce buffer in this case, but we should.  Fix that by doing things in
the exact same way as ALSA sources do.
2023-03-02 16:18:27 +00:00
Wim Taymans
5c180a57a5 audioconvert: copy follower port flags
Copy the follower port flags to the adapter ports. This is mostly
interesting to mark the ports of a device as physical and terminal.
2023-03-02 12:35:06 +01:00
Barnabás Pőcze
0e0a2627aa treewide: print pthread_t as a pointer
On glibc, `pthread_t` is `unsigned long int` while on musl
it has a pointer type. To avoid format string warnings,
cast it to `void *` and use the `%p` format specifier.
2023-02-25 20:45:28 +01:00
Barnabás Pőcze
7b3ef1ac4e spa: alsa: fix spa_log_trace_fp() args
Less arguments were passed than required by the format string.
2023-02-25 20:17:51 +01:00
Pauli Virtanen
99d5436f15 bluez5: media-sink: write packets exactly on time
Delay output by one packet, so that we never need to wait for
node_process to supply more data when a packet is due out, and can write
audio packets at exactly equal intervals (up to timer/io accuracy).

In principle, this should not be necessary. However, enable it for now,
in case this improves the various stutter/etc. bug reports.
2023-02-25 01:10:20 +00:00
Pauli Virtanen
f05e68e4d4 bluez5: media-sink: encode next packet as soon as possible
After flushing a packet, encode the next one immediately if we already
have the data.  This makes the flush timing more accurate (std ~4x
smaller) as we don't need to wait for the encode.
2023-02-25 01:10:20 +00:00
Carlos Rafael Giani
031f992981 alsa-compress-offload-sink: major sink rework
* Add support for running the sink as a driver
* Detect which compressed formats are actually supported
* Correctly open/close/start/stop device according to the node commands
* Shift away from tinycompress and use Compress-Offload ioctls directly
  to be able to access various caps information (including fragment sizes)
  which are unavailable in the tinycompress API
* Implement SPA_PARAM_PropInfo and SPA_PARAM_Props support
2023-02-24 14:15:13 +01:00
Pauli Virtanen
da21cfa93c bluez5: backend-native: implement AT+BCC
Implement HF-initiated connection establishment command AT+BCC
for HFP AG.
2023-02-23 18:42:53 +02:00
Wim Taymans
eca4049a38 null-sink: accept our custom format as well 2023-02-23 12:04:13 +01:00
Wim Taymans
8aefdd8a6a audioconvert: log params to error as well 2023-02-23 12:03:40 +01:00
Wim Taymans
a9756def46 spa: allow passing audio.format to null-sink
So that the EnumFormat returns the given format instead of the default
float ones.
2023-02-23 10:31:51 +01: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
Pauli Virtanen
192044f1d9 bluez5: dup transport fd, in case media-sink is using it
For bidirectional links, both media-sink and media-source are polling
the same fd.  This won't work, so dup the fd in media-source to avoid
problems.
2023-02-17 20:40:46 +02:00
Barnabás Pőcze
d77ef4b05e spa: bluez: include gio/gunixfdlist.h
Apparently before glib 2.73 including only gio/gio.h
does not include gio/gunixfdlist.h. So do that explicitly.
2023-02-16 20:55:55 +01: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
Barnabás Pőcze
2b6541f503 spa: support: send TID to systemd journal
Knowing which thread posted which log message can
be useful, so send the TID to the systemd journal.

The `TID` field is explicitly listed on
https://www.freedesktop.org/software/systemd/man/systemd.journal-fields.html#TID=
2023-02-14 11:38:52 +00:00
Wim Taymans
58812103f3 test: add another channelmix test 2023-02-14 11:57:04 +01:00
Wim Taymans
2895961b48 audioconvert: improve channelmix with unknown layouts
Use a 0 mask to handle unknown layouts. When the source or destination
is an unknown layout, pair, distribute or average. When pairing, keep
track how we paired and use that to construct the matrix later.

This fixes [ UNK UNK ] -> [ FL FR ] mapping by pairing.
2023-02-14 11:57:04 +01:00
Dmitry Sharshakov
6d712d17e7 meson: libcamera: remove libdrm dependency
Seems to no longer be used in plugin headers, thus not a direct dependency.
2023-02-10 09:21:58 +00:00
Barnabás Pőcze
1cde814cdf spa: libcamera: remove unused libcamera-client.c 2023-02-09 22:02:48 +01:00
Pauli Virtanen
b94cb5d99d bluez5: fix BAP current profile
Fix BAP profiles again: make sure the current profile is indicated
properly.
2023-02-07 22:54:37 +02:00
Wim Taymans
b9999b292d channelmix: improve mixing setup
Handle MONO layout as a real layout, not just like FC. This means it
does not share the FC mixing weights.
Only distribute and combine MONO channels when the target is also
MONO, enable normalization in this case.
Otherwise downmix and upmix the mono channels like any other channel,
which will make it respect the upmix and other settings.
Change some tests with this new way of doing things.

Fixes #3010
2023-02-06 21:05:23 +01:00
Pauli Virtanen
987b772b97 bluez5: don't claim sbc is supported when there's no A2DP at all
Handle failure to register legacy A2DP endpoints.
2023-02-06 06:35:40 +00:00