Commit graph

3806 commits

Author SHA1 Message Date
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
Wim Taymans
35c27d0c10 media-session: restored saved profile from off
Always attempt to restore the saved profile again from the off state.
This can happen when the device goes into suspend or when hdmi is
unplugged.
2021-03-17 12:23:58 +01:00
Wim Taymans
e51cc5b537 channelmix: Prepare for generating LFE channel
Add channelmix.lfe-cutoff property, 0 is disabled
Disable upmix by default
2021-03-17 11:09:19 +01:00
Huang-Huang Bao
4200ca98d6
media-session: don't destroy bluez sm_object in session destroy handler, let object been destroyed in session_shutdown.
Avoid double free on object proxy, although it has been handled by d143c169cc.
2021-03-17 08:42:31 +08:00
Björn Daase
5913eb098c treewide: fix issues found by codespell 2021-03-16 19:11:25 +00:00
Jonas Holmberg
44e0251afd impl-node: Make rounding of quantum configurable
Add new context config clock.power-of-two-quantum to make it possible to
not round quantum to closest lower power of two. This makes it possible
to match the quantum of a source node with the quantum of a client
node.
2021-03-16 19:09:29 +00:00
Pauli Virtanen
d143c169cc media-session: free sm_objects only after session destroy emitted
Allows monitors (eg. bluez5) free any sm_objects they hold in
session_destroy.  In session_shutdown, destroy such objects before the
event, and free them only afterward.

Fixes double-free in bluez monitor.
2021-03-16 19:06:42 +00:00
Wim Taymans
6c94dc30a2 impl-node: delay start when both a driver and driving
WE can only delay the start for drivers that are driving. Remote
nodes are driving themselves but are not drivers so they need to
start early.

See #879
2021-03-16 17:28:40 +01:00
Wim Taymans
f2b537bb65 context: fix passive node check
A node starts out as passive but becomes non-passive when there
is a non-passive link to an active node. If there is a link to
an inactive node, the node remains passive.

This fixes suspend of drivers in all cases.

Fixes #898
2021-03-16 15:48:55 +01:00
Huang-Huang Bao
75b4c80dc6 bluez5: add logic to fallback to previous behavior if connection info handling is not supportrd by session manager (i.e wireplumber). 2021-03-16 10:31:08 +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
Huang-Huang Bao
e7cecaaea6 media-session: apply updated properties to bluez/v4l2 device handle 2021-03-16 10:31:08 +00:00
Pauli Virtanen
d9c5ea54fd media-session: set bluetooth volume directly on the local adapter node
Avoid problems with session proxy appearing too late by setting props on
directly on the local SPA node.
2021-03-15 21:24:39 +02:00
Wim Taymans
5c91f23c18 default-routes: only restore routes when profile changed
When the profile changes, try to restore the previously saved
routes. Otherwise, follow the best route when it changes.

See #863
2021-03-15 16:06:13 +01:00
Wim Taymans
85a102f414 default-profile: restore saved profile only for first time
Don't always try to restore the saved profile when it's available
but only do this the first time. From then on, try to follow the
best profile when it changes.
2021-03-15 14:57:10 +01:00
Wim Taymans
0b6d3e4b71 default-routes: reconfigure the profile when routes change
When something changes to the route status, try to reconfigure the
current profile.
2021-03-15 11:51:24 +01:00
Wim Taymans
9964741637 context: non-passive loopback links also active a driver
If a driver node is linked with a non-passive link to itself, it
should also become running.

One example of this is the Midi bridge, that needs to start when you
link one device to another. The devices are all on the same node
so linking devices would result in loopback connections.
2021-03-15 11:42:09 +01:00
Pauli Virtanen
8ba6e98320 media-session: move libcamera+bluez5 device removal to object free callback
libcamera + bluez5 devices should be freed/unloaded via the sm_object
free callback, similarly as in alsa and v4l2 monitors.  This ensures
they are run at session_shutdown.
2021-03-15 08:20:38 +00:00