Commit graph

3174 commits

Author SHA1 Message Date
Wim Taymans
f6356a3441 media-session: handle node destroy during linking
Mark a node as busy linking while we call _create_links. The
_create_links method does a roundtrip and this might cause the node
to be destroyed. Set a flag when we notice this and avoid accessing
the destroyed object.
2021-03-26 13:07:28 +01:00
Wim Taymans
0af8c0c045 pulse-server: check message size 2021-03-25 19:07:13 +01:00
Philippe Normand
ddd731bc09 module-access: Plug /.flatpak-info fd leak
The file descriptor needs to be closed in all situations, not only in the fstat
error case.
2021-03-25 18:05:07 +00:00
Pauli Virtanen
3d82700edb media-session: retry link a few times if it fails
Retry linking nodes a few times instead of giving up immediately.

This is a workaround, but it fixes moving streams on BT profile changes.
2021-03-25 19:51:02 +02:00
Wim Taymans
bcc147cf72 context: keep some room for our own support
We need some extra items in the array to store our own support
objects, so pass a smaller one to the core support.
2021-03-25 17:43:59 +01:00
Wim Taymans
e3b0cc76a3 pulse-server: avoid leaks in error path
When reading the properties failes, make sure to free the properties
anyway.
2021-03-25 17:34:44 +01:00
Wim Taymans
5629885e41 media-session: avoid strcmp on unterminated string
The string might not be 0 terminated so use the length to set a
limit for strcmp.
2021-03-25 17:29:19 +01:00
Wim Taymans
4ab4c57a55 impl-core: fix memleak in error case 2021-03-25 17:17:40 +01:00
Wim Taymans
78da72ce30 pulse-server: take length of the right string
We need to take the length of the desc, not name, to construct the
extended 'Monitor of <desc>" string.
2021-03-25 17:02:10 +01:00
Wim Taymans
faeb42fa66 pw-loopback: fix leaks, improve cleanup 2021-03-25 16:50:49 +01:00
Wim Taymans
2d2557381c pulse-server: avoid returning NULL strings
Don't return a NULL string when converting an id to a string because
some callers don't expect this and crash.
2021-03-25 15:35:12 +01:00
George Kiagiadakis
05beb04259 impl-core: also include fcntl.h on non-freebsd builds to compile getrandom 2021-03-25 15:16:41 +02:00
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
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
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
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
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
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
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
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
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
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
Wim Taymans
972cf8d657 media-session: make midi sequencer bridge name configurable
Setting this to a2j might make it look pretier in some jack apps.
Not sure yet if this should be the default.
2021-03-18 16:27:46 +01:00
Joakim Tjernlund
d983c51469 pulse-server: Emulate PA driver name as blueman looks for it 2021-03-18 16:20:30 +01:00
Wim Taymans
2ee4e94c59 policy-node: take into account sinks as a default source
A sink can be set as a default source, which means that the default
source is the monitor ports of the sink.

Move the direction check for later so that we can first check if we
are dealing with a potential default sink/source for the given
direction. If we found a default sink/source, we don't need to do
the direction check anymore.

This makes it possible to set a sink as a configured default source
and have policy-node take this into account when defining the
default.source metadata.

See #715, #908
2021-03-18 11:57:16 +01:00
Wim Taymans
8d7c5732db pulse-server: remove .monitor suffix when set as default source
We place the sink name in the metadata when it is used as a default
source.
2021-03-18 10:28:47 +01:00
Huang-Huang Bao
68677774fc
bluez5: fix reference to already freed spa_bt_device
Fixes #907
2021-03-18 12:09:30 +08:00
Pauli Virtanen
83443967a0 media-session: set node list change flag
See a96d8aa1aa
2021-03-17 16:19:04 +00:00
Wim Taymans
bc47378abc pulse-server: support moving capture streams to monitors
Also resolve the monitor ids to the sink with the monitor ports.
2021-03-17 17:02:28 +01:00
Wim Taymans
24d795e9a4 pulse-server: don't free stream map in disconnect
The cleanup handler might still run and try to iterate the streams
so make sure the map is not freed yet.

See #901
2021-03-17 16:28:21 +01:00
Wim Taymans
a96d8aa1aa media-session: guard against node destroy while iterating
When we are iterating the nodes and one is destroyed, restart the
scan operation so that we avoid accessing invalid memory.

See #901
2021-03-17 16:19:16 +01:00
Huang-Huang Bao
f021866adb
meson: fix symbolic link creating on FreeBSD 2021-03-17 19:29:55 +08:00