Commit graph

9809 commits

Author SHA1 Message Date
Georg Chini
dbaf450394 null-sink: Request no more than the configured latency from sink-input
In the case, where the latency is larger than the maximum block size,
module-null-sink will request multiples of the maximum block size from
the sink input instead of limiting the requested amount of data to the
the configured latency.

This patch fixes the problem.

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/554>
2021-05-17 14:40:15 +00:00
Hui Wang
80efd7a64c Revert "alsa-mixer: Set "Front" control to 0 dB on headphone path"
This reverts commit 96369919e5.

The commit was originally for the issue of Headphone can't output
sound, that was because the Headphone and Lineout share the 1st alsa
mixer and DAC, but this commit introduced a new issue of the speaker
is not muted after switching to headphone.

A recent merged kernel commit (f48652bbe3ae@linux) could fix the 1st
issue, so we could revert the fix of the 1st issue from PA, then the
2nd issue is fixed automatically.

BugLink: https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/747
Signed-off-by: Hui Wang <hui.wang@canonical.com>
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/553>
2021-05-17 14:30:33 +00:00
Jan Alexander Steffens (heftig)
2a07c83cfc build-sys: meson: Add missing include dir
Otherwise building module-echo-cancel fails here:

    FAILED: src/modules/module-echo-cancel.so.p/echo-cancel_adrian-aec.c.o
    cc -Isrc/modules/module-echo-cancel.so.p -I. -I../pulseaudio -Isrc -I../pulseaudio/src -I/usr/include/orc-0.4 -flto=auto -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -std=gnu11 -march=x86-64 -mtune=generic -O2 -p>
    ../pulseaudio/src/modules/echo-cancel/adrian-aec.c:30:10: fatal error: adrian-aec-orc-gen.h: No such file or directory
       30 | #include "adrian-aec-orc-gen.h"
          |          ^~~~~~~~~~~~~~~~~~~~~~

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/552>
2021-05-12 21:10:54 +02:00
Christopher Arndt
2af43a8baf Add port order metadata to JACK sink / source ports
Adds JACK metadata property to ports created by *module-jack-sink*
and *module-jack-source* with key `JACK_METADATA_ORDER`, the port index
(1-based, in order of creation) as value and type
`http://www.w3.org/2001/XMLSchema#int`.

This allows JACK applications, which use JACK metadata, to list or display
these ports in correct order.

See also: https://jackaudio.org/api/group__Metadata.html

Signed-off-by: Christopher Arndt <chris@chrisarndt.de>
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/550>
2021-05-03 12:19:17 +00:00
Patrick Gaskin
39125a0f2b win32: Use DACLs when setting socket permissions
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/548>
2021-05-03 11:43:10 +00:00
Patrick Gaskin
a238a58186 cli-command: Replace config dir with toplevel for .include on win32
This makes the behaviour match pa_{open,find}_config_file by
replacing PA_DEFAULT_CONFIG_DIR with the toplevel.

This fixes the hardcoded paths for {default,system}.pa.d introduced
in 45abd0b43c (!361).

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/545>
2021-05-03 10:58:45 +00:00
Igor V. Kovalenko
4ec89c27c9 bluetooth: adjust sync to source with different sample spec
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/544>
2021-05-03 10:49:32 +00:00
Patrick Gaskin
d21d0d89a5 build-sys: meson: Merge system_conf config data from default_conf
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/547>
2021-04-23 01:52:55 -04:00
Georg Chini
1c1d0c7827 stream-restore: Fix use of uninitialized variable
The variable card_name in sink_input_preferred_sink_changed_cb and
source_output_preferred_source_changed_cb could be used uninitialized,
which leads to invalid database entries.

This patch fixes the problem.

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/543>
2021-04-20 12:18:43 +02:00
Igor V. Kovalenko
f760143c22 build-sys: meson: do not install manpages for disabled parts
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/540>
2021-04-19 18:48:59 +00:00
Igor V. Kovalenko
424580a901 build-sys: meson: allow building client libraries only
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/540>
2021-04-19 18:48:59 +00:00
Martin Wilck
1a73fb9eb9 parecord: really fix recording OGG
432a91ed ("fix "Failed to open audio file" for FLAC and OGG)" claimed
to fix recording of OGG files with pacat, but it really fixed only
FLAC. This patch must be added on top to fix OGG, too.

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/542>
2021-04-19 18:24:34 +02:00
Georg Chini
468e3669aa loopback: Fix crash bug
The loopback message may be called after the sink input is already destroyed which causes
a crash. Also memory is leaked because the message object is not correctly freed.

This patch fixes the problems by adding a "dead" flag to the message structure and freeing
the message object on exit.

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/541>
2021-04-19 15:21:07 +00:00
Igor V. Kovalenko
38905a096c alsa-mixer: Allow selected fallback mappings in all profile sets
When fallback mapping is selected all subsequent profile sets containing
selected mapping are ignored. When there are only e.g. fallback input mappings
available, admitted profile set will only contain one profile with selected
first input fallback mapping and no outputs, and rest of profiles will only
contain outputs and no inputs. When there are only fallback input and output
mappings, there will be no profiles admitted at all.

Fix this by making sure that selected first fallback input or output mapping
is actually allowed to exist in all probed profile sets.

Note while this change allows selected fallback mappings to be found in duplex
configuraitons, probing fallbacks still can fail if there is more than one input
fallback and first one (selected) does not work in duplex configurations.

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/539>
2021-04-19 14:48:36 +00:00
Martin Wilck
432a91ed43 parecord: fix "Failed to open audio file" for FLAC and OGG
This patch fixes the following error:

$ pacat --file-format=ogg -r test.ogg
Failed to open audio file.
$ parecord sep.flac
Failed to open audio file.

libsndfile errors out if a WAV or OGG file is set to have anything but
SF_ENDIAN_FILE:

f4d1646e5c

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/526>
2021-04-19 13:35:48 +00:00
Igor V. Kovalenko
fec9eb178d bluetooth: disable HSP HS profile by default
A few headsets have issues if HFP HF profile connection is attempted before
HSP HS profile connection is closed. Looks like this could happen because
bluez bluetoothd alows to make simultaneous HSP HS and HFP HF peer connections.

One of affected headsets is WH-1000XM2

Until we find out how to prevent simultaneous HSP HS and HFP HF connections,
when native backend has HFP HF profile enabled (this is the default) do disable
HSP HS completely unless user explicitly request it via discovery modarg.

Do this by adding module-bluetooth-discover arg enable_native_hsp_hs,
default to inverse of enable_native_hfp_hf.

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/538>
2021-04-16 08:33:42 +03:00
Igor V. Kovalenko
e3fa937508 bluetooth: handle HFP codec list in any order
HFP HF peer can send +BAC= list of codecs in any order and pa only expects "1,2"
Fix this by actually parsing codec list elements while looking for "2" (mSBC)

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/537>
2021-04-14 21:30:27 +00:00
Lyndon Brown
651e0db07b proplist: tweak documentation for pa_proplist_get()
to clarify that only mutating proplist calls potentially invalidate results
of earlier get requests, thus addressing the confusion found at [1].

[1]: https://github.com/jnqnfe/pulse-binding-rust/issues/38

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/536>
2021-04-09 01:47:58 +01:00
Igor V. Kovalenko
1a194c9918 bluetooth: mSBC: log lost input audio packets at debug level
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/507>
2021-04-05 15:43:32 +00:00
Igor V. Kovalenko
6a92940796 bluetooth: add modarg to allow disabling mSBC codec
Add module-bluetooth-discover argument enable_msbc, default is true (enabled)

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/507>
2021-04-05 15:43:32 +00:00
Igor V. Kovalenko
310e2877a0 bluetooth: split BT codec from A2DP SEP configuration api
Common API for all bluetooth codecs is now pa_bt_codec.
API to negotiate and configure A2DP SEP over Bluez is now pa_a2dp_endpoint_conf.

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/507>
2021-04-05 15:43:32 +00:00
Igor V. Kovalenko
c7c9ca22ab bluetooth: set initial packet size to 60
Raise initial MTU size to fix frame size when hci can do 60 byte frames.

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/507>
2021-04-05 15:43:32 +00:00
Igor V. Kovalenko
9de895fe23 bluetooth: add more call indicators
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/507>
2021-04-05 15:43:32 +00:00
Igor V. Kovalenko
436a98a50b bluetooth: produce silence on mSBC decoding error
We are supposed to conceal packet loss. This is not trivial but we can at least
produce silence instead of breaking on mSBC decoding error.

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/507>
2021-04-05 15:43:32 +00:00
Igor V. Kovalenko
436813d8a8 bluetooth: remember negotiated HFP codec in native backend
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/507>
2021-04-05 15:43:32 +00:00
Igor V. Kovalenko
ddad63a23c bluetooth: show negotiated HFP codec
While codec switching for HFP is not implemented, show current codec via
messaging api.

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/507>
2021-04-05 15:43:32 +00:00
Igor V. Kovalenko
f0d32e9454 bluetooth: add mSBC to backend-ofono
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/507>
2021-04-05 15:43:32 +00:00
Igor V. Kovalenko
030dc8b968 bluetooth: prepare to redo transport writeout scheduling
Bluetooth SCO is synchronous stream, make our writes more uniformly paced.
To do this, first separate writing to socket from rendering a frame.

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/507>
2021-04-05 15:43:32 +00:00
Igor V. Kovalenko
976fc1d099 bluetooth: mSBC: ignore empty encoded frame
If input block size is shorter than SBC frame codesize, encoder will return 0.
Log this and skip whole input block.

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/507>
2021-04-05 15:43:32 +00:00
Igor V. Kovalenko
7d191b64d9 bluetooth: mSBC: ignore all-zero packets
This is a workaround for hardware/driver which inserts all-zero packets in what
otherwise looks like a valid mSBC stream.

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/507>
2021-04-05 15:43:32 +00:00
Igor V. Kovalenko
6c0c9cf845 bluetooth: use helper to set multiple transport object attributes
For mSBC to work correctly the following must be set correctly
- codec object
- transport write method
- transport setsockopt method

Use helper method to set all three simultaneously.
Static configuration structure may be cleaner solution.

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/507>
2021-04-05 15:43:32 +00:00
Igor V. Kovalenko
62776cc815 bluetooth: apply write MTU detection based on read packet size
HFP Audio Connection SCO configuration is negotiated symmetrically in both
directions, and USB HCI SCO packet framing is also symmetric in both directions.
This means that packet size will be the same for reads and writes over HFP SCO
socket.

HFP profile specification states that valid speech data shall exist on the
Synchronous Connection in both directions after the Audio Connection is
established.

This guarantees that an incoming packet will arrive shortly after SCO connection
is established. Use it's size to fix write MTU in case kernel value is wrong.

Discussion here https://lore.kernel.org/patchwork/patch/1303411/

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/507>
2021-04-05 15:43:32 +00:00
James Bottomley
4444ecad6f bluetooth: add wideband audio codec negotiation to HFP
The HFP protocol supports the ability to negotiate codecs if that is
supported by both AG and HF.  This patch adds advertising of codec
negotiation support and the ability to negotiate a codec change.  The
only currently supported extra codec (as of HF 1.7.1) is mSBC.  mSBC
requires that the transmission be done over an eSCO link with
Transparent Data.  The linux kernel ensures the former, but we have to
manually set the socket to transparent data.

Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/507>
2021-04-05 15:43:32 +00:00
James Bottomley
f22cfa8f81 bluetooth: add support for mSBC codec
Adding processing support for the mSBC codec is somewhat problematic,
because, although it is a SBC codec, the a2dp handling can't simply be
reused because the codec is used on an eSCO link with transparent
data, meaning the transmission unit has to be 48 bytes (fragmenting
the codec packets) and reassembly and boundary detection is required
to be done by the implementation.  Therefore we have to implement
separate render and push routines for msbc that do this fragmentation.

Fragmentation is done by emulating circular buffers.  The receive
(push) buffer is easy, since the mSBC packet size is 60, simply have a
buffer of this size in the sbc_info area where the fragments are
reassembled.  Once we have a full 60 bytes, decode and restart from
zero.  The send (render) buffer is more problematic, since the
transmit must be done from contiguous memory.  This means that the
buffer must be the lowest common multiple of the transmission unit and
the packet size.  This value is 240 since 240/48 == 5 and 240/60 == 4.
So the buffer pointers are reset at 240 which is a whole number of
both rendered packets and eSCO transmission units.

Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/507>
2021-04-05 15:43:32 +00:00
Igor V. Kovalenko
a7b21fb555 bluetooth: add CVSD codec implementation
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/507>
2021-04-05 15:43:32 +00:00
Igor V. Kovalenko
913e7767d6 bluetooth: unify decoder code paths
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/507>
2021-04-05 15:43:32 +00:00
Igor V. Kovalenko
3902cee4a5 bluetooth: unify encoder code paths
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/507>
2021-04-05 15:43:32 +00:00
Tanu Kaskinen
8a87af380a stream-restore: Fix NULL preferred device handling
When an application sets a device for a newly created stream, we treat
that as a temporary setting, and don't save it as the preferred device
for future streams. The handling for this was broken, however: if the
stream already had a preferred device saved in the stream-restore
database, that was unset.

This was a regression introduced in
bc0e728320 and
70bbbcdc84. These commits tried to detect
in subscribe_callback() when the preferred device is cleared, but as a
side effect the preferred device started to get cleared from the
database also when a stream was created with a device set by the
application.

There's no way for subscribe_callback() to distinguish the different
cases of the preferred device being NULL. This problem is solved by
using the PREFERRED_SINK/SOURCE_CHANGED hooks. The hooks are only called
when the preferred device really changes.

Fixes: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/issues/1063
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/535>
2021-04-05 15:17:15 +00:00
Tanu Kaskinen
737ebcdfdb sink-input, source-output: Add hooks for preferred device changes
The hooks are fired when the preferred device changes. This is useful
for module-stream-restore.

I added new set_preferred_sink/source() functions for firing the hooks.
The functions also log the preferred device changes.

There was already pa_sink_input_set_preferred_sink(), but that had a
side effect of moving the stream, so I needed a new function. Since it
can be confusing when the two similarly named functions should be
called, I added a comment for pa_sink_input_set_preferred_sink() that
explains the different situations.

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/535>
2021-04-05 15:17:15 +00:00
Igor V. Kovalenko
1f204a1357 bluetooth: prioritize native backend HFP HF connection
Bluez prepends newly registered profile to a list of supported profiles,
and new peer profile connections are attempted in reverse order of profile
registration.

Currently native backend would register HFP AG profile before HSP AG profile.
When peer supports both HFP HF and HSP HS profiles, this registration order
causes extra HSP HS connection attempt before native backend would reject it
to make sure peer is reconnected with HFP HF profile.

Reorder HSP AG profile registration before HFP AG to make sure peer supporting
both profiles connects with HFP HF profile first.

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/534>
2021-04-03 08:48:06 +03:00
Igor V. Kovalenko
7ca50bab2f bluetooth: update messaging api reference
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/525>
2021-03-27 11:18:22 +00:00
Igor V. Kovalenko
a2db3fcfb2 message-params: clean up
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/525>
2021-03-27 11:18:22 +00:00
Igor V. Kovalenko
1dd05f4a9b message-params: use JSON instead of custom format
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/525>
2021-03-27 11:18:22 +00:00
Igor V. Kovalenko
0ba768b2e9 json: add JSON encoder
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/525>
2021-03-27 11:18:22 +00:00
Igor V. Kovalenko
1df4a311d4 json: improve supported numbers
Use 64bit signed integers and fix double value conversion.

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/525>
2021-03-27 11:18:22 +00:00
Marijn Suijten
02027518af bluetooth: Only use hardware volume callbacks for peer attenuation
Setting these callbacks adds the HW_{VOLUME,MUTE}_CTRL flag even when
PulseAudio is solely responsible for performing attenuation whilst only
keeping the peer posted on changes.  For this case the hardware callback
is not registered at all but instead a hook is attached to catch
PA_CORE_HOOK_{SINK,SOURCE}_VOLUME_CHANGED.  Only when the peer performs
attenuation (the peer is in HeadSet/HandsFree role) are the callbacks
used, without touching PA software volume at all.  A future change could
potentially use software volume to compensate for the extremely coarse
16 steps of volume control in HSP and HFP, and to allow volume over
100%.

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/519>
2021-03-26 21:09:36 +01:00
Georg Chini
015028d7e3 alsa-sink: Do not increase watermark when requested to rewind 0 bytes
Since commit cb91d7a1 the watermark is increased when there is nothing to rewind.
This is also done in the case when there was actually no rewind requested at all,
so the watermark is increased needlessly.
This patch fixes the issue by skipping the rewind if none is requested.

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/530>
2021-03-25 02:29:42 +00:00
Edward Lee
169f8c5f2c Win32: Use WAVEFORMATEX for multi-channel audio output on Windows.
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/359>
2021-03-23 13:12:38 -04:00
Edward Lee
e12ba8eaee Win32: Fix build issues.
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/359>
2021-03-23 13:12:18 -04:00
Marijn Suijten
8db4dff2c5 bluetooth: Set up hardware gain control if init volume is received late
Originally written for A2DP this rework of that patch enables late-bound
hardware volume control on HFP and HSP.  As per the specification the
headphones (where gain control for both speaker and microphone could
happen in hardware on the peer) are supposed to send initial values for
these before the SCO connection is created; these `AT+VG[MS]` commands
are also used to determine support for it.  PA uses this information in
`add_{sink,source}` to attach hardware volume callbacks, _if_ it is
supported.  Otherwise PA performs the attenuation in software.

Unfortunately headphones like the WH-1000XM3's connect to A2DP
initially and only send `AT+VGS` (microphone hardware gain is not
supported) _during_ SCO connection when the user switches to the HFP
profile afterwards; the callbacks set up dynamically in
`rfcomm_io_callback` are written after the sink and source have been
created (`add_{sink,source}`), leaving them without hardware volume
callbacks and with software volume when adjusted on the PA side.  (The
headphones can still send volume updates resulting in abrupt changes if
software and peer volume differ.  Furthermore the same attenuation is
applied twice - once in PA software, once on the peer).

To solve this problem we simply check whether the callbacks have been
attached whenever the peer sends a volume change, and if not attach the
callbacks to the sink/source and reset software volume.

Fixes: d510ddc7f ("bluetooth: Perform software attenuation until HF/HS reports gain control")
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/528>
2021-03-17 22:57:38 +01:00