Commit graph

2354 commits

Author SHA1 Message Date
Pauli Virtanen
eca37b58a6 bluez5: make room for a2dp duplex channel
Some non-standard A2DP codecs (FastStream/aptX-LL) have "voice duplex
channel" that can be used to provide an A2DP duplex mode.

Add support for duplex channels, accounting for the fact that the two
directions may be encoded with different actual codecs.
2021-08-21 20:00:52 +03:00
Pauli Virtanen
f00ec34787 bluez5: use lower latency for aptx-ll codec
This pushes the latency to 256 samples, which still seems to work
Latency of 128 seems to be too small. (NB. the number of input samples
is also the size of packets sent in bytes)

Since pipewire clients usually use powers of two, this may be the
smallest value that makes sense.
2021-08-18 19:55:22 +00:00
Pauli Virtanen
90b62ba2b3 bluez5: add aptx-LL codec
Support the low-latency variant of the aptx codec.

The magic mostly seems to be on the device side, since the stream is the
same as standard aptx, but latency is smaller even if stream/packet
sizes are the same.

Sound output latency is noticeably less than with the standard aptx.
Tested on Sennheiser HD 250 / Avantree Aria Pro.

The codec in principle also supports bidirectional duplex streams,
but that is not implemented here.
2021-08-18 19:55:22 +00:00
Pauli Virtanen
73994feda9 bluez5: allow same codec ID to correspond to multiple endpoints
The codec IDs are user-visible properties.

Some codecs can have multiple endpoints (e.g. different caps struct, or
multiple possible vendor ids), so this detail should not leak to the
user.
2021-08-18 19:55:22 +00:00
Pauli Virtanen
fc2fe12794 bluez5: update a2dp-codecs.h from bluez with aptx-ll caps 2021-08-18 19:55:22 +00:00
Julian Bouzas
cad64bc992 audioadapter: add support for passthrough mode
Allows audioadapter to behave as its follower
2021-08-17 16:01:10 +00:00
Wim Taymans
49c1c0386f pw-cat: fix raw read
raw read needs bytes, so use the stride to calculate it from frames.
Move ulaw/alaw to packed formats.
2021-08-17 17:56:31 +02:00
Wim Taymans
e9679afb12 audioconvert: support alaw/ulaw conversion 2021-08-17 17:33:29 +02:00
Wim Taymans
df9f79d869 audioconvert: add converstion to and from alaw/ulaw 2021-08-17 17:32:25 +02:00
Wim Taymans
d0d7f2f20b spa: add alaw and ulaw defines
Add alaw and ulaw as raw formats.
2021-08-17 17:31:03 +02:00
Wim Taymans
fd82da938a audioconvert: add more format support
Add support to endian conversion as well.
2021-08-17 15:03:03 +02:00
Wim Taymans
a5e2e955d2 audioconvert: add more conversions
Add the other endian conversions.
2021-08-17 14:45:00 +02:00
Wim Taymans
c39d374ca8 alsa: hook up latencyOffsetNsec in ALSA sink/source
This property is exposed on the device Route and forwarded to the
nodes. It then configured the process_latency.ns field, which
influences the reported port latency.

This makes it possible to change the internal port latency on the
sink and source with pavucontrol and tweak the synchronization to
compensate for internal latencies in the device.
2021-08-17 11:57:12 +02:00
Wim Taymans
391465d1cd audioadapter: emit Latency param changed when follower changed
When the follower port Emits a latency param changed, our reported
latency also changes so we need to emit the changed notify.
2021-08-17 10:49:05 +02:00
Wim Taymans
a2083d12d4 alsa: add params to set default internal latency 2021-08-17 10:15:40 +02:00
Wim Taymans
6d196b1d11 alsa: use ProcessLatency param to get and set internal latency 2021-08-17 10:04:12 +02:00
Anukul
6c9f342775 Update 90-pipewire-alsa.rules --> add rule for gsx 1200 2021-08-16 10:04:49 +00:00
Pauli Virtanen
672223d055 bluez5: avoid poll busy loop in a2dp-sink
Disable flush polling when we don't have data ready to write to the
socket (or socket send failed). This avoids entering into a poll busy
loop, which may result to rtkit killing the process.
2021-08-13 23:37:48 +03:00
Pauli Virtanen
5071589aea bluez5: enable SBC-XQ codec by default, if allowed by quirks
Enable SBC-XQ by default, and move it at the end of the codecs list, so
that bluez does not connect to it automatically except when it is the
codec used previously.

When the codec is disabled by quirks, it won't appear in the codecs
list, and so can't be selected by user (and so won't be connected
automatically).

However, since SelectConfiguration does not carry information which
device is in question, we cannot prevent BlueZ connecting to the codec
even if it's disabled for a specific device. If the "impossible" occurs
regardless, we won't reject the connection and the profile will be shown
as the generic "A2DP" one.  If the sound is garbled, the user can select
some other profile that works.
2021-08-13 18:45:16 +00:00
Zsombor Welker
f5850af4d8 bluez5: handle XAPL battery level per Apple Guidelines
Corrects the handling of AT+XAPL Apple extensions to send
`+XAPL=iPhone,2` instead of `+XAPL: iPhone,2` based on Apple's
documentation.

Replaces magic numbers with enum values.

[Accessory Design Guidelines](https://developer.apple.com/accessories/Accessory-Design-Guidelines.pdf)
2021-08-13 10:30:36 +02:00
Zsombor Welker
a1777d00e3 bluez5: correct parsing order for HF indicator 2 based battery status
Since "AT+BIND=" was before "AT+BIND=?", the seconds statement was never
matched.
2021-08-12 21:13:22 +02:00
Sanchayan Maity
be6824cb15 bluez5-device: Set device intended role for HFP 2021-08-12 18:54:46 +00:00
Zsombor Welker
f87942027f bluez5: report HF indicator 2 based battery status
HF indicator 2 (see [assigned-numbers], Hands-Free Profile) is able to
report battery percentage at 1% intervals (in range [0, 100]), contrary
to the `+XAPL` `+IPHONEACCEV` extension which only supports 10%
increments.  This does not guarantee increased granularity however, as
peers may still be limited to imprecise battery measurements internally
or round to coarser percentages.
Supporting both additionally broadens the range of devices for which PW
can report its battery level.

[assigned-numbers]:
https://www.bluetooth.com/specifications/assigned-numbers/
2021-08-12 18:45:44 +00:00
Wim Taymans
44c6ec146e filter-chain: parse config options
Remove LADSPA dependencies, only use it in ladspa_plugin.c
Parse convolver config, like filename
2021-08-11 21:33:48 +02:00
Wim Taymans
0a5a4c046d alsa: Free global state
We need to do this or else newly plugged devices might not load.

It does not seem to harm UCM config on my machine, so this reverts
3d372424cc

See #1478
2021-08-10 11:25:41 +02:00
Wim Taymans
b7162d2c09 alsa: free alibpref after use 2021-08-10 11:14:15 +02:00
Wim Taymans
bdc164f509 udev: fix behringer UMC202 usb device id
See https://usb-ids.gowdy.us/read/UD/1397/0507
2021-08-10 10:45:47 +02:00
Wim Taymans
35d7ad5529 acp: compare the HW volume against stored HW volume
When we store the real_volume we get a hardware_volume as stored
in the mixer and a residual software_volume.

When we read the volume from the card, we need to compare this against
the hardware_volume we stored to check if something changed, not
against the real_volume that also contains the leftover software_volume.
2021-08-09 14:18:20 +02:00
Nils Tonnätt
dd12910769 Revert "[Meson] Fix all deprecation warnings"
This reverts commit f7e1175ef0.
2021-08-08 19:18:40 +00:00
Nils Tonnätt
f7e1175ef0 [Meson] Fix all deprecation warnings 2021-08-06 07:56:16 +00:00
Wim Taymans
a9fecd50ed bluez5: improve debug
Log the errno when something is wrong.
2021-08-05 15:41:50 +02:00
Wim Taymans
e3a643bffe bluez5: remove useless pod_frame() call 2021-08-05 15:41:26 +02:00
Peter Hutterer
5ae528c957 spa: move the log version define so it matches other implementations
Makes it match up with the comment now too
2021-08-05 09:51:40 +00:00
Peter Hutterer
1244229faf spa: document the spa_hook interface with an example 2021-08-05 09:51:40 +00:00
Peter Hutterer
d8f6033b9d spa: document the spa_interface and how it works 2021-08-05 09:51:40 +00:00
Peter Hutterer
56acf766a5 doc: split the spa_interfaces out as separate group from the spa_hooks 2021-08-05 09:51:40 +00:00
Wim Taymans
c6dc7e98fd dbus: protect against NULL data
Make sure we don't accidentally unref a NULL data.
2021-08-03 19:11:15 +02:00
Daniel Stone
bf112940d0 spa: Only test __cplusplus value when it's defined
In higher warning levels, clang complains about testing the value of
__cplusplus when it's not defined.
2021-08-03 15:43:59 +00:00
Peter Hutterer
51a177eb6d tree-wide: replace strstr(a, b) == a with spa_strstartswith()
spa_strstartswith() is more immediately understandable.

Coccinelle spatch file:
	@@
	expression E1, E2;
	@@
	- strstr(E1, E2) != E1
	+ !spa_strstartswith(E1, E2)

	@@
	expression E1, E2;
	@@
	- strstr(E1, E2) == E1
	+ spa_strstartswith(E1, E2)

Applied to the tree except for alsa/acp/compat.h because it looks like
that header is still mostly as-is from PA.
2021-08-02 08:24:21 +00:00
Huang-Huang Bao
9f2d6d6d28 bluez5: fix rounding error on hardware volume conversion
Ensure the conversions between spa_bt_volume_linear_to_hw and spa_bt_volume_hw_to_linear are reversible when
operating on hardware volume.
2021-07-30 08:46:14 +00:00
Simon Ser
73217818cc spa: document enum spa_video_format
References: https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/1470
2021-07-30 07:29:44 +00:00
Neal Gompa
1216371f8c bluez5: Use libfreeaptx instead of libopenaptx
libfreeaptx is a fork of libopenaptx prior to the dubious licensing
situation was introduced to the library.

As it's fully API compatible, let's use that instead for those who
want to use aptX support.

The library source is available at https://github.com/iamthehorker/libfreeaptx
2021-07-29 15:22:04 +00:00
Wim Taymans
2dabd337dc audioconvert: clear negotiated rate
When we clear the format on the non-dsp port, set the rate back to
0 so that we can negotiate a new rate if needed.
2021-07-29 13:35:41 +02:00
Peter Hutterer
4e90760155 spa: silence a doxygen warning
warning: documented symbol 'spa_log_error foo' was not declared or defined.
2021-07-29 14:03:00 +10:00
Wim Taymans
44583367db pod: add prop option to avoid fixation
Add a DONT_FIXATE flag to spa_pod_props. The flag avoids fixation
of the property by spa_pod_fixate().

When filtering properties, 'and' the flags together in the filtered
property. This mostly preserves the merged property flags. It also
merges the DONT_FIXATE flags so that when both sides can handle
the non-fixated result, it will be returned.

This can be used to let PipeWire filter out the common property
fields and leave the final selection of fields to the producer. This can
only work when the final selected field can be transported in some
other way than the format param, like on the buffer fields or in
metadata. One use case is negotiation of the DMABUF modifiers.

See #1084
2021-07-28 11:03:26 +02:00
Peter Hutterer
49f3d5842e test: replace all spa_assert() macros with spa_assert_se()
These are tests, we never want those to be optimized away.
2021-07-27 10:24:44 +10:00
Peter Hutterer
63d833dabf spa: use spa_assert_se() for bugs in the util string functions
These are programming bugs that should never happen, so let's always
abort.
2021-07-27 10:24:44 +10:00
Wim Taymans
78f52a7073 loop: avoid corruption of ringbuffer
The ringbuffer can't be written to from multiple threads.

When both the main loop and data thread do _invoke, they both write to
the ringbuffer and cause it to be corrupted because the ringbuffer is
not multi-writer safe.

Doing invoke from the thread itself is usually done to flush things out
so we really only need to flush the ringbuffer and call the callback.

See #1451
2021-07-26 11:39:48 +02:00
Pauli Virtanen
606108f409 spa: add spa_strstartswith 2021-07-24 14:36:03 +03:00
Javier Martinez Canillas
76cb5c1169 libcamera: remove unused buffer variable in LibCamera::stop()
To fix build warning about a variable being unused in LibCamera::stop():

[1/2] Compiling C++ object spa/plugins/libcamera/libspa-libcamera.so.p/libcamera_wrapper.cpp.o
../spa/plugins/libcamera/libcamera_wrapper.cpp: In member function ‘void LibCamera::stop()’:
../spa/plugins/libcamera/libcamera_wrapper.cpp:531:58: warning: unused variable ‘buffer’ [-Wunused-variable]
  531 |                 for (const std::unique_ptr<FrameBuffer> &buffer : this->allocator_->buffers(stream)) {
      |                                                          ^~~~~~
2021-07-23 07:59:10 +00:00