Commit graph

6088 commits

Author SHA1 Message Date
Arseny Maslennikov
403f27c531 meson, pw-top: use ncursesw
Some PulseAudio clients are known to use localised client and
stream names as values for the respective PulseAudio props, most
notably plain old pavucontrol.

We call setlocale before anything else for ncurses to display
localised text correctly. We also want to link with ncursesw, which
supports multibyte Unicode locales.
2021-03-25 11:22:52 +00:00
Wim Taymans
5f7910fcac impl-port: only add the port when buffers are negotiated
To avoid crashes when the node is scheduled but buffer have been
cleared.

See #904
2021-03-25 11:30:58 +01:00
Wim Taymans
b5220c83da improve debug 2021-03-25 11:30:30 +01:00
Wim Taymans
5d88e072a8 pulse-server: handle NULL proxy
The proxy could be removed before we get the global remove so we need
to handle the case where we access an object without a proxy and
avoid a crash.
2021-03-25 09:08:13 +01:00
Wim Taymans
b759f9a691 pw-loopback: handle NULL buffers
Make sure we return the non-NULL buffers in all cases.
2021-03-24 17:45:18 +01:00
Wim Taymans
4bcb7e0468 tools: add pw-loopback
Sends the captured data from a source directly to a sink.

It uses an input and output stream so the source and sink can be
moved in pavucontrol, channel remixing is possible and the volume
can be adjusted.

See #959
2021-03-24 17:02:21 +01:00
Wim Taymans
20b8426013 pipewire: snprintf always 0 terminates the string 2021-03-24 16:58:19 +01:00
Wim Taymans
8c334fa3ab alsa: never queue buffers when rate matching
When we are following the resampler requested size in capture, never
keep queued buffers around or we might get out of sync with the
requested size and cause cracks and pops in the resampler.

See #805
2021-03-24 11:48:32 +01:00
Wim Taymans
34800dc019 json: don't move past the end of a symbol
We can't move past the } or ] or we might miss the end of the
container. Now that we ignore \0 it is not a problem if the \0
is placed at the container boundary.
2021-03-23 18:05:44 +01:00
Wim Taymans
b54af4ab0a media-session: don't loop forever on link failures
Based on patch from Pauli Virtanen

Keep track of the last node that we failed to link to and don't try
to link to it again over and over.

See #882
2021-03-23 17:27:01 +01:00
Wim Taymans
fe49c2e6b1 impl-node: handle error from the Start command
When we execute Start on a node, handle the error case and set
the node into the error state.
2021-03-23 17:25:36 +01:00
Wim Taymans
a9e14a30da impl-node: allow suspend on error nodes
When a node is in the error state, make sure we can execute a
Suspend on it to bring it back into a usable state.
2021-03-23 17:21:45 +01:00
Wim Taymans
3981f15ec6 media-session: also suspend error nodes
When a node is in the error state we need to suspend it to be
able to use it later again.
2021-03-23 17:21:06 +01:00
Wim Taymans
ae85a3da39 media-session: make link_nodes return the number of links
Return the result from sm_media_session_create_links() as the
result of link_nodes. This is > 0 when something was linked, < 0
on error and 0 when no ports are available. We should be able to
use this result later to handle errors.
2021-03-23 16:36:46 +01:00
Wim Taymans
df9644f109 jack: add jack.self-connect-mode
Add a property to restrict self-connections. This can be used to
stop clients from connecting themselves automatically.

Fixes #952
2021-03-23 12:24:38 +01:00
Wim Taymans
3b0b5cb55d pw-dump: print id-xxx for unknown ids
When the id has no info in the type system use id-xxx instead
of "unknown".
2021-03-23 11:32:35 +01:00
Wim Taymans
4668b72312 impl-node: first start the node, then make it schedulable
We first need to issue the start command for driver nodes and then
we can add the node to be scheduled. Else we might end up with nodes
that receive the _process callback without the Start command being
called first and we can crash.

See #904
2021-03-23 10:17:01 +01:00
Wim Taymans
7ee52b396d media-session: use restore stream for routeless nodes
When a node does not have routes, treat it like a stream and use
the restore-stream logic to restore the volumes.

Rework some of the logic a little. Don't save empty strings. Wait
for param updates to save/restore values.

This makes volume restore work on virtual sinks/sources and
sinks/sources without any routes.

See #729
2021-03-22 17:10:31 +01: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
Wim Taymans
8a9c2ae901 merger: don't try to change the volumes in PortConfig
Just leave them be. Something else is supposed to changed the volumes
if needed. In the usual case where nothing changes, we don't want to
override the volumes.
2021-03-22 16:33:36 +01:00
Huang-Huang Bao
d439b7cdd7 bluez5: retry sco connect if it got aborted by ECONNABORTED
When I enforing HFP codec switching between HFP profiles, it has a chance of being aborted by ECONNABORTED. Seems a retry is sufficient for work around it.
2021-03-22 10:53:16 +00:00
Wim Taymans
53024c1747 jack: free the global map when the client is closed 2021-03-22 11:21:44 +01:00
Wim Taymans
fa1350b0cf pulse-server: make sure we are active when draining
When we start draining, set ourselves active so that the process
function is called where the draining is completed.

This avoids a corked stream from waiting forever to drain the stream.

Fixes #946
2021-03-22 10:31:09 +01:00
Wim Taymans
80a6583271 pulse-server: send any STREAM_KILLED command last
Mark the stream as killed and then only send the STREAM_KILLED
command after we send the other pending commands.
2021-03-22 10:29:45 +01:00
Wim Taymans
6b6bf1e1d0 pulse-server: always reply to pending drain operation
When we destroy a stream but there is still a pending drain operation,
send an error for the drain tag first.
2021-03-22 10:16:48 +01:00
Huang-Huang Bao
8b7502c8db
sco-sink: fix no sound issue if first port buffur size is less than write MTU
No data is written because 'sco_on_timeout' always reset 'write_buffer_size' to 0.
2021-03-22 14:03:45 +08:00
Wim Taymans
5cddd61c6c acp: remove the soft volume/mute events
Remove the soft mute/volume events, add a new method to get the soft
volume and use the volume_changed event to emit the changed soft and
monitor (real) volumes event for the node.

Make sure the monitor ports always uses the monitor volume, which is the
real volume unaffected by the mixer volumes.

This configures the soft and real volume on the sink/source in all
cases and makes the monitor port follow the real volume of the sink.

See #897
2021-03-21 16:19:57 +01:00
Huang-Huang Bao
3bce026d67 protocol-native: fix out-of-bounds access to SEC_LABEL hex table
If buffer type char[] is 4-byte aligned, higher 3-byte on char could be non-zero if data is not initialized, which make 'buffer[i] >> 4' larger than 0x0f.
Use type uint8_t[] on SEC_LABEL buffer to fix it.
2021-03-21 12:07:39 +00:00
JP Guillemin
471fffe4a3 Update a2dp-codec-sbc.c 2021-03-21 12:04:51 +00: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
eb9b787db1 bluez5: fix ofono transport acquire 2021-03-20 20:01:52 +00: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
0385d0a07e bluez5: guard against transports without sco_io
If backend releases transport early and sco_io becomes NULL, don't
access it.

Also guard against calloc failing in sco_io creation.
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
Pauli Virtanen
e18df4e344 bluez5: use callback table in hsp/hfp backends 2021-03-20 20:01:52 +00:00
Pauli Virtanen
18eccf4289 bluez5: don't logspam in sco-source on debug level 2021-03-20 20:01:52 +00:00
Wim Taymans
de12a24e77 protocol-native: hex encode invalid SEC_LABEL
When the sec label contains invalid chars, hexencode it to avoid
causing problems with invalid strings later.
2021-03-20 21:00:55 +01:00
NeroBurner
9499e4969b Fix small typo, capitalization and trailing dot at end of sentences 2021-03-20 15:55:45 +00:00
Pauli Virtanen
942ead7d90 pulse-server: fix route profile numbering
Route profile numbers refer to profile ids, not indices.
2021-03-20 15:32:26 +02:00
Pauli Virtanen
7be7b258cb pulse-server: don't send invalid port profile arrays
libpulse assumes in introspect.c:fill_card_port_info that port profile
array size <= card profile array size, and may crash otherwise.

Enforce this in fill_card_info. It can happen, if EnumRoute and
EnumProfile info is not in sync.
2021-03-20 15:15:37 +02:00
Huang-Huang Bao
abfa04caa4 a2dp: add props param support for LDAC
LDAC quality can now be set with SPA_PROP_quality on a2dp-sink node.
Also fix a NULL reference if device setting is empty.
2021-03-20 09:16:20 +00:00
Huang-Huang Bao
1d390addb1 a2dp: allow codec to hold Props params
Initial Props value are parsed from device settings, further changes are triggered by 'set_param' on a2dp node.
Codec can then use props to tweak its transcoder.
2021-03-20 09:16:20 +00:00
Huang-Huang Bao
6512c2b5f6 bluez5: fix a use-after-free on transport handle
'remove_dynamic_node()' reference transport after it got freed in 'spa_bt_transport_free()'.
2021-03-20 09:15:02 +00:00
Gleb Popov
03ea1a2177 Add a necessary include.
The `basename` function is defined in <libgen.h> and on FreeBSD this header
doesn't get transitively included, which causes a runtime crash.
2021-03-20 09:11:48 +00:00
George Kiagiadakis
66c43e5af2 bluez: sco-{source,sink}: adjust node properties for when acting as a stream
Add media.name so that restore-stream can store this stream.
Remove node.driver because the stream is slaved to the connected ALSA device.
Remove pause-on-idle in all cases, as this is now configurable from
the config file.
2021-03-19 20:27:49 +02: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
Wim Taymans
92f1a24849 media-session: check stream move after configuring a new node
When a new node is configured, check if existing streams might need to
be moved to it.

This fixes the case where a stream has a target node set to some
bluetooth device and it starts playing to the default device because
the bluetooth device is not connected. When the BT device is then
connected and configured, the stream is moved to the new BT device.
2021-03-19 15:51:17 +01:00
Huang-Huang Bao
43603dd75d a2dp: add property to force LDAC encoding quality
Fixes #661
2021-03-19 11:50:56 +00:00
George Kiagiadakis
343be7503a bluez: backend-ofono: advertise transport state for incoming connections 2021-03-19 11:49:41 +00:00
George Kiagiadakis
f9b39191c4 bluez: backend-native: advertise transport state for incoming connections
Incoming connections only happen when the remote end is an AG.
Advertising the state allows the device to dynamically create nodes
for such connections.
2021-03-19 11:49:41 +00:00