Commit graph

3893 commits

Author SHA1 Message Date
Wim Taymans
38d36f1921 media-session: improve saved profile restore
We only want to restore the saved profile when it is available, when
it is not available and there was no change in best profile, leave
the profile as it is.
2021-03-11 10:22:33 +01:00
Wim Taymans
d295d97160 media-session: only restore best profile when something changed
Keep track of the best profile. Only try to switch away from the
saved profile when something changed and the saved profile is not
available.

This makes it possible to select an unavailable profile but when
something is changed, it will switch away from it.
2021-03-11 09:32:17 +01:00
Thibault Saunier
485bae5eb0 meson: Use feature options everywhere it makes sense 2021-03-10 20:18:34 +00:00
FeRD (Frank Dana)
2931522d2c pw-cli: Make 'dump' type arg case-insensitive 2021-03-10 11:41:32 -05:00
Wim Taymans
e334c5862e pulse-server: fill in the format info 2021-03-10 17:27:11 +01:00
Wim Taymans
d5fc67cf06 pulse-server: Prefer the formats of the extended format API
Fix enumerate the formats from the extended API and then append
the old API formats.

See #876
2021-03-10 16:55:01 +01:00
Wim Taymans
ef4b3c403e media-session: -1 as node.target is default
A node.target property of -1 also means to follow the default
sink/source. The ALSA plugin might use this to select the
target node and would otherwise not move to the new default sink.
2021-03-10 15:27:06 +01:00
Wim Taymans
78e9e5958e impl-node: delay starting the driver node
Only start the driver node after we have added ourselves to the
driver node or else we might start too soon, before there is anything
to schedule and we cause driver underruns.
2021-03-10 13:28:56 +01:00
Wim Taymans
62def0399f impl-node: rework link activation
Only activate the links when the node is added to a driver. Otherwise
the driver will expect us to decrement the activation counters for the
links but that won't happen because the node will not be processed
yet.

Instead we activate the links that were not activated yet when the
node is activated.

This improves scheduling for newly added links and nodes.
2021-03-10 13:06:02 +01:00
Wim Taymans
cc26ef9614 impl-node: update the io position from the data-loop
So that the update is synchronized with the data processing and
we don't accidentally process an old driver activation.
2021-03-10 13:03:34 +01:00
Wim Taymans
0881d5b881 context: restart graph recalculation when something changed
When we were busy with the graph recalculation and something changed,
restart the graph state change to get the new change applied.

For example, when we start a node and it has a max-quantum set, we
need to restart our calculation with the new quantum limits.
2021-03-09 15:48:47 +01:00
Wim Taymans
dd0342167f policy-node: move variable up in scope
We are using it outside of the scope it is defined in.
2021-03-09 12:48:48 +01:00
Wim Taymans
c237ccfbda pulse-server: use the manager sync method for async replies
Use the manager sync method to wait until all pending queries are
finished. It is the manager that will query the new parameters so
we need to wait until that completes.

See #868
2021-03-09 12:09:05 +01:00
Wim Taymans
82c452a93d pulse-server: expose sync method 2021-03-09 12:08:45 +01:00
Wim Taymans
d29bdf64ee pulse-server: reply async to some requests
Trigger a roundtrip before we send the reply to the client for many
methods like set_volume/set_mute etc.

this ensure that we get the updated information from the server before
we reply so that a subsequent query returns the up-to-data information.

Fixes #868
2021-03-09 09:55:48 +01:00
Wim Taymans
1b6060ef5f media-session: schedule more rescan for pending changes
Trigger/delay a rescan until the profiles, routes and stream
volume are restored.

See #789
2021-03-08 15:14:40 +01:00
Wim Taymans
d603c1086a media-session: (re)schedule rescan after new pending operation
Every time a new operation is started, schedule a rescan. This
ensures that there are no more pending actions before the policy
module scans the nodes.

This has the effect that all devices and nodes are up to data and
ready to be used by policy-node.

Fixes #789
2021-03-08 13:20:02 +01:00
Wim Taymans
59f86df9f3 media-session: move profile switch to default-profile
Move the profile switching from default-route to the default-profile
module. This makes more sense and it also allows us to restore the
saved profile when it becomes available.

Make default-profile always check if the saved profile can be restored
before attempting to switch to the best profile.

Default-route now just monitors profile changes and restores the
routes associated with it.

See #466
2021-03-08 11:52:38 +01:00
Wim Taymans
2aa261659d pulse-server: handle NULL default_sink/source
Don't crash when default_sink/source is NULL

See #676
2021-03-07 08:18:11 +01:00
Wim Taymans
6324298bc5 channelmix: add more generic upmixing
Add options to enable lfe filtering and upmix.
Enable upmix by default, lfe is disabled because we don't actually
do a lowpass filter yet.
2021-03-06 21:31:18 +01:00
Wim Taymans
5712992fc9 stream-restore: Don't save the default sink/source as a target
If the default sink or source is set as the target, just don't save
the new target so that it follows the new default.

This is a workaround for gnome-control-center first setting the
default source/sink and then setting the targets on all
stream-restore database entries to the new default. Setting an
explicit target will pin the stream to that sink/source forever,
which is then making pavucontrol default source/sink toggle
fail.

See #676
2021-03-06 20:08:11 +01:00
Wim Taymans
d9b80fda37 pulse-server: set our default sink/source immediately
In COMMAND_SET_DEFAULT_SINK/SOURCE, set our default source and sink
immediately instead of waiting for the metadata update. This makes
it possible to check for the new default sink immediately in other
modules.
2021-03-06 20:06:06 +01:00
Wim Taymans
dbebbe2f33 pulse-server: support NULL set-default-sink/source
It is allowed to set a NULL value for the default source/sink, which
then simply clears any configured value.
2021-03-06 19:58:52 +01:00
Wim Taymans
662fd8a1f9 pulse-server: avoid crashing when clearing metadata
The key will be NULL so we can't strdup it.

Fixes #845
2021-03-05 20:16:29 +01:00
Wim Taymans
1c365f6169 policy-node: fix compiler warning 2021-03-05 20:16:05 +01:00
Wim Taymans
c8fd34a41d metadata: store default-nodes as JSON
Don't just store the id in the metadata but a JSON object with
the node name. This makes it possible to easily introspect the
metadata and also extend the metadata with more fields later.

Instead of matching the metadata id to the global ids we now
have to match it against the name.
2021-03-05 17:37:12 +01:00
Wim Taymans
8d5cc7013d conf: write valid JSON by putting , between keys
Separate keys with , to make a valid json file
2021-03-05 12:40:28 +01:00
Wim Taymans
b40397d986 media-session: check metadata before using it
The session manager might be configured without metadata support
so check this before attempting to use the metadata. It's not
really a problem because the default sink/source can only be
changed with the pulseaudio API, which activates metadata.
2021-03-05 10:34:27 +01:00
Wim Taymans
93002ecd11 media-session: remove unused prefix from load/save state
The prefix was used to filter the properties when loading and
saving but since the conversion to the core provided functions, this
feature is not longer available.

It's not exactly a problem, we could implement the filtering ourselves
afterwards but there is little point because we just ignore the unknown
items and never write invalid items.
2021-03-05 09:23:19 +01:00
Barnabás Pőcze
3c01cfe8f8 protocol-native: connection: fix errno check condition
The branch should be taken if errno is neither EAGAIN,
nor EWOULDBLOCK.

Previously,

  if (errno != EAGAIN || errno != EWOULDBLOCK)

would be taken for all values of errno if EAGAIN != EWOULDBLOCK.
(Except for the ones that are filtered out before.)

Fix that by changing `||` to `&&`.
2021-03-04 19:18:19 +00:00
Wim Taymans
1642e5220f media-session: sanitize device names as well
See #827
2021-03-04 12:45:35 +01:00
Wim Taymans
28b28ef92c pipewire: align the spa_handle to 8 bytes
See #835
2021-03-04 10:58:35 +01:00
Wim Taymans
a4b0b9afe5 build: check for getrandom and sys/random.h
Fixes #833
2021-03-04 10:57:48 +01:00
Wim Taymans
67b431cfca rtkit: boost default rt.prio to 88
See #685
2021-03-03 19:56:22 +01:00
Wim Taymans
c8804c3d6d context: make a new node.max-latency property
node.latency also influences the pipeline latency in that it can
push the latency above the default value.
node.max-latency, instead, is only used to clamp the final latency
of the pipeline.
2021-03-03 13:27:48 +01:00
Wim Taymans
a57d3e4dae Revert "context: set max-quantum to 4096 by default"
This reverts commit 293d9b3c5d.

The root cause of this might now be fixed.

See #724
2021-03-02 10:46:24 +01:00
Wim Taymans
e19263140a pulse-server: improve module handling
Make a registry of modules
Assign an unique number to each module with the MODULE_FLAG bit set
so that we can also enumerate them
Implement enumerating our internally loaded modules
Implement unloading of the module using the module id
Move module-null-sink into a separate file
Use Audio/Sink if no other media.class was given, so that it works
just like the pulseaudio module
Enable linger=true in all cases.
2021-03-01 14:57:28 +01:00
Wim Taymans
15e6a825f2 pulse-server: don't read past the end of the string 2021-03-01 13:56:10 +01:00
Wim Taymans
80a543e043 adapter: improve error message
Make sure we debug the result code that is returned.
2021-02-26 20:45:25 +01:00
Wim Taymans
f7d756460e alsa: add option to use device channel map instead of default
See #461
2021-02-25 21:16:16 +01:00
Wim Taymans
cab87b6d3e pipewire: make pipewire a generic launcher
It uses the basename as the config file so you can symlink to it
and make new custom servers.
2021-02-25 13:35:04 +01:00
Wim Taymans
293d9b3c5d context: set max-quantum to 4096 by default
Some devices seem to have trouble with larger quantum.

See #724
2021-02-25 12:25:01 +01:00
Wim Taymans
1a12d6082a stream: improve draining
After we drained, set the io state to NEED_DATA again. This will
trigger a new _process callback, if we have new buffers we will
exit the drain state and produce more data, if we have no buffers we
reenter the drained state and signal the drained event.

This effectively provides a way to exit the drain state by pushing
a new buffer into the stream.
2021-02-25 12:14:42 +01:00
Gleb Popov
96fda265e0 Fix compiler warning by including a required header 2021-02-25 09:34:12 +00:00
Gleb Popov
9f53057b51 Add userspace implementation of getrandom() for FreeBSD 11 2021-02-25 09:34:12 +00:00
Wim Taymans
7cf07da392 Start media-session and pulse-server in uninstalled config
Also update the INSTALL instructions to match reality.
2021-02-25 07:00:56 +01:00
George Kiagiadakis
27cfff7965 systemd: do not specify RuntimeDirectory on the media-session service
This will just re-create /run/pipewire for no good reason; the one
in pipewire.service is enough
2021-02-24 21:15:41 +00:00
George Kiagiadakis
32512a8962 systemd: system-mode: preserve /run/pipewire after the daemon stops
/run/pipewire is initially created by pipewire.socket when it creates
the socket file, but it is owned by root with mode 0755.

In the .service unit, RuntimeDirectory=pipewire re-creates /run/pipewire
for user pipewire (owned by pipewire:pipewire, 0755) when this unit starts.
This is necessary for the pipewire daemon to be able to write the .lock file.

By default, when the service unit stops, systemd deletes this runtime
directory and therefore it also deletes the socket that is owned by
pipewire.socket. When this happens, the service is no longer
socket-activateable even though pipewire.socket is active.

RuntimeDirectoryPreserve=yes prevents the service unit from removing
this runtime directory and socket activation still works as expected
2021-02-24 21:15:41 +00:00
George Kiagiadakis
2491f56355 config: ignore module-portal load failures
When running pipewire as a system-wide daemon, module-portal
obviously doesn't load. Make it optional so that the default
config doesn't fail in system-wide mode
2021-02-24 21:15:41 +00:00
Gleb Popov
dbc9a520ef Check for sys/mount.h and sys/vfs.h headers and include them conditionally 2021-02-24 19:29:57 +00:00