Commit graph

9657 commits

Author SHA1 Message Date
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
Sanchayan Maity
d61493640e bluetooth: Introduce a can_be_supported API for A2DP codecs
This API internally checks if a requested codec can be supported on the
system. This is especially required for codecs supported via GStreamer
where the availability of a plugin decides if the said codec can be
supported.

This will be used to prevent registration of a codec which the remote
endpoint device might be able to support, but, PulseAudio can't as the
codec is not available on the system due to the absence of a plugin.
We can also prevent listing or switching to an unavailable codec.

Note that the codec negotiation happens with the bluez stack even before
a device is connected. Because of this, we need to make sure that gst_init
is called before checking for the availability of a plugin. Since
module-bluez5-device gets loaded only after a connection to the device
has been established, doing the gst_init in that or one of the bluetooth
modules is not feasible.

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/440>
2021-01-19 13:43:42 +05:30
Sanchayan Maity
6044169763 bluetooth: Add support for getting current active codec
For example, using the following on the command line will return the
current codec for a bluetooth device

pacmd send-message /card/bluez_card.4C_BC_98_80_01_9B/bluez get-codec

where 4C_BC_98_80_01_9B is the bluetooth device.

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/440>
2021-01-19 13:43:42 +05:30
Sanchayan Maity
4ce996b74a bluetooth: Add currently active codec name to card/sink/source proplist
This exposes the currently active codec on the source or sink via the
proplist and can be seen in output of pacmd list-sinks/list-sources.
Also set it on the card. In case of a bi-directional codec, the codec
for the sink and source could be different. For example, for aptX-LL,
the codec name on card, sink and source would be aptx-ll, aptx and sbc
respectively.

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/440>
2021-01-19 13:43:42 +05:30
Sanchayan Maity
2fea838e50 bluetooth: Add support for getting list of negotiated codecs
For example, using the following on the command line will return the
list of possible codecs for a bluetooth device

pacmd send-message /card/bluez_card.4C_BC_98_80_01_9B/bluez list-codecs

where 4C_BC_98_80_01_9B is the bluetooth device.

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/440>
2021-01-19 13:43:42 +05:30
Sanchayan Maity
3377964889 bluetooth: Add aptX support via GStreamer
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/440>
2021-01-19 13:43:42 +05:30
Sanchayan Maity
ef4762a416 bluetooth: Add LDAC support via GStreamer
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/440>
2021-01-19 13:43:42 +05:30
Sanchayan Maity
a407e9aafa bluetooth: Add a generic GStreamer codec module
This adds a generic gstreamer codec module based on which other
bluetooth codecs viz. aptX, aptX-HD, LDAC and AAC can be supported.

The GStreamer codec plugins used here themselves depend on the native
codec implementation.

aptX/aptX-HD -> libopenaptx
LDAC         -> libldac
AAC          -> Fraunhofer FDK AAC

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/440>
2021-01-19 13:43:42 +05:30
Sanchayan Maity
3447335da9 bluetooth: Support A2DP codec switching via messaging API
This uses the messaging API to initiate a codec switch.

While a particular codec might be applicable only for a particular
profile, for eg. aptX can only be applicable for A2DP sink or source
and not for let's say HSP, the codec switching logic has not been
tied to the logic for switching profiles.

Codec can be switched by running the following on the command line.

pacmd send-message /card/bluez_card.XX_XX_XX_XX_XX_XX/bluez switch-codec{"ldac_hq"}
pacmd send-message /card/bluez_card.XX_XX_XX_XX_XX_XX/bluez switch-codec {"ldac_mq"}
pacmd send-message /card/bluez_card.XX_XX_XX_XX_XX_XX/bluez switch-codec {"ldac_sq"}
pacmd send-message /card/bluez_card.XX_XX_XX_XX_XX_XX/bluez switch-codec {"aptx_hd"}
pacmd send-message /card/bluez_card.XX_XX_XX_XX_XX_XX/bluez switch-codec {"aptx"}
pacmd send-message /card/bluez_card.XX_XX_XX_XX_XX_XX/bluez switch-codec {"sbc"}

Codec name passed above is matched against pa_a2dp_codec->name. Note that
the match is case sensitive. XX_XX_XX_XX_XX_XX needs to be substituted with
the actual bluetooth device id.

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/440>
2021-01-19 13:43:42 +05:30
Sanchayan Maity
5284b450e7 bluez5-util: Add support for using RegisterApplication D-Bus API
A2DP codec switching needs new version of bluez as older version does not
provide needed org.freedesktop.DBus.ObjectManager and RegisterApplication
DBus APIs. As a preparation for the next step of adding codecs and then
codec switching, add support for using the new API.

Getting list of supported codecs by remote device is supported only by new
version of bluez daemon. If the RegisterApplication API fails, we
fallback to the older RegisterEndpoint API and only register the SBC
codec.

For more information, see
https://dbus.freedesktop.org/doc/dbus-specification.html#standard-interfaces-objectmanager
https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc/media-api.txt

This changeset has been taken from Pali Rohár's A2DP codec patch
series but separated out to only include the D-Bus specific changes.

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/440>
2021-01-19 13:43:42 +05:30
Sanchayan Maity
fca6a2fd68 bluetooth: a2dp-codec-util: Use lower index for higher priority
Instead of letting a codec with higher index have higher priority,
just use a lower index for high priority. This allows the for loop
iterating over the codecs to be written in a straightforward manner
and not have to iterate from the end. FWIW Pipewire does the same.

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/440>
2021-01-19 13:43:42 +05:30
Igor V. Kovalenko
f7c84b3217 map-file: regenerate
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/461>
2021-01-18 17:57:41 +00:00
Igor V. Kovalenko
353c013780 buildsys: meson: implement update-map-file target
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/461>
2021-01-18 17:57:41 +00:00