Commit graph

85 commits

Author SHA1 Message Date
Huang-Huang Bao
03cde9751b
bluez5: guard against device profile
Invalid device profile should not be set.
2021-05-11 19:22:42 +08:00
Huang-Huang Bao
0c102b3e33
bluez5: emit SPA_PROP_softMute when route mute changed
Fixes #1137
2021-05-04 01:11:14 +08:00
Andrea Gelmini
47ef2b6b09 Fix typos 2021-04-30 07:40:20 +00:00
Wim Taymans
5bf2144438 spa: improve volume handling
Make a new softVolume property that contains only the soft volume
to apply.

In the case of HW/SW volume, we pass the real volume in the
channelVolume and the leftover volume in softVolume. We don't
use the monitorVolume for this anymore because it is a completely
separate volume handled by the merger node.

This way, channelVolume always represents the effective volume
set on routes, channelmix and merger and only the softVolume (when
available) is applied as software volume by channelmix.

This makes things map a bit better to what is actually happening with
the real volume and leftover software volumes after applying the
hardware volumes in the device.

With this change, the volume on the monitor is not affected by the
sink volume anymore and we can use the monitorVolume for this later.

This also means that the monitor volume in pavucontrol of the sinks
does not change when the sink volume changes. PulseAudio is inconsistent
here: If the volume is HW, the monitor volume is not affected, if the
volume is SW, it is. In PipeWire there is an option in merger to
let the volume affect the monitor with monitor.channel-volumes = true.
2021-04-29 12:46:29 +02:00
Huang-Huang Bao
8129b6658e bluez5: rename 'bluez5.reconnect-profiles' property to 'bluez5.auto-connect'
Avoid confusion with 'ReconnectUUIDs' in bluez policy config. See #1081.
2021-04-22 07:36:47 +00:00
Huang-Huang Bao
f44d00424f bluez5: don't clear dynamic node flag from node id in volume changed handler
It causes transport state handler don't emit node removing info.
Fixes #1080.
2021-04-22 07:34:02 +00:00
Huang-Huang Bao
01f2c91b89 bluez5: fix HSP HS profile enumeration
HSP don't supports codec switching.
2021-04-21 08:58:48 +00:00
Huang-Huang Bao
98d1a3cb16
bluez5: improve bluetooth profile descriptions, make them more translatable 2021-04-18 16:53:45 +08:00
Huang-Huang Bao
edee633f96
bluez5: add property to enable hardware volume control 2021-04-17 19:35:46 +08:00
Huang-Huang Bao
80f6ddf526
bluez5: add hardware volume support
Add necessary apis to bluez transport.
Add A2DP(AVRCP) absolute volume support. Source volume can only update to adapter node but not from due to AG nodes don't have route.
Since A2DP/HSP/HFP volume is already percentage itself, it has been mapped to pulseaudio volume then converting to linear volume.
2021-04-17 19:07:35 +08:00
Wim Taymans
036c54b043 Add i18n support for some more user-visible strings 2021-04-15 17:56:40 +02:00
Dmitry Sharshakov
97b01ed9b0 bluez5: add a property to select default profile 2021-04-04 08:43:09 +00:00
Wim Taymans
f0ab2bc1db bluez5: pass the route save property around
So that volumes are saved by the session manager.

Fixes  #995
2021-03-30 16:31:17 +02:00
Pauli Virtanen
f330446291 bluez5: better error/malformed input handling
Safer parsing of AT commands, additional null and error checks.
2021-03-27 14:38:31 +00:00
Huang-Huang Bao
bd7dba617f
bluez5: fix SPA_PROP_bluetoothAudioCodec param prop setting
Remove 'const' from 'codec_id' declaration.
2021-03-27 09:27:33 +08:00
Pauli Virtanen
51b0248d09 bluez5: update a2dp codec list when remote endpoints change 2021-03-26 16:59:07 +00:00
Pauli Virtanen
a552655edc bluez5: add bluetoothAudioCodec property to device
Also make the "codecless" profiles to automatically switch to the codec
profiles.
2021-03-26 16:59:07 +00:00
Huang-Huang Bao
34c9f24d2a bluez5: autoconnect device profiles on startup
Auto-connect all paired & trusted devices on startup.
Since devices that already connected or powering off would reject the connecting requests, it should be fine with this behavior.
Also reconnect remaining profiles if only partial profiles are connected.
2021-03-26 14:15:55 +00:00
Wim Taymans
fc44013d17 device: place the number of routes in the nodes
So that we can know if this node has routes or not.
Nodes without routes might need their volumes restored directly
with the node properties, like streams. Nodes with a route need their
volumes set on the device managing the node.
2021-03-22 16:43:54 +01:00
Pauli Virtanen
132786c202 pulse-server: implement send_object_message
Use it for providing Bluez codec listing/switching interface.  It
currently works by just switching device profiles.
2021-03-20 23:30:38 +02:00
Pauli Virtanen
b7a1f11842 bluez5: check profile existence before listing in routes
Check profile existence before listing in routes, since it depends on
codec availability that may vary.
2021-03-20 20:01:52 +00:00
Pauli Virtanen
79e098bdf2 bluez5: implement HFP codec switching
Implement switching HFP codecs in bluez5-devices, currently only for
backend-native.

Codecs are exposed via profiles similarly as for A2DP.

Some hardware appears to not properly reply to the +BCS message. Catch
these cases with a timeout, in which case we fall back to previously
existing transports.
2021-03-20 20:01:52 +00:00
George Kiagiadakis
bca9e55d12 bluez: add a new "Audio Gateway" device profile
This profile is meant to be used with audio gateways, such as mobile
phones, making pipewire act as a headset. It activates all 3 "dynamic"
nodes (all of which are "Stream/*/Audio"), allowing both A2DP source
and HSP/HFP AG to be available at the same time. Ultimately, the remote
device (the AG), is the one that decides which profile to use and pipewire
just creates/destroys the appropriate stream nodes dynamically.

To make things less confusing, the HFP/HSP profile is now only available
if the remote device is a Head Unit and the A2DP profile is only available
if the remote device has an A2DP Sink.

If the device has both A2DP Source & A2DP Sink (not sure if this is a real world
possibility, but just in case...), the A2DP profile allows using them both,
while the AG profile will only allow the source.

In addition, to keep things less complex, the routes are now only used for
device nodes (the "Audio/*" ones). A2DP source and HSP/HFP AG never have a route.
Restoring their props should be possible to be handled by the restore-stream
module.
2021-03-19 20:27:49 +02:00
George Kiagiadakis
34425a8027 bluez: make sco nodes dynamic when the remote end is an AG 2021-03-19 11:49:41 +00:00
Wim Taymans
8a4d2ed7ce pipewire-pulse: set correct errno values
errno should be set to the positive errno value.

This does not cause problems except for the pulse-server where the
errno value is negated and returned as an error result.
2021-03-19 12:46:05 +01:00
George Kiagiadakis
a75fe69c8e bluez5: emit & remove the A2DP source node depending on transport state
Typically a source stops the connection when it has nothing to play
and this causes the transport to become "idle" and our A2DP source
also stops. However, the node is still present and "running" (if linked),
which causes the graph to underrun as it receives no data from this node.

This patch dynamically creates and destroys the a2dp source node depending
on the transport state. So, when the transport is idle, there is no node
in the graph at all.
2021-03-18 14:34:27 +00:00
Huang-Huang Bao
374180e211 bluez5: pass per-device settings to codec handler, make 'bluez5.sbc-xq-support' a per-device setting 2021-03-16 10:31:08 +00:00
Huang-Huang Bao
af8272fe08 bluez5: create device handle before profile negotiation started so that profile handler can retrieve per-device settings 2021-03-16 10:31:08 +00:00
Pauli Virtanen
8f075619b2 bluez5: set volume for both channels when switching HFP -> A2DP
Retain mono volume level set with HFP, for A2DP, in case session manager
fails to restore it.
2021-03-15 23:24:40 +02:00
Pauli Virtanen
c7ad443e03 bluez5: update supported codec list when profiles changed
When A2DP is connected and new device profiles appear, update also
supported codec list.

Fixes missing codec profiles when A2DP is connected late.
2021-03-15 20:47:22 +02:00
Pauli Virtanen
98bedb3895 bluez5: don't set a2dp codec for source device initial profiles
Source devices don't have the a2dp codec profiles, so don't set a codec
profile as the initial one.
2021-03-10 21:32:01 +02:00
Pauli Virtanen
511bafb436 bluez5: release transports on profile change
SCO transports have timer-delayed release, but they need to be released
immediately when changing profiles to close connections before switching
to A2DP.
2021-03-08 23:42:08 +02:00
Pauli Virtanen
a99f3a90ef bluez5: correct EnumRoute availability
Mark bluez5 routes always available in EnumRoute, because there's always
a device connected.

Fixes default-route resetting profiles back, when they are manually
changed.
2021-03-07 01:37:57 +02:00
Pauli Virtanen
e42261c6d2 bluez5: remove per-device codec filtering
This does not work as intended, because we no longer do a codec switch
on device connect.  It should be done in a different way, but since it's
not used for anything right now, can as well remove it.
2021-03-06 15:19:14 +02:00
Pauli Virtanen
4389e44903 bluez5: emit props change events only if values actually changed
This may avoid infinite loops if parameters are being set based on events
sent by parameter changes. It's also what alsa-acp devices do, so bluez5
should follow.
2021-03-02 23:46:27 +02:00
Wim Taymans
157d423246 bluez5: remove stray route param field
This info is also in the classes field.
2021-03-01 16:55:16 +01:00
Pauli Virtanen
a5dc2493df bluez5: route shouldn't list a2dp profiles when not connected 2021-02-19 21:16:27 +02:00
Wim Taymans
930b411075 bluez5: set the right volumes on the node 2021-02-18 19:25:04 +01:00
Wim Taymans
8c5ca000ef bluez5: volumes need to be distributed to all channels
Otherwise some channels might become silent.

See #741
2021-02-18 17:47:22 +01:00
Pauli Virtanen
d75a79babc bluez5: add delay adjustment property + fallback value for a2dp-sink
Not all devices report their A2DP delay. In those cases, use a fallback
value of 150ms by default.

Make the delay adjustable with a SPA_Prop, and expose it as a part of
the route. Implement the corresponding parts in media-session.
2021-02-18 11:33:45 +00:00
Pauli Virtanen
df1dbee687 bluez5: include a2dp codec profiles in route profiles 2021-02-18 11:33:45 +00:00
Wim Taymans
2908e11a72 bluez5: add mSBC and CVSD codec name to properties
Fixes #666
2021-02-12 17:20:37 +01:00
Pauli Virtanen
beaec3d003 bluez5: set initial profile based on what's connected at startup
Set initial device profile according to what's connected at startup,
rather than having media-session try to set it to A2DP (and fail, if the
profile was not connected, resulting to startup in null profile).

This avoids making a codec switch at device startup (we'll stay with
what BlueZ autoconnected us to, usually the previously used codec).
2021-02-11 11:13:42 +00:00
Pauli Virtanen
e0557e0ca8 bluez5: disable codec switching when in A2DP sink role
Devices that expect pipewire to function as a sink don't seem to like it
switching codecs. Disable codec switching when device is a source.
2021-02-06 18:12:19 +00:00
Pauli Virtanen
0346b477ad bluez5: make routes compatible with default-route
default-route wants to have SPA_PARAM_ROUTE_devices and
card.profile.devices before it will restore routes. Add these
also for bluez5-devices.

Fixes restoring volumes on Bluetooth profile change.
2021-02-03 10:49:30 +00:00
Pauli Virtanen
4d9e9fcc33 bluez5: emit events on profile change and handle them
BlueZ may connect transports long after DEVICE_PROFILE_TRANSPORT_SEC has
passed on already existing devices.  When this occurs, the bluez5
pipewire device should notify that the profile enumeration has changed.

Ignore these events during A2DP codec switch, and handle any changes
when the switch completes.
2021-02-02 09:56:29 +00:00
Pauli Virtanen
5d97351970 bluez5: expose different A2DP codecs as separate profiles
The codecs probably should become a separate param later on, but this
workaround at least makes existing UIs work.
2021-02-02 09:56:29 +00:00
Pauli Virtanen
e860f2bb4e bluez5: basic codec-switching framework 2021-02-02 09:56:29 +00:00
Wim Taymans
7fa1833310 bluez5: use function to get profile name 2021-01-27 20:39:02 +01:00
Wim Taymans
30d568403c bluez5: mark profiles as available 2021-01-25 15:53:36 +01:00