Commit graph

674 commits

Author SHA1 Message Date
Julian Bouzas
75281d8681 default-nodes: check if default node has available route
Fixes #145
2022-01-12 07:16:08 -05:00
Julian Bouzas
07a0a5b404 default-nodes: check if the ports exist in rescan_om
Ports might not be ready in the node's port object manager yet.

Fixes #153 and #150
2022-01-12 09:48:36 +00:00
Julian Bouzas
0d008dce75 m-default-nodes-api: don't return stream node if default node name matches
Stream nodes can never be default nodes, so we skip them in case they have the
same name as the actual default node.

Fixes #130
2022-01-06 06:50:32 +00:00
Julian Bouzas
a1423a4b1f m-device-activation: reset iterator when finding best and default profiles
Avoids possible issue when finding best profile when default is not found.
2022-01-05 08:54:12 -05:00
Corentin Noël
b6dd422dd2 si-audio-adapter: Reference WpTransition before passing it as callback data
Make sure to always have a valid WpTransition when used in the finish callback.

Signed-off-by: Corentin Noël <corentin.noel@collabora.com>
2022-01-05 10:28:33 +01:00
Julian Bouzas
f7dfb90db6 module-default-nodes-api: sync with core before emitting changed signal
This makes sure pipewire is not doing anything while emitting changed signal.
2022-01-05 08:57:33 +00:00
Julian Bouzas
8bbbba23ff m-default-nodes: don't reevaluate nodes if they are not ready
This makes sure nodes are ready before finding the default node, avoiding audio
glitch in wrong device if profile was also changed while changing the default
node (can happen with Gnome Sound Settings).

Since nodes are destroyed and recreated again when a device profile changes, the
only way to make sure device nodes are ready is to check the profile classes
structure, which tell us how many total nodes the device has, and then check
that those nodes exist for that device. A rescan is triggered whenever devices,
nodes or ports changed.

This patch also improves the logic when finding default nodes, allowing virtual
sources to be set as default sources.

Fixes #85 and #130
2022-01-05 08:57:33 +00:00
Julian Bouzas
76a61e43a5 m-default-nodes: set effective node metadata to NULL if node is not found
There might not be any node at all, so we need to clear the efective node
metadata.
2022-01-05 08:57:33 +00:00
Wim Taymans
4896ad0680 json: improve json parsing
spa_json_get_string() will never write more than maxlen.
Use spa_json_parse_stringn() to perform destination length checking.
2022-01-04 16:36:15 +01:00
George Kiagiadakis
f3f063760c si-std-link: handle node destroy events while linking is in progress
This should solve issues with stale objects lying around, printing
warnings and in some cases also crashing things

Related to #128, #78
2021-12-22 16:12:04 +02:00
Julian Bouzas
f8d60fcecd m-device-activation: reevaluate current profile if params changed
This also uses the same reevaluation logic as pipewire-media-session.

Fixes #98 and #118
2021-12-20 09:54:05 +00:00
Julian Bouzas
4997e2eb19 m-default-profile: only store the default profile if the save flag is present
Also refactors module to use params-changed signal.
2021-12-20 09:54:05 +00:00
Julian Bouzas
86d85584b2 m-mixer-api: unset iterator value before breaking or returning from loop 2021-12-20 09:54:05 +00:00
Julian Bouzas
2af63b20df si-standard-link: return transition error once even if multiple links failed 2021-12-13 08:37:07 -05:00
iczero
a452250b47 scripts: also look in $XDG_CONFIG_HOME/scripts 2021-12-06 14:47:49 +00:00
Julian Bouzas
e3a161273d m-device-activation: set best profile if default is not available 2021-12-06 12:10:41 +00:00
Julian Bouzas
49f1ead1a7 si-standard-link: always return transition error if activation fails
Avoids having the session item in an invalid state.
2021-11-25 16:06:17 +00:00
Julian Bouzas
9ed6af021f si-audio-adapter: always return task error if set ports format fails
Avoids having the session item in an invalid state.
2021-11-25 16:06:17 +00:00
Julian Bouzas
45d567b488 si-audio-adapter: clean up unneeded code when setting ports format 2021-11-25 16:06:17 +00:00
Peter Hutterer
f4546a18e8 m-reserve-device: replace the hash table key on new insert
We're using the WpReserveDevice's name as key in the hash table, so we
must update the key as well when we replace an item in the hashtable -
the old device (and its name) will be released.

The side-effect of this is that the *third* device with an identical
name will no longer replace the previous device. This results in the
following sequence:

- dev1 added: name Audio0
  - dev1 requests name owner Audio0
- dev2 added: name Audio0
  - replace dev1 in the hashtable
     - dev1 emits "release" signal
     - dev1 unowns the Audio0 name
  - dev2 requests name owner Audio0
- dev3 added: name Audio0
  - adds to the hashtable because the existing key is now undefined
  - dev3 requests name owner Audio0
     - error, you cannot request ownership for the same name twice

Fixes #93
2021-11-18 12:00:09 +00:00
Julian Bouzas
72b3be9e83 m-si-audio-endpoint: use an internal audio adapter session item
Avoids code duplication with si-audio-adapter.
2021-10-21 14:03:10 -04:00
Julian Bouzas
5c1035bab4 m-si-audio-adapter: add no-format configuration property
Makes format finding optional when configuring item.
2021-10-21 13:04:33 -04:00
Julian Bouzas
44a0c55e3d m-si-audio-endpoint: do not use virtual media class for null sink nodes
The PulseAudio layer does not recognize virtual media classes.
2021-10-20 12:50:33 -04:00
Julian Bouzas
6624eaaf3e m-si-audio-adapter: remove unused audio utilities 2021-10-20 07:41:21 +00:00
George Kiagiadakis
eff97aed6e file-monitor-api: allow watching files too, not just directories 2021-10-19 17:16:37 +03:00
Julian Bouzas
ea229779a8 si-audio-adapter: make sure formats is valid before iterating 2021-10-18 14:33:01 -04:00
George Kiagiadakis
6e67000d5e si-standard-link: fix crash after returning a link error
If one link fails, the activation transition will return, but then
other links will continue to call the callback and try to access
the now invalid activation transition. With this change, the callback
is bound to the lifetime of the transition and will stop being called
after the transition returns

Fixes #76
2021-10-16 09:51:00 +03:00
Enrean Rean
477fc744de meson: add support for compiling module-logind with elogind
Closes #71
2021-10-15 13:36:30 +00:00
George Kiagiadakis
11f9433929 si-audio-adapter: skip reconfiguring if the same mode & format are requested 2021-10-14 18:31:54 +03:00
Wim Taymans
486288363b si-standard-link: fix aux channels links
AUX channels can link to any other channel but when AUX channels are
linked, they must match exactly.

Fixes some issues with split devices with aux channels.
2021-10-14 16:28:51 +02:00
George Kiagiadakis
90d6e6042e si-standard-link: do not crash if an output port has no input port to link to
... and also do not link multiple output ports to the same input port
2021-10-14 17:16:50 +03:00
George Kiagiadakis
1db706990c si-standard-link: refactor linking logic to correctly link unpositioned nodes
"unpositioned" nodes don't have a specific channel layout
(ex the Pro Audio profile); in that case, we should not try to copy this
undefined layout to the peer node, we need to configure both in their
preferred layout and do a best-effort linking of ports.
2021-10-14 16:38:49 +03:00
Ashok Sidipotu
784c405c31 wp: support loading optional modules
-some modules will not be available during runtime, due to
  external dependencies.
 -these modules can now be marked optional.
 -loading of these optional modules will be attempted and if
  they are not available, wp will recover and will not be
  terminated.
2021-10-14 06:27:53 +00:00
Nicolai Syvertsen
27a6970de5 lua/api: fix impl_module_new arg parse 2021-10-13 17:25:51 +00:00
Wim Taymans
4585ee08c9 si-audio-adapter: parse the rate optionally
We can use spa_format_audio_raw_parse() because we need to parse
the samplerate here optionally.

Many virtual sinks will not set a rate, which makes parsing fail and
the node will end up with the default channels/positions, which is
most likely wrong.

Fixes channel positions for virtual sinks.
2021-10-13 16:41:31 +02:00
George Kiagiadakis
c6e2f2de87 si-audio-adapter: ensure the node is suspended before changing PortConfig 2021-10-13 13:17:29 +03:00
George Kiagiadakis
5dcd06c339 policy-node: implement encoded audio passthrough
* also respect node.exclusive
* also send error to clients if a target node was not found
  or if it is not possible to link to it
* also allow dont-reconnect nodes to be handled normally
  the first time they appear, until they are linked once
2021-10-13 12:48:03 +03:00
George Kiagiadakis
30407f9930 lua/api: add bindings for client:send_error() 2021-10-13 11:18:51 +03:00
George Kiagiadakis
5ce2dd3e66 lua/pod: add bindings for fixate() and filter() 2021-10-13 11:18:14 +03:00
George Kiagiadakis
03f14105cf si-audio-adapter: find the device format early and store format-specific flags
* find out if the node supports iec958 or dsd
* use spa_pod_fixate() to get the default format of the node, like p-m-s does
* use _enum_formats_sync() to utilize the param cache, assuming that the node
  always has all features enabled (which is always the case when coming from
  an ObjectManager that was defined in Lua)
* simplify the activation / deactivation procedure
* configure nodes with unpositioned channels early, as if they were devices
2021-10-12 20:00:10 +03:00
Julian Bouzas
47896503a8 modules: fix default audio format segfault 2021-10-11 03:08:34 -04:00
George Kiagiadakis
e76c67c45c policy: refactor/improve policy-node & session items to fix linking to monitors
* populate most session item properties from create-item.lua to keep
  things more compact and readable
* use a standard naming scheme for the session item properties
* use session item properties instead of node properties in policy-node.lua
* improve policy-node's performance by converting the properties dictionary
  less times for each session item
* refactor some policy logic and make things slighly more readable
* change the accepted values for 'context' in wp_si_linkable_get_ports();
  use "input" and "output" to keep things clear, because the previous use
  of NULL and "reverse" were implying that a node has only one "standard"
  direction, but this is complicated for sinks w/ monitors and duplex nodes
* allow using monitors (which are Audio/Sink nodes in fact) as sources
* treat Audio/Duplex nodes as sinks, like p-m-s does
* respect the "stream.capture.sink" property of streams

Fixes #66
2021-10-08 00:26:41 +03:00
Wim Taymans
a13308bac7 implement route-settings metadata and notification volume
Make a module that creates a route-settings metadata and provides
some helper functions to parse the json fields.

Load the route-settings module in the policy.

Move the Notification settings to the metadata. Listen for metadata
updates and update our state table.

Fixes #51
2021-10-05 15:47:46 +00:00
George Kiagiadakis
1c77837c9b m-default-nodes: safeguard timeout callback with g_cclosure_new_object 2021-10-05 17:29:05 +03:00
George Kiagiadakis
5e14c69108 m-default-nodes: lift restrictions on media.class for audio nodes
Previously a default source had to be Audio/Source and a default sink
had to be Audio/Sink. This did not account for:
 - monitor sources (Audio/Sink)
 - duplex nodes (Audio/Duplex)
 - virtual sources (Audio/Source/Virtual)

With this change the restriction is now on the number of input/output
ports, so any Audio/* node with output ports is a valid target to select
as a default source, while any Audio/* node with input ports is a valid
target for a default sink.

Fixes #60
2021-10-05 17:28:42 +03:00
Julian Bouzas
151ba8425e m-si-audio-adapter: add 'disable.dsp' configuration property
If 'disable.dsp' is set to TRUE, the adapter will always be configured in
passthrough mode. Then, if 2 adapters want to be linked with different formats,
the si-standard-link session item will automatically reconfigure one of the
adapters in convert mode so that the format matches.
2021-09-29 14:03:27 -04:00
Julian Bouzas
133249399a m-si-standard-link: refactor and add support for no DSP mode
We always use the output session item mode and format when configuring adapters,
unless the input session item is a device node and the output session item is
not a device node.
2021-09-29 14:03:27 -04:00
Julian Bouzas
30b1dd7b4c si-adapter: call format task if port param-info is triggered in non DSP mode
This is needed so that the async callback passed to _set_ports_format is called
when changing the adapter's port format and the port has not been removed or
added. Eg: when configuring the adapter in S16 convert mode to S32 convert mode.
2021-09-29 14:03:23 -04:00
Julian Bouzas
334d92b5cb si-adapter: use F32P default format if mode is NULL 2021-09-29 13:38:22 -04:00
George Kiagiadakis
a253aa4c49 modules: implement logind module and integrate with bluez monitor
This copies the logic of media-session's logind module and allows
the bluez monitor to be active in only one user session at a time.
This is especially useful to avoid interference between the gdm
session and the actual user session, which momentarily both have
wireplumber running when logging in/out.

Fixes #54
2021-09-27 18:30:32 +03:00