Commit graph

9869 commits

Author SHA1 Message Date
Igor V. Kovalenko
815dd2d627 bluetooth: prefer headset HFP HF connection with native backend
When HFP HF support is enabled in native backend, peer HFP HF profile connection
is preferred over same peer HSP HS profile connection if peer supports both
profiles.

Enforce the preference by rejecting HSP HS profile connections from such peer.

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/491>
2021-02-23 06:54:39 +00:00
Igor V. Kovalenko
70171158ee bluetooth: fix headset=auto ofono handover
Native backend implements HFP AG but not HFP HF yet, therefore headset=auto
functionality is still needed if HFP HF is required.

To make headset=auto work again, drop both HFP AG and HSP AG roles while
performing handover from native backend when oFono is detected running.

While at it, restore profile description to Headset Head Unit (HSP/HFP)
to note that HFP may be still provided via oFono backend.

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/491>
2021-02-23 06:54:39 +00:00
Igor V. Kovalenko
8491477b3e bluetooth: enable module-bluez5-discover argument enable_native_hfp_hf
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/491>
2021-02-23 06:54:39 +00:00
James Bottomley
cb193e19ee bluetooth: make native the default backend
Change default backend from 'auto' to 'native' so that in the usual
install pulseaudio uses the native backend with HFP_HF handling.

set default to false unless the backend is the native one, in which
case the default becomes true.

Additionally set default value of enable_native_hfp_hf to false unless
the backend is the native one, in which case the default becomes
true. so that we only bind the HFP_HF end point in the native case
(leaving it free for ofono in the ofono backend or auto case)

Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/491>
2021-02-23 06:54:39 +00:00
James Bottomley
485a64642e bluetooth: add correct HFP rfcomm negotiation
HFP 1.6 requires a stateful negotiation of AT commands.  The prior
version got away with initialising HFP simply by replying 'OK' to
every negotiation attempt.  This one actually tries to parse the state
and make sure the negotiation occurs correctly

Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>

---

v4:

- Update for PA 11.0
- Finally sort out CIND negotiaton for complex headsets

v3:

- remove internal debugging
- added comment for t->config being not null for hfp
- removed unused returns from hfp_rfcomm_handle()
- remove rfcomm comment
- use pa_startswith
- simplify negotiation

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/491>
2021-02-23 06:54:39 +00:00
James Bottomley
66ed99a13d bluetooth: separate HSP and HFP
When all headsets supported both HSP and HFP, life was good and we
only needed to implement HSP in the native backend.  Unfortunately
some headsets have started supporting HFP only.  Unfortuantely, we
can't simply switch to HFP only because that might break older HSP
only headsets meaning we need to support both HSP and HFP separately.

This patch separates them from a joint profile to being two separate
ones.  The older one retains the headset_head_unit name, meaning any
saved parameters will still select this (keeping us backward
compatible).  It also introduces a new headset_handsfree.

For headsets that support both HSP and HFP, the two profiles will
become separately visible and selectable.  This will only matter once
we start adding features to HFP that HSP can't support (like wideband
audio).

Signed-off-by: <James.Bottomley@HansenPartnership.com>

---
v6:

- merge profile switching fixes patch from Rodrigo Araujo

v5:

- rename option to enable_native_hfp_hf
- don't call profile_done for HFP_HF unless it was initialised

v3:

- Update for PA 11.0

v2:

- fold in review feedback
- add global disable option for not registering HFP

v3:

- change parameter to enable_profile_hfp
- update device_supports_profile to be aware of hfp/hsp exclusivity
- change parameter to enable_profile_hfp_hf

bluetooth: separate HSP and HFP (to me merged with this patch)

Hi.

First, just to say that your patches are going great. Finally I can use
the microphone of my HFP only headset (a version of a Bluedio T2+).

So far, I've only encontered one problem: the auto_switch option of
module_bluetooth_policy stops working. Dug through the code and I think
you missed a few spots were you have to hangle the new headset_handsfree
profile in module_bluetooth_policy.c

Applying the following after applying your v5 patches fixed the issue
for me, now when I start making a VOIP call the profile switches to
headset_handsfree and the mic works automatically, and when the call
finishes it reverts back to a2dp.

Thanks and best regards.

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/491>
2021-02-23 06:54:39 +00:00
James Bottomley
709909a1fc bluetooth: use consistent profile names
The PA_BLUETOOTH_PROFILE names should mirror the PA_BLUETOOTH_UUID
names using profile_function instead of randomly made up names.  Fix
this with the transformation:

PA_BLUETOOTH_PROFILE_HEADSET_HEAD_UNIT -> PA_BLUETOOTH_PROFILE_HSP_HS
PA_BLUETOOTH_PROFILE_HEADSET_AUDIO_GATEWAY -> PA_BLUETOOTH_PROFILE_HFP_AG

Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>

---

v4: update for PA 11.0

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/491>
2021-02-23 06:54:39 +00:00
Henri Chain
bca4c22832 systemd: move to session slice
As per https://systemd.io/DESKTOP_ENVIRONMENTS/
(the default is app.slice which is not appropriate for pulseaudio)

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/506>
2021-02-18 20:42:25 +00:00
Georg Chini
6b2844a61d source-output: Fix source-output volume after move of virtual source stream
When the source-output of a virtual source with volume sharing disabled is moved,
the source output volume is reset to 100%. This patch fixes the problem by
applying the virtual source volume to the source-output after the move.

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/509>
2021-02-17 21:42:14 +01:00
Igor V. Kovalenko
b1f599dcd9 bluetooth: remove unwanted change from bluez fallback code
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/504>
2021-02-15 15:42:22 +00:00
pseyfert
d74c47340a fix handling of symbolic port names in zsh completion
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/500>
2021-02-15 15:06:35 +00:00
Igor V. Kovalenko
de8b7c0d8f build-sys: meson: support elogind alternative for module-systemd-login
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/502>
2021-02-12 20:34:11 +03:00
Igor V. Kovalenko
156e16f941 build-sys: meson: add tcp-wrappers
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/498>
2021-02-12 17:14:24 +00:00
Igor V. Kovalenko
f7f9c70b0f build-sys: drop gconf support
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/499>
2021-02-12 17:05:07 +00:00
Paul Seyfert
faa1a7e042 zsh-completion Add completion of sample names
This closes #201.

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/501>
2021-02-10 19:37:07 +01:00
Marijn Suijten
c05c6f9eee bluetooth/gst: Unify encoder and decoder pipeline setup
The encoding and decoding pipeline are essentially identical: both push
data in via an appsrc, route it through a codec-specific (opaque)
element, and finally pull data out of an appsink. The code already makes
it impossible to have an encoding and decoding pipeline simultaneously
set up in `gst_info`, and converting `bool for_encoding` to a tri-state
(encode, decode, or both) would be messy; particularly when encoding and
decoding could possibly differ in format.

This change removes a swath of code and removes the possibility of
misusing `enc_` or `dec_` in the wrong place (ie. after copying a bit of
code and forgetting to rename one or two). When bidirectional codecs
come online a second codec instance (`gst_info`) can simply be created
and controlled independently.

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/487>
2021-02-01 17:23:46 +00:00
Marijn Suijten
92af2c90f9 bluetooth/aptx: Call the non-HD encode_buffer function
For consistency with its decode_buffer counterpart.

For the time being the base function only performs an extra check and
logs an error when no data has been written into the GStreamer encoding
pipeline.

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/487>
2021-02-01 17:23:46 +00:00
Marijn Suijten
6b5857c1ac bluetooth/aptx: Simplify lifetime of caps
Fixes: 73c80ffba ("bluetooth/aptx: Deduplicate caps setup for encoding and decoding")
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/487>
2021-02-01 17:23:46 +00:00
Igor V. Kovalenko
bf99b4bdfc bluetooth: support increasing bitrate for SBC XQ
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/476>
2021-02-01 17:10:52 +00:00
Igor V. Kovalenko
89082cbfaa bluetooth: a2dp dual channel SBC XQ codec configurations
Desired SBC bitpool value is calculated from target bitrate limit.

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/476>
2021-02-01 17:10:52 +00:00
Marijn Suijten
ff2f16294f bluetooth: Remove unused ts_elapsed variable
Fixes: 969951121 ("bluetooth: allow increasing output bitrate")
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/477>
2021-02-01 16:10:12 +00:00
Marijn Suijten
f9bf21e012 tests: Update ladspa-dbus to Python 3
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/477>
2021-02-01 16:10:12 +00:00
Marijn Suijten
537bf3cf8e treewide: Use DBus defines instead of direct string literals
While cleaning up the BlueZ counterpart of strings defined in
preprocessor macros it is only consistent to take care of all DBUS_
macros as a whole.

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/477>
2021-02-01 16:10:11 +00:00
Marijn Suijten
670f585530 bluetooth: Consistently use BlueZ defines for strings
These errors and interface names shoudld all reuse predefined constants.

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/477>
2021-02-01 16:10:11 +00:00
Marijn Suijten
99ac831fef bluetooth: Unify BlueZ macro defines shared between util and native
Define all BLUEZ_ macros once in the shared header, instead of twice in
both backend-native.c and bluez5-util.h.

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/477>
2021-02-01 16:10:11 +00:00
Marijn Suijten
87f08a7b56 bluetooth: improve indentation around dbus_message_iter_open_container
Consistently use newlines and the same indentation style for all calls
to dbus_message_iter_open_container in Bluetooth code.

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/477>
2021-02-01 16:10:11 +00:00
Georg Chini
89bae1b3b7 null-source: Change max_rewind when the latency changes
The null-source did not change max_rewind when changing the latency. This
patch fixes the issue.

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/493>
2021-02-01 16:03:46 +00:00
Georg Chini
12cf6da242 sink: Unlink monitor source before unlinking sink
Unlinking the monitor source after unlinking the sink leads to a crash when the monitor
source is master of a virtual source. Changing the unlink order fixes the problem.

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/493>
2021-02-01 16:03:46 +00:00
Jaroslav Kysela
597a1eb1ba alsa: fix the plug: PCM device name creation
The plug: ALSA PCM device name can pass any device name
even with argument, but the syntax is:

plug:SLAVE='<pcm_device_name>'

BugLink: https://github.com/alsa-project/alsa-ucm-conf/pull/75#issuecomment-768555182
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/492>
2021-01-28 08:50:09 +01:00
Igor V. Kovalenko
c6309a9c18 bluetooth: pass output_rate_refresh_interval_ms module parameter
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/488>
2021-01-26 10:01:47 +03:00
Sanchayan Maity
c686215268 bluetooth: ldac: Use format as FLOAT32LE
LDAC encoder already supports S16, S24, S32 and F32LE. Using FLOAT32LE
for the sample format would avoid the additional call for conversion to
pa_sconv_s32le_from_float32ne. perf tool shows this as being the function
called frequently after encode. So, just avoid this by using sample format
as F32LE.

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/486>
2021-01-22 20:10:54 +05:30
Marijn Suijten
9431e96ae4 bluetooth/gst: Move common enc/dec initialization back to generic init
Now that codec-specific code only touches its own bin and not any
elements (appsink/src) outside of it, make things official by
initializng them later in gst_codec_init where they are actually needed.

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/484>
2021-01-22 11:04:19 +01:00
Marijn Suijten
46a97d76eb bluetooth/aptx: Use capsfilter instead of appsink/appsrc "caps" prop
Make the codec-specific initializer more generic by not touching any
elements outside of its own GstBin.

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/484>
2021-01-22 10:41:20 +01:00
Marijn Suijten
73c80ffba0 bluetooth/aptx: Deduplicate caps setup for encoding and decoding
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/484>
2021-01-22 10:41:20 +01:00
Marijn Suijten
da1600eb61 bluetooth/gst: Determine PA input/output caps in generic code
Make the code ever so slightly more generic by not using appsrc and
appsink in codec-specific logic when assigning caps specific to the raw
(PCM) format provided by or returned to PA.

Note that caps have to be set (= event) after starting, can't send
events in flushing state.

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/484>
2021-01-22 10:41:19 +01:00
Marijn Suijten
db73004a3a bluetooth/gst: Add assertions around element_add_pad and bin_add
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/484>
2021-01-22 09:47:09 +01:00
Tanu Kaskinen
ca3fd62c71 i18n: Update .pot and .po files
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/485>
2021-01-22 09:12:32 +02:00
Jan Kuparinen
b2c664e9bc Translated using Weblate (Finnish)
Currently translated at 95.1% (472 of 496 strings)

Translation: pulseaudio/pulseaudio
Translate-URL: https://translate.fedoraproject.org/projects/pulseaudio/pulseaudio/fi/
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/485>
2021-01-22 09:09:47 +02:00
Jan Kuparinen
951c259319 Translated using Weblate (Finnish)
Currently translated at 94.9% (471 of 496 strings)

Translation: pulseaudio/pulseaudio
Translate-URL: https://translate.fedoraproject.org/projects/pulseaudio/pulseaudio/fi/
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/485>
2021-01-22 09:09:47 +02:00
Igor V. Kovalenko
7e9e9e271a bluetooth: allow increasing SBC output bitrate
SBC codec decrements bitpool value by fixed amount each time it is asked to
reduce output bitrate. This results in reduced audio quality with SBC codec.

Implement increase_encoder_bitrate for SBC codec by adding 1 to bitpool value
each time encoder bitrate needs to be increased to restore SBC audio quality.
While at it, remove bitpool decrement limit to use connection agreed value
instead as we will be able to restore quality later.

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/474>
2021-01-21 15:16:19 +00:00
Igor V. Kovalenko
9699511215 bluetooth: allow increasing output bitrate
Bluetooth thread may ask encoder to reduce bitrate if writing is not keeping up
with inputs or writing to bluetooth socket takes too much time.

Assuming conditions leading to reduced bitrate are intermittent, allow periodic
attempts to increase encoder bitrate, by default at most twice per second.

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/481>
2021-01-21 15:10:15 +00:00
Marijn Suijten
ac33a01f30 bluetooth: Add missing can_be_supported check to is_codec_available
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/479>
2021-01-21 15:03:39 +01:00
Marijn Suijten
519052e77e bluetooth: Check support for encoding and decoding separately
As suggested in [1]:

This way it is possible for a codec to have both the encoding and
decoding part optional, instead of getting both or nothing (where PA
theoretically supports both).

In addition this cleans up code that was previously checking the
existence of a function pointer, or nothing at all (switch_codec).

[1]: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/440#note_768146

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/479>
2021-01-21 15:03:37 +01:00
Sanchayan Maity
8816b6b05b bluetooth: Fix unregistering of the message handler
In cases, where codec initialisation may fail, we still try
unregistering the message handler. Do not try unregistering
the handler if it was not registered in the first place.

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/483>
2021-01-21 18:41:25 +05:30
Arun Raghavan
3a4038f3ff gitignore: Add install/ for local prefixed installs
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/475>
2021-01-19 10:57:17 -05:00
Marijn Suijten
ac8f0c2070 bluetooth/bluez5-util: Do not reply to ClearConfiguration
Similar to the situation/comment in `endpoint_release` BlueZ does not
request any reply to `ClearConfiguration()` either; sending one results
in the same "0 matched rules" warning from dbus-daemon:

    dbus-daemon[1309]: [system] Rejected send message, 0 matched rules; type="method_return", sender=":1.71" (uid=1000 pid=87548 comm="../build/src/daemon/pulseaudio -vvvv -n -F ../buil") interface="(unset)" member="(unset)" error name="(unset)" requested_reply="0" destination=":1.3" (uid=0 pid=1308 comm="/usr/lib/bluetooth/bluetoothd -d ")

Solve this by only creating a return message when an (othwise empty)
reply is solicited for, just like in `endpoint_release`.

Unfortunately we also have to make sure to not send any error back if no
reply is requested, but fortunately an argument parsing error here is
extremely unlikely.

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/472>
2021-01-19 15:47:26 +00:00
Sanchayan Maity
cdbb73f9ad bluetooth: Move codec specific bits to their own respective files
We move the codec specific bits to their own respective files and now
make the codec specific initialisation use a GstBin, which the generic
GStreamer module now uses in the pipeline.

It is job of the codec specific function to add elements in the GstBin
and link the added elements in the bin. It should also set up the ghost
pads as a GstBin has no pads of it's own and without which the bin
cannot be linked to the appsrc/appsink.

Also, we now only initialise either the encoding or the decoding
pipeline and not both. The codec init API already gets passed the
for_encoding flag. We pass and use the same to codec specific init
functions.

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/440>
2021-01-19 13:43:42 +05:30
Sanchayan Maity
ed44fa1856 bluetooth: Register an endpoint according to encode or decode support
As we now support codecs other than SBC, we might have codec which does
not have an encode or a decode capability. Specifically, in the case of
LDAC there isn't a known decoder implementation available. For such a
case, we should not register the corresponding endpoint.

In case of LDAC, as decoding cannot be supported, we should not register
a sink endpoint or vice versa in the other scenario.

To do this, we check if encode_buffer or decode_buffer entry for a codec
has been set in pa_a2dp_codec and accordingly prevent or allow it's
registration.

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/440>
2021-01-19 13:43:42 +05:30
Igor V. Kovalenko
366bd5615c bluetooth: Make GStreamer threads realtime
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/440>
2021-01-19 13:43:42 +05:30
Sanchayan Maity
8289bdb76d bluetooth: Prevent registration of an unavailable codec at runtime
When it comes to codecs provided via GStreamer, we register all codecs
if GStreamer option is enabled for bluez5 via meson. However, the
GStreamer plugin required for the codec might not be present on the
system. This results in the codec being available for registration with
the bluez stack or selection by the user, but, trying to use the said
codec then fails.

To prevent the above, we now use the can_be_supported codec API to check
if the codec is usable and if not, we do not register the said codec and
also prevent users from switching to it.

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/440>
2021-01-19 13:43:42 +05:30