Commit graph

4031 commits

Author SHA1 Message Date
Wim Taymans 85dd03c2d8 filter-chain: make plugin wrapper
So that we can implement the internal plugins with a more expressive
API than LADSPA.
2021-08-11 21:12:36 +02:00
Wim Taymans e46799d43f filter-chain: simplify parsing a little
Always parse the value and check the type.
2021-08-11 21:10:29 +02:00
Wim Taymans 67eb485811 filter-chain: add convolver 2021-08-11 20:54:04 +02:00
jicksaw b4976728c3 filter-chain: fix parsing when control isn't last
Control had to be defined last, because after it the parser would
start skipping keys and fail to set rest of the params.
2021-08-11 18:52:10 +00:00
Pauli Virtanen aa0736d67f pulse-server: allow moving nodes with node.target to default sink/src
Set node.target metadata to "-1" instead of deleting it to direct nodes
to the default device.

Deleting the metadata, as done previously, does not work for nodes for
which the client has node.target set.
2021-08-09 22:25:59 +03:00
Pauli Virtanen 8c6b111ea6 media-session: simplify target node handling + fix priorities
Handle all node.target behavior in rescan_node.

Make distinction between target nodes set in session manager via
metadata or via restore-stream; priorities are
metadata > client's node.target > restore-stream.
Allow metadata override to also remove the target node setting.
2021-08-09 21:02:43 +03:00
Pauli Virtanen e2d810a9b9 media-session: fix linking nodes with targets to wrong nodes
For nodes that have node.target set, when the target is not available,
media-session links them to any available node.  If the target node
appears afterward, media-session would not re-link them, leading to
output being directed to wrong place (e.g. pavucontrol input monitor)
even though the intended target or a better fallback is available.

This occurs e.g. when devices are removed and re-added.

Fix this by (i) for reconnectable nodes, reconnect them if target
appears later, and (ii) for non-reconnectable nodes, raise error to the
client if node.target is set but not found (but proceed to fallback if
obj->target_node is set).

Also slightly reorganize policy-node.c:rescan_node for clarity.
2021-08-09 21:02:43 +03:00
Wim Taymans 5a4ef78480 pulse-server: fix some indent errors 2021-08-09 15:27:42 +02:00
Wim Taymans 0e386b6584 context: also set driver on inactive nodes that want one
Also set the driver on an inactive node when it wants a driver.

Fixes the case where xjadeo does not activate itself but still wants
to poll the transport state of the driver.

See #1491
2021-08-09 10:50:07 +02:00
Wim Taymans 7fda66142b conf: try to load state from where we saved it
When XDG_STATE_HOME is unset, we save in $HOME/.local/state/pipewire,
so try to first load the state file from there as well before we
try to fall back to the old XDG_CONFIG_HOME location.
2021-08-09 09:47:58 +02:00
Peter Hutterer 55c264d2a5 conf: store state in XDG_STATE_HOME
Defaulting to $HOME/.local/state, this is the directory that state
information is to be kept.

As with the configuration loading, where a caller requests an absolute
path, that path will be honored, we only fall back to XDG_STATE_HOME for
relative paths.

This adds a new PIPEWIRE_STATE_DIR environment variable to override this
directory.
2021-08-09 16:52:43 +10:00
Peter Hutterer 956c83f1c8 conf: rework conf_load to take a path only
Refacturing to make it possible to read from different paths.
2021-08-09 16:48:50 +10:00
Pauli Virtanen 83f72489ad media-session: if no node found on reconnect, unlink but no error
If a reconnecting node was linked at least once successfully, and a
re-link ends up not finding any node to link to, don't raise an error.
Instead, just unlink the node, and wait for a suitable sink to appear
later.

This fixes the issue that some Pulseaudio apps have to be restarted
if all devices go away, before they start working.

It also seems like the right thing to do, because if you remove links
manually, this does not cause errors to occur.
2021-08-08 19:22:45 +00:00
Nils Tonnätt dd12910769 Revert "[Meson] Fix all deprecation warnings"
This reverts commit f7e1175ef0.
2021-08-08 19:18:40 +00:00
Barnabás Pőcze 090aaa4fb0 media-session: bluez-autoswitch: simplify logic
When `val` was used, it was always a true-ish since the
address of an array on the stack was assigned to it.
Remove this variable altogether, and use `name` directly.
Only use `name` when it is valid - when `key && value`.
2021-08-08 18:46:53 +02:00
Barnabás Pőcze 3724088c21 media-session: bluez-autoswitch: fix memory leak
`impl->default_sink` is dynamically allocated, but previously
it was not freed when the containing struct was being destroyed.
Fix that by freeing it in `session_destroy()`.
2021-08-08 18:46:53 +02:00
Pauli Virtanen 4840fd3da8 media-session: don't remove default.configured when devices go away
There's no particular problem to have default.configured to point to a
non-existent device, it will be ignored.  This was left over when
default and configured default were made separate things.

default-nodes also doesn't need to track the id of the configured
default, so remove also other stuff that's no longer necessary.  It can
simply load the values to metadata on startup, and save them to a file
when they are changed, without needing to understand what the values
mean.

Also fixes commit 7071562334 causing defaults to be forgotten when
nodes are removed.
2021-08-08 14:28:46 +03:00
Wim Taymans 33d8f14e45 stream: don't call process() in Start in some cases
We only want to call process() from Start when we are not a driver and
not realtime.

When we are a driver, the user will need to call _trigger_process()
to kick things of.

When we are asked to schedule process from the realtime thread, we
need to wait until the RT thread is scheduled.

In all other cases we can call _process() from the mainloop so that
the RT thread has something to collect when it gets scheduled.
2021-08-06 16:15:55 +02:00
Wim Taymans b030a4e7da stream: add a method to check if driving or not
When the node is driving, we need to call trigger_process()
otherwise we don't and we simply need to wait for the process() to
be called, triggered by the driver node.

See #1484
2021-08-06 15:36:52 +02:00
Wim Taymans 3c97090ba0 stream: rename _drive() to _trigger_process()
Should be a bit more intuitive to understand what it will do.
2021-08-06 15:32:21 +02:00
Wim Taymans 47fe5b550d examples: add a pull based video player
It has the DRIVER flag set and sets a PW_KEY_PRIORITY_DRIVER value
to something higher than the source so that it becomes the driver.
Every timeout it does pw_stream_drive() to start the graph, which
will eventually call the process function with a pulled buffer to
display.

The framerate is set to something lower (80ms between frames) to
show the pull effect.

fixes #1484
2021-08-06 14:49:32 +02:00
Wim Taymans 23d3b10be4 examples: update video-src examples
So that hey use pw_stream_drive() to start the graph.
2021-08-06 13:55:43 +02:00
Wim Taymans 9831f62927 stream: add pw_stream_drive()
This method is meant for driver streams when they have data or need
data.

Previously only source (output) streams could drive the graph and
indirectly by doing pw_stream_queue_buffer(). This behaviour is now
deprecated (but will still work) in favour of calling
pw_stream_drive() explicitly.

pw_stream_drive() will call the process function immediately (if
driver) or later (when not a driver) so that the same code paths
can be used when running as a driver or not.

In a similar way, a consumer (input) driver stream can now be
written. It will call pw_stream_drive() when it wants data and the
process function will be called when the data is ready.

See #1484
2021-08-06 13:36:34 +02:00
Wim Taymans 42e0b520aa stream: Detect if we are driving or not
We need to check the position vs the clock to see if we are currently
driving the graph. We can only call the node ready callback when
we are actually driving the graph.
2021-08-06 13:09:39 +02:00
Peter Hutterer 5da2081a4b default-profile: document what this module does in more detail 2021-08-06 08:03:27 +00:00
Peter Hutterer 43a560e25f default-profile: make the job to restore a saved profile easier to read
"restored" describes a state but the only case we actually set this
value if we want to restore our previously saved profile. Rename a
variable to indicate this, makes it easier to understand.
2021-08-06 08:03:27 +00:00
Peter Hutterer cec4699986 default-profile: remove write-only field saved_profile 2021-08-06 08:03:27 +00:00
Nils Tonnätt f7e1175ef0 [Meson] Fix all deprecation warnings 2021-08-06 07:56:16 +00:00
Wim Taymans 9229467f20 module-zeroconf: only free impl when not NULL 2021-08-05 15:49:38 +02:00
Wim Taymans 4be14c24f5 stream: improve latency param debug 2021-08-05 15:42:38 +02:00
Wim Taymans 874724877d filter: handle NULL latency param 2021-08-05 15:42:23 +02:00
Wim Taymans 83422ba62d pulse-server: bump version to 15.0.0 2021-08-05 13:32:09 +02:00
Wim Taymans dc6a81520d media-session: always call va_end 2021-08-05 13:32:09 +02:00
Pauli Virtanen 76bae0cac4 media-session: add bluez-autoswitch module
Add module that switches bluez device profile to HFP/HSP if an input
stream (non-monitor, autoconnect) appears, and the current default
output device is bluez one that does not have input route.

When all input streams are gone, switch all changed profiles back.

Pending restore state is saved to session manager state files, in order
to restore it if e.g. devices get disconnected.  This usually is not
currently necessary since the bluez5 plugin prefers to connect to A2DP
over HFP, but might matter in future with backchannel-enabled A2DP
codecs.
2021-08-05 11:27:06 +00:00
Peter Hutterer 5e5bf5f340 doc: don't double up the pw_proxy_new() documentation 2021-08-05 09:51:40 +00:00
Nils Tonnätt 761fa6f59d meson: fix meson test without building pipewire before
This adds project internal dependencies to some tests to let all
tests succeed. It is not adding all dependencies those tests actually
need.
2021-08-04 20:38:30 +02:00
Torkel Niklasson 02b4ccd782 src/pipewire/impl-node.c: Change client err/warn logs to infos
xrun, client too slow and that the client missed wakeups is not a
critical issue for us, so we patch them to be infos instead of
warnings and errors.
2021-08-04 09:37:29 +00:00
Peter Hutterer 3ced15ad22 doc: some extra docs for the core objects 2021-08-04 07:49:53 +00:00
Peter Hutterer 5561531751 doc: document the core/implementation API split a bit better
Still missing a proper review of the linked objects, but at least this
now explains why those two are split.
2021-08-04 07:49:53 +00:00
Peter Hutterer d0060fbddd test: move the client and utils tests over here 2021-08-04 07:45:06 +00:00
Peter Hutterer 99a10c1606 protocol: assert if the loop initialization fails on the connection test
This test needs an environment set up to load everything correctly,
running it directly results in a segfault. Let's make sure we assert on
a NULL loop to make this look slightly more planned.
2021-08-04 15:43:10 +10:00
Wim Taymans bba8c5daa3 client-node: add port_set_mix_info
Add a new client-node port_set_mix_info event. bump the interface
version to 4 and the event version to 1.

The event is used to send information about the peer object to the
port mixer. This can be used to track what buffers belong to what
peer.
2021-08-03 17:36:11 +02:00
Wim Taymans 62f8ffcfb2 impl-link: put the peer_id in the mix
Place the global id of the peer port in the mix so that we can track
the peer object that way.
2021-08-03 17:33:49 +02:00
Wim Taymans f4048ae663 protocol-native: fix marshal of add_port
We need to terminate the arguments with NULL.
2021-08-03 17:30:08 +02:00
Wim Taymans edfa210656 protocol: also return marshal with higher version
The marshaller needs to be of the requested version or newer.
2021-08-03 17:28:01 +02:00
Wim Taymans d25bb0e20f impl-link: reset state in INIT
When the link state goes back to init, clear any pending operations and
reset our state.
2021-08-02 18:03:26 +02:00
Wim Taymans da8f835de3 context: after suspend, reevaluate the graph
Reevaluate the graph again after we potentially suspend because of a
rate change because links might become unprepared and need to be
prepared again before the node becomes active.
2021-08-02 17:31:01 +02:00
Wim Taymans 48f7218d03 context: improve debug 2021-08-02 17:30:40 +02:00
Wim Taymans 57cbd2e963 impl-link: handle port states going backwards
When the port state goes backwards (like when suspended) update
the link state accordingly.
2021-08-02 17:28:16 +02:00
Wim Taymans 7d9dde0a1d loopback: pass all latency to the other stream
Latency configured on one streams needs to be passed directly to the
other stream.
2021-08-02 11:46:53 +02:00
Wim Taymans f71529cbaf context: add missing link prepare
It got removed accidentally in a previous commit, breaking some of the
loopback devices.

Fixes #1472
2021-08-02 10:48:42 +02:00
Peter Hutterer c9506a8597 doc: basic documentation for the logind media-session module 2021-08-02 08:27:51 +00:00
Peter Hutterer 310b4611c8 media-session: add stub docs for all media-session modules
Same basic approach as for the pipewire modules
2021-08-02 08:27:51 +00:00
Peter Hutterer 6d7e90fca2 meson: add the media-session logind sources to the media-session sources
This way the media_session_sources variable contains all source files we
build (required by the documentation build).
2021-08-02 08:27:51 +00:00
Peter Hutterer 602bed7a98 doc: add minimal documentation for the alsa endpoint SM module 2021-08-02 08:27:51 +00:00
Peter Hutterer 436eefc625 alsa-endpoint: add a FIXME for some missing code
We call setup_alsa_ucm_endpoint() before the
setup_alsa_fallback_endpoint(), but this function always returns
-ENOTSUP. Add a FIXME comment to make this more obvious.
2021-08-02 08:27:51 +00:00
Peter Hutterer 51a177eb6d tree-wide: replace strstr(a, b) == a with spa_strstartswith()
spa_strstartswith() is more immediately understandable.

Coccinelle spatch file:
	@@
	expression E1, E2;
	@@
	- strstr(E1, E2) != E1
	+ !spa_strstartswith(E1, E2)

	@@
	expression E1, E2;
	@@
	- strstr(E1, E2) == E1
	+ spa_strstartswith(E1, E2)

Applied to the tree except for alsa/acp/compat.h because it looks like
that header is still mostly as-is from PA.
2021-08-02 08:24:21 +00:00
Wim Taymans 1ff208875c context: implement dynamic rate
Add a default.clock.allowed-rates property that lists the possible
rates for the graph.

Add node.rate and node.lock-rate properties to suggest a graph rate
and lock the rate.

Collect the largest clock rate from the nodes and if it is allowed,
try to configure it as the graph rate. Only switch rates when the
driver is IDLE or suspended or when we force a rate.

No alternative samplerates are specified because we first need to
work around a common driver bug (cards with 1 cristal need the same
rate for capture as playback) for this to work.
2021-07-30 16:15:34 +02:00
Wim Taymans 8375d7b2d7 impl-node: remove unused function 2021-07-30 11:57:52 +02:00
Wim Taymans 6acf72dc30 impl-node: rework quantum and max_quantum handling
Rework the quantum and max_quantum handling. Work directly with the
latency fractions and calculate the final quantum size until we know
the samplerate.
2021-07-30 11:42:15 +02:00
Wim Taymans 7bec96640c node: add node.lock-quantum property
The graph will not switch quantums when there is an active node
with the node.lock-quantum property set to true.

It can be used to stop certain jack clients from crashing when the
quantum changes.
2021-07-30 11:42:15 +02:00
Peter Hutterer 6989b24148 pulse-server: fix json comma handling
First was never set to false, so we kept skipping the commas.

Fixes 393f3e6d05
2021-07-30 07:29:11 +00:00
Peter Hutterer b6a8f67764 module-portal: use spa_atoi32 for safer PID parsing 2021-07-30 07:24:24 +00:00
Peter Hutterer 82e427745d doc: structure the portal documentation a bit better 2021-07-30 07:24:24 +00:00
columbarius 06b03aef57 example: check which endian sdl is using
enum spa_video_format uses explicit big endian, while sdl can be either.
We need to adapt the convertion table accordingly.
2021-07-30 07:23:55 +00:00
Wim Taymans 393f3e6d05 pulse-server: align format to pulseaudio json message format
PulseAudio uses json now as the message format. Reformat our output
and parse our input accordingly.
2021-07-29 20:55:44 +02:00
Wim Taymans 08a1ca403f context: add option for soft/hard clock rate changes
Hard rate changes (the default now) makes the graph suspend so that the
driver reopens the device with the new sample rate if possible. This
causes a glitch.

Soft rate changes works as before and just changes the clock rate of
the position area, which makes everything resample things to the new
rate without a glitch.

Sample rate changes can currently still only be triggered by
configuring the settings metadata clock.force-rate
2021-07-29 17:13:54 +02:00
Wim Taymans 65e7402d01 context: log rate changes
We don't need to check, rt.position of a node is never NULL.
Check if the rate changed and log an info message, just like we do
for the quantum.
2021-07-29 16:50:39 +02:00
Wim Taymans ebf4bf8d83 context: don't follow links to inactive nodes
We don't need to follow nodes that we already visited or that are
inactive so skip them early.

Always try to prepare the link otherwise, not only for passive links
because non-passive links might also be paused because of a suspended
driver.
2021-07-29 16:43:54 +02:00
Wim Taymans 7092effaab media-session: add info when suspending a node 2021-07-29 16:38:33 +02:00
Wim Taymans 158c23b2fd impl-link: prepare link only between active nodes
We only ever want to prepare a link between active nodes so add the
check in the _prepare() functions instead. This also makes it skip
the prepare step for inactive nodes when recalculating the graph.
2021-07-29 16:33:00 +02:00
Peter Hutterer 4496aed5a6 doc: revamp the pipewire-access page
Rewording, linking to the various things, etc.
2021-07-29 16:06:36 +10:00
Peter Hutterer d1c80183d9 doc: add a media-session header file with the access-flatpak module
This adds a new top-level documentation entry for pipewire-media-session
with a list of modules (currently only one). Similar setup to the
pipewire modules, it allows us to document all modules in-place.
2021-07-29 16:06:36 +10:00
Wim Taymans 4e087caa2b jack: add per client match rules
This makes it possible to configure per client settings such as
latency and later also to lock the quantum for certain clients.

See #1456
2021-07-27 17:57:30 +02:00
Wim Taymans 8e8cb34dc2 protocol: don't place sockets in $HOME
No server will put them there and no client will look for it there.
2021-07-27 10:57:31 +02:00
Peter Hutterer b70a3dca85 protocol-native: don't initialize sockets in $HOME
Leaving sockets in the home directories is bad form, so let's not do
this.

This effectively requires XDG_RUNTIME_DIR to be set for pipewire to
work - it is set correctly on most setups anyway and on custom setups
this needs to be addressed with a custom environment.

Fixes #1443
2021-07-27 08:23:23 +00:00
Peter Hutterer 49f3d5842e test: replace all spa_assert() macros with spa_assert_se()
These are tests, we never want those to be optimized away.
2021-07-27 10:24:44 +10:00
Wim Taymans dd5b460daa client-node: remove custom target signal
The target signal is called when the peer nodes are ready and this
node needs to be scheduled. It is the in-process version of the
signal.

Remove our custom version that, just like the default version, schedules
the node implementation but doesn't do any accounting.

Makes pw-top report driver stats for bluetooth devices.

Fixes #1450
2021-07-26 15:46:21 +02:00
Wim Taymans 9f6890e10e pulse-server: improve stream cleanup
First disconnect the stream this ensures no more process events are
called. Then flush out the pending events, then destroy the stream.

Fixes #1451
2021-07-26 11:48:00 +02:00
Wim Taymans d1905716e4 impl-node: Split ALWAYS_PROCESS and WANT_DRIVER handling
Make a new PW_KEY_NODE_WANT_DRIVER to assign the node to a running
driver. (does not work yet)
Use a new variable to hold the ALWAYS_PROCESS setting and also
update want_driver.
This makes things it a bit more future proof.
2021-07-26 10:38:06 +02:00
Wim Taymans 62fa0823ec modules: virtual sink/sources need driver
Virtual sinks and sources implemented with streams need to be grouped
with a driver node to be able to schedule. We don't have a way to let it
use a default driver so add it to the pipewire.dummy driver.

This fixes stalled pipe and other streams streams.

Fixes #1407
2021-07-26 10:21:44 +02:00
Wim Taymans 16faacec92 pulse-server: don't compare string pointers
We always want to clear the provided blocklist from the properties. The
logic tries to only clear when there was a blocklist but it checks this
by comparing the string pointer to the fallback, which gives a compiler
warning.
2021-07-26 09:39:55 +02:00
Barnabás Pőcze b6405b761f pulse-server: use sizeof() instead of hard-coding
Use `sizeof("/pid")` instead of hard-coding 5
in the condition.
2021-07-25 15:17:08 +02:00
Barnabás Pőcze 627ef37a77 pulse-server: use pid_t where appropriate
Instead of `int`, use the `pid_t` type to represent
process identifiers.
2021-07-25 15:17:08 +02:00
Barnabás Pőcze 2d27497045 pulse-server: use S_ISDIR()
Use the `S_ISDIR()` macro instead of `S_IFMT` and bitwise operations
to make the code simpler.
2021-07-25 15:17:08 +02:00
Barnabás Pőcze e90a70fd49 pulse-server: check if a runtime directory could be found
Print an error message and return an error code if all
options have been exhausted without success.
2021-07-25 15:17:08 +02:00
Barnabás Pőcze 30e3884a75 pulse-server: add another check for the return value of snprintf()
In addition to checking if the resulting string would
be too long, also check whether or not snprintf failed.
2021-07-25 15:17:08 +02:00
Barnabás Pőcze 67b422fa18 pulse-server: fix potential use of dangling pointer
`getpwuid_r()` puts the strings pointed to from the returned
passwd struct into the specified buffer. Previously, that
buffer technically didn't live long enough to be usable
in the `snprintf()` call - although in practice this didn't
appear to be a problem. A particular version of GCC 11 generates
the same machine code for this function regardless whether
this patch is applied or not. Still, fix this by moving
the buffer to an outer scope.
2021-07-25 15:17:08 +02:00
Philippe Normand 8b5601947c gst: Fix logging in buffer_recycle()
The first argument should be a GObject. GstMiniObjects are not GObject.
2021-07-25 11:17:18 +00:00
Pauli Virtanen 1f0934862a bluez5: add device to blocklist 2021-07-25 11:16:36 +00:00
Pauli Virtanen 777bc89d02 pipewire-pulse: add module-switch-on-connect
module-switch-on-connect sets the configured default sink/source
whenever suitable new sink/sources appear.

This should give the same behavior as Pulseaudio's module.

This module exists mainly to provide a workaround e.g. for desktop
environments such as XFCE, whose mixer applications try to manage the
default devices assuming fully PA-like behavior, breaking default
pipewire output switching.
2021-07-24 18:51:57 +03:00
Wim Taymans 7071562334 media-session: remove default node from properties
When we remove a default node, remove it from the properties and trigger
a save of the state so that the configured default is also actually
removed from the state file.
2021-07-21 17:06:16 +02:00
Pauli Virtanen f4b0cf2758 bluez5: blocklist kernel versions that broke mSBC on several adapters
These kernel versions contain a patch ("Bluetooth: btusb: Add support
USB ALT 3 for WBS") that breaks mSBC on several bluetooth adapters.

See https://lore.kernel.org/linux-bluetooth/ca3adcf5fd1e7afa923f445d391aaa00f335c470.camel@iki.fi/
2021-07-21 17:20:12 +03:00
Wim Taymans 1ad54e8a26 spa: add 64 AUX channels
Make 64 AUX channels instead of using the CUSTOM range for them.
2021-07-21 11:25:43 +02:00
Wim Taymans d03f29eb66 pulse-server: fix channel_map check
We store the spa channel ids in the channel_map so convert them to
pulseaudio ids before comparing them to the max pulseaudio id.
2021-07-21 11:12:37 +02:00
Érico Nogueira 4c166709d0 modules: improve _gettid wrapper
- use meson to check for gettid() function, always use if available
- use syscall fallback on linux, if not
- restrict thr_self() fallback to *only* FreeBSD
- error out if there isn't any gettid impl
2021-07-20 15:51:50 +00:00
Wim Taymans a4b8bd6d52 rtkit: use _gettid() instead of getpid() in fallback 2021-07-20 17:13:26 +02:00
Érico Nogueira 9160a127b5 modules: fix typo in module-rtkit
Was using the gettid() function directly instead of the _gettid()
wrapper.
2021-07-20 12:01:21 -03:00
Wim Taymans cb3543e9b4 media-session: don't move nodes to same link-group
Refuse to move a node to a new target when they belong to the same
link-group to avoid loops.

Fixes #1376
2021-07-20 09:52:57 +02:00
Wim Taymans 6e44c081b0 modules: silence some useless warnings
Fixes #1423
2021-07-19 18:30:22 +02:00
Wim Taymans bd98c6771e modules: make a default node.link-group property
When nothing else is specified, add a default node.link-group property
so that all the nodes from this echo-canceler are tagged as being linked
together in some way.

This allows the session manager to follow the relations between the
different streams and avoids linking those related nodes together, which
avoids playing or recording from itself in a loop.

Fixes #1376
2021-07-19 18:21:11 +02:00
Wim Taymans 587e9d5fb1 mem: remove unused global mempools list
The mempools list keeps track of all allocated mempools but is otherwise
not used. Because it is not protected with a lock, concurrent contexts
or thread loops can step on eachother and crash. Remove this for now
until we actually need it and implement it with some sort of lock.

Fixes #1416
2021-07-19 12:13:25 +02:00
Peter Hutterer 257fd83f65 Replace Pipewire with PipeWire for consistency
And set up a CI job to check for that.
2021-07-14 16:56:54 +10:00
Arun Raghavan 3bde823e74 pipewire-pulse: Fix media.class setting on pipe sink/source
Fixes: https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/1407
2021-07-12 01:31:58 -04:00
Wim Taymans 33e07cc984 pipewire-pulse: don't republish when object changes
Ignore changes to the object. Otherwise, we would remove and publish
the device again for each volume change.

Fixes #1406
2021-07-07 17:38:17 +02:00
Wim Taymans 33f90abfb5 impl-link: use loopvisited variable for loop checking
Don't reuse the visited variable for checking feedback loops because the
scheduler expects it to be false on entry. Use a different variable
instead.
2021-07-07 15:56:39 +02:00
Wim Taymans afb7090ba0 media-session: reevaluate current profile only for its own routes
Only check the current active profile when some routes changed that are
part of the profile. If some other route changed, just ignore it.

Fixes #1403
2021-07-07 15:12:44 +02:00
Peter Hutterer 1bd43e8282 test: skip the endpoint test under valgrind
This test currently prevents us from running the test suite in valgrind but
it's not a straightforward fix. So in the meantime, skip this test when
running under valgrind.
2021-07-07 11:03:23 +00:00
Peter Hutterer 0f5e462909 tests: fix indentation issues in meson.build 2021-07-07 11:03:23 +00:00
Wim Taymans 6600d93d5d impl-link: improve feedback loop check
Mark peer nodes as visited and only visit them once. Reduces the
complexity a lot.
Limit the number of hops we check to 32 to avoid excessive work.
2021-07-07 12:54:09 +02:00
Jonas Holmberg 298dfa7da4 pipewire: make pw_get_prgname() thread safe
Make sure the string isn't overwritten while another thread is reading
it.

Fixes #1402
2021-07-06 19:29:16 +02:00
Wim Taymans 8184d4576a handle snprintf errors better 2021-07-06 17:56:04 +02:00
Wim Taymans d88e8edd11 avoid shadowing arguments 2021-07-06 17:55:16 +02:00
Wim Taymans 9fa72f22cb thread: fix compilation 2021-07-06 16:20:05 +02:00
Wim Taymans 1ff535e6eb spa: move thread to SPA support
It can be more generally useful eventually.
2021-07-06 15:48:20 +02:00
Peter Hutterer bba9edabee conf: don't allow a NULL config name
No functional changes, this is enforced by the only in-tree callers of
pw_conf_load_conf() but let's enforce this properly.
2021-07-06 07:14:21 +00:00
Peter Hutterer fb2d35895e conf: ignore the prefix if the config file name is an absolute path
Fixes:
$ export PIPEWIRE_CONFIG_PREFIX=/usr/share/pipewire
$ pipewire -c /etc/pipewire/bar.conf
[W][11925.530591][          conf.c:  253 conf_load()] config 0x560039ac6510: error loading config '/usr/share/pipewire//etc/pipewire/pipewire.conf': No such file or directory
[W][11925.530721][       context.c:  178 try_load_conf()] context 0x560039ac6190: can't load config /usr/share/pipewire//etc/pipewire/pipewire.conf: No such file or directory
2021-07-06 07:14:21 +00:00
Konstantin Kharlamov 64352dd256 gstpipewireformat: remove useless comparison in gst_caps_from_format
Fixes a LGTM warning:

    Empty block without comment
2021-07-06 00:07:17 +03:00
Konstantin Kharlamov 8c013b8183 modules: remove useless comparison in pw_properties_from_avahi_string
It doesn't do anything, let's just get rid of it.
2021-07-05 23:57:35 +03:00
Konstantin Kharlamov 6f39e13f11 module-zeroconf-discover: factor out pw_properties_from_avahi_string
This allows to get rid of the empty if block in comparison to
channel_map, and makes it clear that the comparison is useless. So in
the next commit we will remove it.

Fixes an LGTM warning:

    Empty block without comment
2021-07-05 23:53:46 +03:00
Wim Taymans 4abcfcdfb9 improve some debug 2021-07-05 16:06:22 +02:00
Wim Taymans c0b002689b impl-link: don't recalc latency on feedback links
Or else we might keep updating the latency in a loop.
2021-07-05 16:00:27 +02:00
Wim Taymans dc5ed8f327 thread: add methods to get rt priority range 2021-07-05 11:35:27 +02:00
Peter Hutterer 488150fac6 modules: document roc ports to be TCP/UDP ports
Let's make this really obvious that we're not talking about a pipewire port
here.
2021-07-05 08:57:41 +00:00
Evgeniy Khramtsov 91988acb6b utils: fix public API with consumers using _POSIX_C_SOURCE on FreeBSD
cb6dbd165a made public API incompatible with consumers using
_POSIX_SOURCE, _POSIX_C_SOURCE or _XOPEN_SOURCE: <sys/mount.h>
isn't standalone but depends on BSD-specific types in <sys/types.h>
which are hidden when POSIX compliance is requested.

xdg-desktop-portal-wlr passes -D_POSIX_C_SOURCE=200809L via meson.build
which works for its own code and all other dependencies.

In file included from ../src/core/main.c:7:
In file included from /usr/local/include/pipewire-0.3/pipewire/pipewire.h:35:
In file included from /usr/local/include/pipewire-0.3/pipewire/client.h:35:
In file included from /usr/local/include/pipewire-0.3/pipewire/proxy.h:108:
In file included from /usr/local/include/pipewire-0.3/pipewire/protocol.h:48:
In file included from /usr/local/include/pipewire-0.3/pipewire/utils.h:34:
In file included from /usr/include/sys/mount.h:38:
/usr/include/sys/ucred.h:99:2: error: unknown type name 'u_int'
        u_int   cr_version;             /* structure layout version */
        ^
In file included from ../src/core/main.c:7:
In file included from /usr/local/include/pipewire-0.3/pipewire/pipewire.h:35:
In file included from /usr/local/include/pipewire-0.3/pipewire/client.h:35:
In file included from /usr/local/include/pipewire-0.3/pipewire/proxy.h:108:
In file included from /usr/local/include/pipewire-0.3/pipewire/protocol.h:48:
In file included from /usr/local/include/pipewire-0.3/pipewire/utils.h:34:

Reported by: Jan Beich <jbeich@FreeBSD.org>
2021-07-05 08:49:14 +00:00
Wim Taymans 5e0c9199bd context: drop RT when freewheeling
When we are freewheeling, drop the RT priority so that we don't
lock up the system too much.
2021-07-05 10:41:57 +02:00
Wim Taymans 1de16afc40 modules: use pw_thread_utils interface for module-rt*
Let the module-rt and module-rtkit provide a new pw_thread_utils
implementation.

The pw_thread_utils interface has many advantages over the old way
of boosting the thread:

1. Does not require to add a source to the loop and do priority
   boost in-thread.
2. Works on simple threads without data-loop interface.
3. Allows dropping RT priority as well.

The rtkit implementation requires a bit more work because there is
currently no pthread API to map an pthread to a tid. We make a small
wrapper thread to capture the tid with getpid() to do the mapping
ourselves. This should go when the new API arrives. See also:
(https://sourceware.org/bugzilla/show_bug.cgi?id=27880)
2021-07-05 10:26:56 +02:00
Wim Taymans 6b73d49780 data-loop: use new thread interface 2021-07-05 10:10:36 +02:00
Wim Taymans bfa3c6c137 thread: add interface to manage threads
Add an interface to create and join threads as well as change the
priority on the threads.
2021-07-05 10:05:37 +02:00
Wim Taymans e2d6545e77 jack: client_thread_id should return the data thread
Add a function in data-loop to get the natvive thread and use that
in client_thread_id() so that it returns the pthread of the
data thread instead of the caller thread.
2021-07-05 09:56:14 +02:00
Wim Taymans 4b9b97841d increase rt.limit from 200ms to 2seconds
200ms seems a little small, some plugins initialize themselves from the
RT thread and get killed. 2 seconds seem to be a better default.

The important part is that there is a limit so that runaway processes
are killed and don't lock up the system.

Fixes #1344
2021-07-04 21:57:54 +02:00
Haochen Tong 77318477bc keys: fix PW_KEY_AUDIO_RATE key name 2021-07-03 19:32:36 +00:00
Wim Taymans d14c383811 pulse-server: silence UNDERFLOW warning to info
Creating underflows is standard behaviour for many clients. PulseAudio
does not warn about this so we should not either.

Fixes #910
2021-07-03 21:14:48 +02:00
Gleb Popov 43e4625bbe Use real pthread_setname_np implementation on old FreeBSD.
pthread_setname_np differs from pthread_set_name_np in the return value, so
it is not correct to just #define one to another.
2021-07-01 17:33:45 +00:00
Wim Taymans 64a25110dc pulse-server: move quirks to a json blob
Make the quirks table as a json blob so that we can move it
out when we need to.
2021-06-30 18:10:41 +02:00
Wim Taymans 900cb596d3 pipewire-pulse: implement simple quirk database
Add a simple quirks table.

Forces S16 formats for teams sink and source info.

Forces removal of the DONT_MOVE flag for capture streams for firefox.

See #838 and #1363
2021-06-30 17:17:36 +02:00
Barnabás Pőcze f5d51162c4 treewide: mark things static and const
Mark some structures, arrays static/const at various places.
In some cases this prevents unnecessary initialization
when a function is entered.

All in all, the text segments across all shared
libraries are reduced by about 2 KiB. However,
the total size increases by about 2 KiB as well.
2021-06-30 14:44:08 +02:00
Barnabás Pőcze c0e158aa0c pipewire: global: take const argument
The elements of the array are never modified,
so change the argument to be `const`.
2021-06-30 14:44:08 +02:00
Barnabás Pőcze 9aacd36f37 pipewire: properties: take const argument
Since these particular methods never modify the
lists they receive, make the arguments `const`.
2021-06-30 14:44:08 +02:00
Barnabás Pőcze 73ea24a356 pulse-server: module-pipe-source: don't queue partial samples
If the number of bytes read is not a multiple of the stride,
then partial samples may be queued. Avoid that by storing the
last partial sample (if any) in a separate buffer,
and only queue full samples.
2021-06-30 14:44:08 +02:00
Barnabás Pőcze 8a61374592 pulse-server: module-pipe-source: set error code when entity is not pipe
Previously, the code did not set any error code, leaving res = 0,
when the file existed but it wasn't a pipe. This resulted in no
status code being returned to the client.
2021-06-30 14:44:08 +02:00
Barnabás Pőcze 9076e3e80b pulse-server: module-pipe-source: do not unlink fifo if it was there
If the module did not create the FIFO, then it should not remove it.
2021-06-30 14:44:08 +02:00
Barnabás Pőcze 7cb7d8b15b pulse-server: module-zeroconf-publish: handle uname() failure gracefully
Only add the "uname=..." entry to the Avahi string list
if `uname()` succeeds.
2021-06-30 14:44:08 +02:00
Barnabás Pőcze 9994a763d6 pulse-server: module-zeroconf-publish: remove static
`sysname` need not be static since `avahi_string_list_add_pair()`
creates a copy, and no other parts of the code have reference to
`sysname` that would require static lifetime.

Furthermore, do not hardcode the size of the array.
2021-06-30 14:44:08 +02:00
Wim Taymans 324894e605 keys: add object.register property
Add a new object.register boolean property.

Make adapter and remote-note only register when object.register
is true.

Make stream and filter not register themselves. They are always
exported to a remote server and thus don't need local
registration.

Fixes #1309
2021-06-30 13:49:34 +02:00
Wim Taymans 2c5d89ff19 pw-cli: allow '-' for port/node in create-link
Passing a '-' as the port or node for create-link will omit sending
the property to create-link so we can check if the link factory handles
missing properties too.

See #1365
2021-06-30 11:52:57 +02:00
Wim Taymans 27b9f469b5 impl-port: avoid recalculating latency on destroying port
Fixes a crash.

Fixes #1371
2021-06-30 09:36:36 +02:00
Wim Taymans d1c6114423 media-session: don't try to link to the same link-group
Avoid linking streams to a node of the same link-group because that
would be a circular link.

Fixes #1360
2021-06-29 14:02:23 +02:00
Wim Taymans c4971d17c4 keys: add node.link-group property
The node.link-group property marks streams that are internally linked
together in some way. It is used to relate the input and output streams
of some of the module streams.
2021-06-29 13:49:55 +02:00
Wim Taymans 5497d2d907 pw-cat: fix format string 2021-06-28 17:21:28 +02:00
Wim Taymans c68a7cd603 pulse-server: silence the ENOTSUP warnings
To stop the device restore extension warnings.
2021-06-28 12:43:31 +02:00
Wim Taymans 0d71068ab2 jack: make JACK use module-rt
It is more like how JACK2 does things.
We get FIFO scheduling by default and we don't get killed by RTKit
when doing long operations, which seem to be the case for many
plugins.
2021-06-28 12:24:03 +02:00
Wim Taymans de99fc3515 module-rt: use FIFO scheduling
FIFO scheduling is recommended for RT usage these days.
2021-06-28 12:23:57 +02:00
Wim Taymans c90bd14ede thread-loop: improve thread name
The thread name can only be 16 chars. We don't need to strdup the
name but copy and trunc into a fixed buffer.
We can also set the thread name right after we created the thread.
Emit a warning when we can't set the thread name
2021-06-28 12:23:08 +02:00
Sanchayan Maity d8b5ab13a5 modules: Allow roc source/sink to be used as native modules
Move the implementation of roc source and sink so that they can be used
as pipewire native modules and make the pulse module implementation use
those.
2021-06-28 12:21:34 +05:30
Pauli Virtanen 2b515b5e50 dbus: keep a ref to DBusConnection if reconnecting is not handled
Several places in the code don't handle reconnecting DBus connections
yet. In those cases, a ref to the DBusConnection handle needs to be
kept, so that there's no use-after-free if it gets freed by spa_dbus
if the connection is broken.

Adjust spa_dbus so that others keeping additional refs is safe.
2021-06-26 16:11:40 +03:00
Evgeniy Khramtsov cb6dbd165a pulse-server: move defines to the common utils.h
Previous commit was an older version that got accidentally pushed.

Improves: 3ba62287ad
2021-06-25 19:08:26 +03:00
Evgeniy Khramtsov 3ba62287ad pulse-server: add missing definitions for FreeBSD
Define struct statfs and LOCAL_PEERCRED for FreeBSD.

Fixes: 62832609c1
2021-06-25 18:53:02 +03:00
Wim Taymans 417c9ab887 modules: add an example sink and source 2021-06-25 16:44:26 +02:00
Wim Taymans aa4de60032 modules: pulse-tunnel can use RT_PROCESS
It writes samples to a ringbuffer and will not do any rt-unsafe
methods.
2021-06-25 15:51:30 +02:00
Wim Taymans 0c14ec769f pulse-server: improve sink/source state
When a sink is RUNNING but there is nothing linked to the input it must
be the monitor that is keeping it active, report IDLE for the sink in
that case.

When a source is RUNNING but there is nothing linked to the output it
must be the sink part that is keeping it active, report IDLE for the
source.

Fixes #1345
2021-06-25 13:23:22 +02:00
Peter Hutterer eb262beb22 doc: document the echo-cancel module 2021-06-25 08:42:24 +00:00
Peter Hutterer 4e3d155dc1 doc: document the access module 2021-06-25 08:42:24 +00:00
Peter Hutterer b23dfc4dc1 doc: make the pipewire keys show up in the doxygen output 2021-06-25 08:42:24 +00:00
Peter Hutterer f181232a61 doc: add the documentation infrastructure for pipewire modules
All empty pages for now but at least this makes them show up in the
documentation.
2021-06-25 08:42:24 +00:00
Peter Hutterer 0880ff9a84 spa: add spa_strendswith (copy from protocol-pulse)
Useful function, let's make it generally available.
2021-06-25 08:42:24 +00:00
Niklāvs Koļesņikovs 71d39e90ed meson: adds post meson setup/--reconfigure summary for auto features
As suggested by George Kiagiadakis, adds calls to summary() function
for each feature that is by default set to auto, so that an overview
of their effective state is printed at the end of meson setup or
meson --reconfigure command.

Currently ordering is a bit messy but tidying it up would detach
the summary() functions from the dependencies they rely on and could
be done later along with meson_options.txt re-ordering so that the
two match as much as possible.
2021-06-25 08:31:12 +00:00
Stefano Ragni 243d534476 dbus: fix bus type reported in logs 2021-06-25 08:26:00 +00:00
Barnabás Pőcze 887876bea8 pulse-server: add missing forward declarations
Part of !776.
2021-06-25 03:24:00 +02:00
Barnabás Pőcze 378ba0d51b pulse-server: clean up includes
* use <> for pipewire includes
* add missing includes
* move "manager.h"

Part of !776.
2021-06-25 03:23:54 +02:00
Barnabás Pőcze 0e48ae9f50 pulse-server: remove unnecessary struct member and includes
Part of !776.
2021-06-25 03:23:51 +02:00
Barnabás Pőcze 480fcbbba9 pulse-server: module-zeroconf-publish: use <> for system include
Part of !776.
2021-06-25 03:23:45 +02:00
Barnabás Pőcze e966b1d6f2 pulse-server: split out message-handler
Part of !776.
2021-06-25 03:23:41 +02:00
Barnabás Pőcze c9f5deb81d pulse-server: split out module handling
Part of !776.
2021-06-25 03:23:37 +02:00
Barnabás Pőcze c49ae39888 pulse-server: split out extension handling
Part of !776.
2021-06-25 03:23:35 +02:00
Barnabás Pőcze d366487116 pulse-server: split out server creation and socket handling
Part of !776.
2021-06-25 03:23:32 +02:00
Barnabás Pőcze 49d31ea0af pulse-server: split out reply, operation, client, stream
Part of !776.
2021-06-25 03:23:27 +02:00
Barnabás Pőcze b2ec1fb60a pulse-server: split out message handling
Part of !776.
2021-06-25 03:23:24 +02:00
Barnabás Pőcze 5318c0eeca pulse-server: split out media roles
Part of !776.
2021-06-25 03:23:20 +02:00
Barnabás Pőcze 62832609c1 pulse-server: split out utils
Part of !776.
2021-06-25 03:23:18 +02:00
Barnabás Pőcze 8a0f52ab78 pulse-server: split out pending-sample
Part of !776.
2021-06-25 03:23:15 +02:00
Barnabás Pőcze bee97b09e2 pulse-server: split out sample, sample-play
Part of !776.
2021-06-25 03:23:12 +02:00
Barnabás Pőcze bc4370e195 pulse-server: split out D-Bus parts
Part of !776.
2021-06-25 03:23:09 +02:00
Barnabás Pőcze acffe1b90b pulse-server: split out "collect" functions
Part of !776.
2021-06-25 03:23:04 +02:00
Barnabás Pőcze 4496c33751 pulse-server: split out volume handling
Part of !776.
2021-06-25 03:23:01 +02:00
Barnabás Pőcze 43e2c64307 pulse-server: split out format handling
Part of !776.
2021-06-25 03:22:59 +02:00
Barnabás Pőcze 8ac60cb0ae pulse-server: split out commands
Part of !776.
2021-06-25 03:22:56 +02:00
Barnabás Pőcze 738b764253 pulse-server: do not define NAME in header
Part of !776.
2021-06-25 03:22:54 +02:00
Barnabás Pőcze 8208e60b33 pulse-server: add include guard to defs.h
Part of !776.
2021-06-25 03:21:38 +02:00
Niklāvs Koļesņikovs d7cddbdb61 meson: changes meson switches for controlling session manager
Some distributions set --auto_features=enabled which messes with the
internal logic of the build system when features are used for other
purposes than pure dependency control. The only solution is to either
avoid the value auto or change the type of the option to non-feature.

This commit does the later by replacing -Dmedia-session, -Dwireplumber
and -Dsession-manager with the new -Dsession-managers array and
-Ddefault-session-manager combo options.

Fixes #1333
Fixes #1336
2021-06-24 14:22:13 +00:00
Wim Taymans 016f02616b json: don't escape / 2021-06-24 16:18:59 +02:00
Sanchayan Maity badb76147f module-protocol-pulse: Add module-roc-source 2021-06-24 11:04:23 +00:00
Sanchayan Maity e60498df51 module-protocol-pulse: Add module-roc-sink 2021-06-24 11:04:23 +00:00
Wim Taymans 17f02d8c6d filter: refactor function to fix the datatype 2021-06-24 12:50:37 +02:00
Wim Taymans f5f79cc0b9 filter: implement enum and set_param on the filter 2021-06-22 16:29:40 +02:00
Wim Taymans 79866a93cd Param: add process latency param and info 2021-06-22 16:29:29 +02:00
Pauli Virtanen 9d38d375d2 bluez5: add and use quirk for broken mic HW volume
Some headsets emit AT+VGM even though +VGM commands do not actually
adjust the recording volume.
2021-06-22 10:58:50 +03:00
Pauli Virtanen 4899b75410 media-session: add hardware volume quirks
Data from interop list in AOSP Fluoride stack.
2021-06-22 10:58:50 +03:00
Pauli Virtanen b57ae8c2a6 bluez5: add support for hardware quirk/feature database
Implement hardware quirk/feature database with pattern matching.
2021-06-22 10:58:50 +03:00
Pauli Virtanen 88077a29db media-session: add bluez hw database conf files 2021-06-22 10:58:50 +03:00
Wim Taymans 6c582d5445 filter: improve latency handling
Keep track of Latency params on ports. When adding a latency param,
parse and update the port latency info.

Add both input and output latency params on the port, even when only
one changed. Use the stored info to do this.

Implement a default latency handler that simply combines and forwards
the Latency settings on ports.

Add a CUSTOM_LATENCY flag that allows you to bypass the default
handler and implement custom logic.

See #911
2021-06-22 09:28:14 +02:00
Wim Taymans 368a12b6e9 filter: Initialize info before adding params
First initialize the port and node info, then add the params so that
the param_info flags are updated correctly. Otherwise, adding the
params would make the param readable but the init of the param_info
later would reset it back to 0 and the param would not be visible.
2021-06-22 09:21:04 +02:00
Wim Taymans 83b198215d filter: use the user param_info field for updates
Keep track of the number of updates in the user field and before
emiting the info, flip the serial flag. This makes it possible to
even emit updates when setting an even number of params.
2021-06-22 09:18:33 +02:00
Wim Taymans a152ad95d5 filter: check port id and direction
Don't crash in case someone tries to access invalid direction or
port.
2021-06-22 09:15:53 +02:00
Peter Hutterer 28a9253622 pipewire: fix a doxygen group assignment 2021-06-22 15:48:48 +10:00
Konstantin Kharlamov 84acfbbda5 media-session: switch to the route when availability changed
When a user plugs in headphones, they expect to hear an audio through
them. Currently, that usecase might or might not work with pipewire
depending on the user's luck, because pipewire instead uses port
priorities, and those apparently rarely have sane default values.

PulseAudio ignored priorities here, instead it made use of the port
right away. This should better match user expectations (who plugged in
headphones and is expecting to hear sound), so let's do the same in
pipewire.

Fixes: https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/1170
2021-06-21 13:08:50 +00:00
Konstantin Kharlamov 3512977450 media-session: correct availability type
It is actually an enum, not a uint32_t
2021-06-21 13:08:50 +00:00
Wim Taymans f85b0bfd16 pulse-server: Avoid overflow in stream read/write index
Keep separate counters for the ringbuffer and stream read/write
indexes.

The ringbuffer has 32 bits indexes while the pulse server is required
to keep 64 bit read/write indexes.

Also handle invalid seek flags.

Fixes #1331
2021-06-21 10:50:23 +02:00
Peter Hutterer 0a5ae1cf47 pipewire: drop \memberof declarations
This is obsolete since the move to doxygen groups and having \memberof blocked
the documentation in the source file from being merged with the header file.
2021-06-21 07:17:35 +00:00
Barnabás Pőcze 80e3da9b01 pulse-server: add missing minus sign
Noticed by @QuLogic.

Fixes: 87c00a6f00 ("pulse-server: add missing EWOULDBLOCK check")
2021-06-19 17:28:03 +00:00
George Kiagiadakis 2723b0c6e2 meson: export plugin and data dirs for other projects to find them
SPA_PLUGIN_DIR is exported in pkgconfig as 'plugindir'
PIPEWIRE_MODULE_DIR is exported as 'moduledir'
PIPEWIRE_CONFIG_DIR is exported only in uninstalled environments
as 'confdatadir' (not making this public due to the possible upcoming
configuration changes in pipewire)

All variables are also exported on the meson dependency objects,
so that subprojects can find them.

Wireplumber can then find them like this:

  pipewire_moduledir = pipewire_dep.get_variable(
    pkgconfig: 'moduledir', internal: 'moduledir', default_value: '')

... and this works regardless of whether wireplumber is being
configured as a subproject or using the uninstalled pkgconfig files
or using the system installation of pipewire.

This is required in order to run wireplumber tests in the
uninstalled environment with 'meson test'
2021-06-18 19:24:28 +03:00
George Kiagiadakis 7ee5172ce8 meson: integrate wireplumber as a subproject
This allows building wireplumber as part of the pipewire build
and running it in the uninstalled environment instead of media-session.

Building each session manager is individually contolled by the options:
 -Dmedia-session=auto/enabled/disabled
 -Dwireplumber=auto/enabled/disabled

And controlling which one is used in pipewire.conf is done with:
 -Dsession-manager=media-session/wireplumber

Wireplumber's source tree must be in subprojects/wireplumber/
If this is missing, the .wrap file ensures that the latest git
master is downloaded while meson configures the build.
This git tree will not be automatically updated later, you need
to ensure that it is up-to-date on your own.
2021-06-18 17:54:18 +03:00
George Kiagiadakis 7ab5c35cad meson: declare spa_dep and override_dependency() for spa and pipewire
This allows meson subprojects (or projects using pipewire as a meson
subproject) to be able to use dependency('libpipewire-0.3') and
dependency('libspa-0.2') to find the uninstalled versions of these
libraries directly from the build dir instead of going through pkg-config
2021-06-18 17:54:18 +03:00
George Kiagiadakis 19bcdaebe2 meson: use newer version of pkgconfig.generate()
pkgconfig.generate() takes a positional argument, which
is the library target for which to generate a pkgconfig file

The previous way of adding the libpipewire target in
the libraries list is deprecated in recent meson
2021-06-18 17:54:18 +03:00
George Kiagiadakis 59407d2f08 includes: update all references to extensions to point to pipewire/extensions
This also brings the advantage that all tools, examples, modules, components
can also be compiled standalone out-of-tree using libpipewire from the system
2021-06-18 17:54:18 +03:00
George Kiagiadakis 953dc22f50 src: move extensions into pipewire
This allows having the same directory structure for headers as it
is in $prefix/include when installed, so that we can build other
projects using pipewire uninstalled (via the -uninstalled.pc or
by using meson subprojects). Otherwise, external code that reasonably
includes <pipewire/extensions/foo.h> fails to compile.
2021-06-18 17:54:18 +03:00
Wim Taymans 1f04e911c5 module: handle work queue create errors
Handle NULL when creating a work queue instead of crashing. The
create can fail when we run out of fds.
2021-06-18 16:29:23 +02:00
Wim Taymans bbbc79647f pulse-server: return INTERNAL error for ENFILE/EMFILE 2021-06-18 15:56:55 +02:00
Wim Taymans 05c633a4f5 profiler: Fix crash with many streams
Write the profiler data to an allocated buffer instead of the stack
so that we can make it a little larger.

Don't try to process the data when the builder had to truncate it
because it didn't fit.
2021-06-18 15:42:14 +02:00
Wim Taymans 4518eded5b context: clean up the settings object as well 2021-06-18 15:26:20 +02:00
Wim Taymans 1662e3834f impl-metadata: don't leak the property 2021-06-18 15:26:20 +02:00
Wim Taymans fb992c3f2d impl-metadata: use the metadata method
so that we call the method of the actual implementation, not our
own implementation.
2021-06-18 15:26:20 +02:00
Wim Taymans def0caf281 pulse-server: handle out-of-files better
When we don't have enough files to accept the connection, clear the
_IN flag so that we don't try to accept if over and over again.
When a client disconnects, set the flag again so that we try to
accecpt new connections again.

See #1305
2021-06-18 15:26:20 +02:00
Wim Taymans 22b5b6b120 connection: make sure we don't overrun the fd array
Do some checks on the fd array and error out when we would overrun.
2021-06-18 15:26:20 +02:00
Wim Taymans adee3d79b9 connection: handle truncated control data
We can't recover from truncated control data so return a fatal error
that should stop the client. Truncated control data can happen when
there are no more fds available, for example.

See #1305
2021-06-18 15:26:20 +02:00
George Kiagiadakis 8cf2f134b7 gstpipewiresink: also break the connection loop when the state is STREAMING
Under some schedulers (observed in a virtualbox VM), the state may
go from PAUSED to STREAMING before this code has a chance to test it
2021-06-18 13:34:35 +03:00
Michal Vasilek a870af02f0 module-rt: define RLIMIT_RTTIME if not defined
older versions of musl libc (before 1.2) don't define RLIMIT_RTTIME
2021-06-18 09:03:46 +00:00
Arun Raghavan 3272940731 echo-cancel: Don't use application name for stream node name
This is not too useful while looking at pipeline graphs, etc. We will
likely want to expand this to also include the module id or something to
distinguish multiple echo-cancel instances (which we can currently do
via the factory ID).
2021-06-17 17:04:35 -04:00
Arun Raghavan 2d251509db doc: Drop duplicate reference to pw_global 2021-06-17 16:39:06 -04:00
Wim Taymans 3944687a14 module-protocol-simple: limit to 10 connections
Like in pulseaudio.
2021-06-17 18:37:04 +02:00
Wim Taymans 38c721993f pulse-server: limit the amount of connections
Set to 64, like pulseaudio. We might want to configure this.

See #1305
2021-06-17 18:36:28 +02:00
Wim Taymans 16755cef52 impl-metadata: fix include 2021-06-17 12:38:53 +02:00
Wim Taymans b167ada994 impl-node: take settings into account for quantum and rate 2021-06-17 11:31:42 +02:00
Wim Taymans e301048abb settings: use metadata for settings
The settings metadata can be used to modify global context properties
at runtime such as min/max quantum, loglevel and samplerate.

See #1288
2021-06-17 11:13:42 +02:00
Wim Taymans f6ce23cbe3 metadata: add vargs format method for metadata values 2021-06-17 11:11:46 +02:00
Wim Taymans beb80a06e8 media-session: use core metadata implementation
Use the core metadata implementation and export that one.
2021-06-17 11:11:45 +02:00
Wim Taymans 80ef77f994 context: add metadata implementation
Add a simple metadata implementation to the core that clients can
use to manage metadata or export.
2021-06-17 11:11:45 +02:00
Wim Taymans d8ad87fd09 context: improve settings and defaults
Make structure with defaults that holds the defaults as they are loaded
from the config file or initialized with default values.

Copy this structure to a settings version that is used at runtime.

Add a force-quantum and force-rate field in the settings that can be
used to force a quantum and samplerate if != 0.
2021-06-17 11:11:45 +02:00
Peter Hutterer 62e98aa836 test: move some of the property tests to pwtest
Mostly 1:1 move of the test-properties.c file in src to the one in test, but a
few checks were merged into the existing functions.
2021-06-17 07:08:53 +00:00
Peter Hutterer 7a6fa50575 daemon: drop the obsolete dbus policy file 2021-06-17 07:02:48 +00:00
Peter Hutterer 08525e865d daemon: simplify configuration file generation
We convert from conf.in to conf, let's make this hardcoded so we stick to
the same scheme everywhere.
2021-06-17 07:02:48 +00:00
Barnabás Pőcze bbbf5724be pipewire: module-zeroconf-discover: free correct pointer
Retrieve the pointer returned by `calloc()` and free that
instead of freeing the pointer to a member. This has worked
so far because as of yet `api` is the first member of the struct.
2021-06-16 17:39:25 +00:00
Barnabás Pőcze 58e254ec63 pulse-server: module-zeroconf-publish: remove unnecessary emit
Since !737 it is not required of modules to emit the "loaded"
event if they can load immediately, therefore remove the
unnecessary `module_emit_loaded()` call.

Furthermore remove redundant log messages as well.
2021-06-16 16:40:57 +02:00
Wim Taymans f43c57afdb pulse-server: add context listener last
Add if after we have done everything else because if there is an
error we don't remove it and there will be an invalid hook registered
in the context.
2021-06-16 12:17:39 +02:00
Wim Taymans 22bb2666c4 metadata: remove metadata when the global is removed
So that we can ensure the metadata only contains valid subject
ids.
2021-06-16 12:17:35 +02:00
Wim Taymans 07d43a001b pw-dump: remember the subject of metadata
So that we can also print it instead of printing 0.
2021-06-16 12:17:30 +02:00
Wim Taymans f15d585f8d metadata: check M permissions before changing metadata
To change a metadata, we need to be able to read the subject and also
have the M permission on it.
2021-06-16 12:17:25 +02:00
Wim Taymans 9d9e3f2d23 metadata: add client-id to properties
Add the client that owns the metadata to the properties.
2021-06-16 12:17:20 +02:00
Wim Taymans 9984dcd1ea pipewire: small comment fix 2021-06-16 12:17:15 +02:00
Sanchayan Maity 96c77e1f2f pulse-server: Implement module-pipe-source 2021-06-16 08:05:51 +00:00
Sanchayan Maity d5ee0ad8cc module-pipe-sink: Fix usage of spa_strerror
spa_strerror() works with negative error codes and async spa results.
2021-06-16 13:30:48 +05:30
Haochen Tong 18ef422f3f
filter-chain: reformat configuration 2021-06-15 20:11:33 +08:00
Sanchayan Maity 4be1981f54 module-protocol-pulse: Clean up unused #define ERROR_RETURN 2021-06-15 10:54:48 +05:30
Wim Taymans b6559289f1 pulse-server: fix compilation on some compilers 2021-06-14 15:43:32 +02:00
Wim Taymans 1bc383a7b7 pipewire-pulse: also store format/channels for sources 2021-06-12 20:30:49 +02:00
Wim Taymans ba402209ba pulse-server: use PulseAudio name for format and channels
Use the pulseaudio names for the format and channels, like the real
pulseaudio.
2021-06-12 20:29:51 +02:00
Sanchayan Maity cf93fd7f9a module-protocol-pulse: Add Avahi zeroconf publish module 2021-06-12 17:56:49 +00:00
Sanchayan Maity e66125ede0 module-protocol-pulse: Factor out some common code
Factor out some of the common code that will be required for zeroconf
support next.
2021-06-12 17:56:49 +00:00
Barnabás Pőcze bd6f63fecd pulse-server: improve module loading
Modules no longer need to emit the "loaded" event manually
if they can load immediately. In that case, the module loading
code will take care of emitting the event. If they can't,
they must return an async spa result, and emit the "loaded" event
when they see fit.

Fixes #1232
2021-06-11 20:50:30 +02:00
Barnabás Pőcze 4d02233ff3 pulse-server: don't broadcast remove event when a module wasn't loaded 2021-06-11 20:50:30 +02:00
Barnabás Pőcze f26358e958 pulse-server: module-simple-protocol-tcp: remove unnecessary struct member 2021-06-11 20:50:30 +02:00
Barnabás Pőcze 3eaea123f9 pulse-server: module-simple-protocol-tcp: add module listener 2021-06-11 20:50:30 +02:00
Barnabás Pőcze 12359b490d pulse-server: module-null-sink: provide fallback name
If no `sink_name` has been specified, use "null-sink" to avoid a
NULL pointer dereference later in the function.
2021-06-11 20:50:30 +02:00
Barnabás Pőcze 09c162c8bf pulse-server: module-null-sink: add missing version to events struct 2021-06-11 20:50:30 +02:00
Barnabás Pőcze 6f5b089767 pulse-server: clear hook list when module is freed
Moreover, rename the hook list to "listener_list".
2021-06-11 20:50:30 +02:00
Barnabás Pőcze d9befc0792 pulse-server: eliminate some memory leaks in modules 2021-06-11 20:50:30 +02:00
Barnabás Pőcze 1d5fb2a7db pulse-server: remove unnecessary struct members 2021-06-11 20:50:30 +02:00
Barnabás Pőcze cd0eb829dd pulse-server: remove redundant log messages from modules
The same information is printed in
* `on_module_loaded()`,
* `module_load()`, and
* `module_unload()`.
2021-06-11 20:50:30 +02:00
Wim Taymans b7c2e7a693 conf: the midi bridge example is from a spa-node-factory
Fixes #1294
2021-06-10 23:47:15 +02:00
Nicolai Syvertsen 01875ad223 pipewire-pulse: set description
Some applications like TeamSpeak crash when this isn't set.
2021-06-10 22:21:26 +02:00
Wim Taymans 77a4ae380e json: remove obsolete # comment handling
Comments are handled by the parser now. Keys and values starting
with # are intentional now.
2021-06-10 18:02:34 +02:00
Wim Taymans 342ae0b643 Revert "conf: Load and stack all config files."
This reverts commit db44fe47ee.

We should not be merging config files at this point. Generating config
files should be done offline and only the result is loaded here.
2021-06-10 11:28:37 +02:00
Wim Taymans 61007dd412 Revert "conf: add comment about removing sections"
This reverts commit 85d34d8d94.
2021-06-10 11:27:31 +02:00
Peter Hutterer 0cd0d6e826 meson.build: split the version data into a separate config
Use this for the version.h file so we enforce that being used everywhere
instead of accidentaly relying on whatever ends up in config.h.

The generated version.h file is identical.
2021-06-10 09:30:56 +02:00
Peter Hutterer b5e98027b7 meson.build: drop VERSION, use PACKAGE_VERSION in the C sources
Slightly better namespaced since it's not usually used anywhere else, VERSION
is too generic.
2021-06-10 09:30:56 +02:00
Peter Hutterer 5cf3c28fa4 config.h is a local header, not a system one
Change the #include accordingly, that's what we use in the rest of the tree
too.
2021-06-10 09:04:16 +10:00
Peter Hutterer da339c286f meson.build: drop HAVE_CONFIG_H
This is an autotools leftover, with meson we're always guaranteed to have
the config.h file.
2021-06-10 09:04:16 +10:00
Wim Taymans 1b5ffa7891 filter: init the Latency param correctly
See #911
2021-06-09 21:12:19 +02:00
Wim Taymans d91cc99d92 properties: escape '/' as well 2021-06-09 18:08:26 +02:00
Wim Taymans 262e609b73 conf: use serialize_dict to write state files
Instead of our home-brew version.
2021-06-09 18:00:47 +02:00
Wim Taymans 54326abd54 properties: improve serialize method
Properly escape the keys because we're trying to generate
valid JSON.
Always place ',' after items.
Add a flag to add a '\n' before each item.
Don't try to string-encode the value when it's already a string.
2021-06-09 17:57:58 +02:00
Wim Taymans 85d34d8d94 conf: add comment about removing sections
Sections that don't need to be changed can be removed because they
are now taken from the main config file.
2021-06-09 15:25:58 +02:00
Wim Taymans db44fe47ee conf: Load and stack all config files.
Load and parse config files in the following order:

$PIPEWIRE_CONFIG_DIR or /usr/share/pipewire
/etc/pipewire
$XDG_CONFIG_DIR or ~/.config/pipewire

This ensure we always load a working base config and reduce the
chances of failing because of a back user config file.

The user config file now only needs to contain the section that
needs the be changed.

See #207
2021-06-09 12:15:39 +02:00
Peter Hutterer dcfd6745d0 test: move the context tests to here 2021-06-09 18:00:39 +10:00
Peter Hutterer 493f0724b5 test: move the array tests to pwtest
Add them to the existing pw_properties test binary and rename that to
pw-utils.

Same functionality as before for the pw_array tests.
2021-06-09 18:00:39 +10:00
Peter Hutterer 0054319d88 meson.build: add -D_GNU_SOURCE to the project arguments
This appends it to every compilation command so we can get rid of the c_args
for (almost all) executables.
2021-06-09 07:47:51 +00:00
Wim Taymans 750cafd7d1 context: use pw_context_destroy() in error cases
Make sure we free all the resources of a context when it can't be
created.
2021-06-09 09:41:50 +02:00
Wim Taymans c12bdb8c6c pipewire: cleanup on error
To make leak checks more accurate.
2021-06-09 09:41:50 +02:00
Wim Taymans db245fd0ce context: override the CORE_NAME in context
Override the CORE_NAME using the env variable in the context instead
of pipewire.c. This avoids needing the _add_string() property method.
Remove the properties_add_string() method, there are new improved
plans for property parsing and merging: See #207
2021-06-08 16:56:22 +02:00
Wim Taymans 1f85d06317 module-adapter: clear bound-resource when destroyed
So that we don't reference it anymore or try to remove the listener.
2021-06-07 12:57:09 +02:00
Barnabás Pőcze b6c6a21747 pipewire: module-adapter: remove resource listener
Unregister the resource listener when the node is going
away to avoid use-after-free issues.

Fixes #1276
2021-06-07 10:54:19 +00:00
Peter Hutterer b6e27822e5 pipewire: use RUNNING_ON_VALGRIND to determine if we're in valgrind
This removes the use of the VALGRIND environment variable
2021-06-07 10:44:27 +00:00
Wim Taymans 9a90030596 pw-cli: fix command parsing after pw_split changes
Don't assume anything about the way the split function maintain the
state.
2021-06-07 11:17:45 +02:00
Arun Raghavan 08daf3f4f4 pulse-server: Add a module-echo-cancel
Fairly straightforwad module to load libpipewire-module-echo-cancel
2021-06-05 17:54:02 +00:00
Wim Taymans a2cb5f3394 properties: try to keep full doxygen docs out of headers
Try to keep the full docs out of the headers and into the .c file.
A small short blurb in the header is enough for quick lookups.
Also try to use a regular comment to not confuse the doc system.
2021-06-04 12:08:23 +02:00
Peter Hutterer 2e6621fae0 daemon: use getenv(PIPEWIRE_CORE) for the core.name if it exists
As documented in pipewire/keys.h, PIPEWIRE_CORE is supposed to overwrite the
default value.
2021-06-04 08:58:18 +00:00
Peter Hutterer f775547528 pipewire: merge, not overwrite the context.properties from the config file
Any values already set in the properties list (e.g. from earlier getenv())
calls should not be overwritten by the value in the config file.
2021-06-04 08:58:18 +00:00
Peter Hutterer b179e81070 pipewire: add pw_properties_add_string()
Equivalent to the existing pw_properties_update_string() but only adds new
properties from the given string, it doesn't overwrite existing ones.
2021-06-04 08:58:18 +00:00
Wim Taymans 2a8b7594bc pulse-server: avoid overflow
Make sure the requested bytes never go below 0.

See #1258
2021-06-04 09:13:43 +02:00
Barnabás Pőcze e65afe8fa2 pulse-server: module-combine-sink: remove hooks
Remove hooks when the module is unloaded to avoid
use-after-free issues. Remove the cleanup source as well.

Fixes #1259.
2021-06-04 06:55:08 +00:00
Peter Hutterer 4cb87317a7 pipewire: assert a nonzero array allocation size
If pw_array_ensure_size() is called on an array that has not been initialized
with an extend, assert. Otherwise we get stuck in an infinite loop since
doubling our zero allocation size will never reach "need".
2021-06-04 09:00:34 +10:00
Wim Taymans 0ba9402d4b Revert "media-session: use direction to find the node by name"
This reverts commit b0068fd46b.

It breaks recording from monitor ports.
2021-06-03 20:33:59 +02:00
Wim Taymans 669fbf10c1 fix some leaks in error paths 2021-06-03 20:33:59 +02:00
Barnabás Pőcze 6affda9424 pipewire: utils: add more tests for pw_split_walk() 2021-06-03 17:23:42 +02:00
Barnabás Pőcze 3b681f2138 pipewire: utils: pw_split_walk(): skip leading runs of chars in delimiter
Previously, if the string started with any of the characters in
delimiter, the first returned string would've been an empty string.
This is in contrast with the fact that otherwise `pw_split_walk()`
skips empty fields.

E.g.

  "::field1::field2" with ":" as `delimiter`

would have resulted in
 *  ""
 *  "field1"
 *  "field2".

Adjust the function to skip leading runs of characters in `delimiter`
by calling `strspn()` first.
2021-06-03 17:06:16 +02:00
Barnabás Pőcze 576513583b pipewire: impl-module: limit module search depth
Limit the depth of the recursive search done by `find_module()`
to a sensible amount (at the moment: 8).
2021-06-03 17:06:16 +02:00
Barnabás Pőcze a8428a57b1 pipewire: impl-module: simplify module dir handling logic
Since `pw_split_walk()` does not skip leading runs of
delimiters, if `module_dir` is an absolute path, then

  l = pw_split_strv(module_dir, "/", 0, &n_paths);

will return an array of one element, which is exactly the same
as `module_dir`, `strcmp(l[0], module_dir) == 0`.

If `module_dir` is a relative path, then the returned array
still contains a single element, which is, again, the same
as `module_dir`.

Therefore, omit the the call to `pw_split_strv()` and simply
use `module_dir` as is.
2021-06-03 17:06:16 +02:00
George Kiagiadakis 131832d441 pulse-server: suffix TAG_USEC constants with LL, as they must be 64-bit
Fixes protocol errors on arm
2021-06-03 17:36:19 +03:00
Wim Taymans 6971d11901 pw-cat: support u8 format as well 2021-06-03 10:10:18 +02:00
Peter Hutterer 8b98d111e1 context: print the correct strerror if the config load failed
"can't load config client.conf: Success" is a bit confusing otherwise.
2021-06-03 09:51:34 +02:00
Arun Raghavan d2d0375c39 module-echo-cancel: Change extension .cc to .cpp for aec-webrtc
Makes this consistent with the rest of the code base.
2021-06-02 18:26:19 -04:00
Arun Raghavan d95870d8d3 module-echo-cancel: Wire up the webrtc echo canceller
Mostly uses the existing infrastructure, but the webrtc canceller has a
fixed blocksize, so we:

  1. Use the canceller blocksize if configured
  2. Accumulate output data in a ringbuffer
  3. Push out the data in the required chunk size
2021-06-02 17:56:40 -04:00
Arun Raghavan 1349d5334d module-echo-cancel: Drop buffers on overruns
Without this, if we do overrun, we'll never catch this.
2021-06-02 12:50:16 -04:00
Arun Raghavan bbae1adda0 module-echo-cancel: Separate input gathering and output processing
This aggregates buffers from the capture stream and the sink in the
corresponding process callbacks, and runs processing based on the
desired resampler rate if there is one.

We allow the ringbuffer in which we capture buffers to grow to some
extent, as that seems to be required for playback to occur smoothly.
Whether this is hiding some other underlying problem likely needs
investigation.
2021-06-02 12:46:12 -04:00
Arun Raghavan 42196a331d module-echo-cancel: Consolidate includes 2021-06-02 12:46:12 -04:00
Wim Taymans 58d0e44664 pipewire: Add option to disable config files
Add env variable PIPEWIRE_NO_CONFIG to disable parsing
custom config files.
Add a method to check extra options.
Expose valgrind, no-config and no-color as options.
2021-06-02 15:55:24 +02:00
Wim Taymans dde03a7dd3 config: add some comments in the config file
About where to copy and change it.
2021-06-02 15:22:49 +02:00
Peter Hutterer 1d4b24d02b pipewire: allow NULL pointers in pw_memmap_free()
Just like the real free() we should just ignore a NULL pointer, makes the
caller code easier for those instances where properties are optional.
2021-06-02 10:56:46 +00:00
Peter Hutterer 71e0cfb5fa pipewire: allow NULL pointers in pw_free_strv()
Just like the real free() we should just ignore a NULL pointer, makes the
caller code easier for those instances where properties are optional.
2021-06-02 10:56:46 +00:00
Peter Hutterer e0471c6757 pipewire: allow NULL pointers in pw_properties_free()
Just like the real free() we should just ignore a NULL pointer, makes the
caller code easier for those instances where properties are optional.

Patch generated with concinelle with a few manual fixes.
2021-06-02 10:56:46 +00:00
Peter Hutterer a1e821c259 pw-dump: use the spa_ato* helpers for string to number conversions 2021-06-02 07:39:41 +00:00
Peter Hutterer 3796bc814e pipewire: use spa_ato*() to parse properties
For boolean properties:
- passing in NULL no longer crashes and instead returns false
- passing in a string starting with 1 (e.g. "1xyz") no longer resolves to true

For int-based properties:
- passing in NULL no longer crashes and instead returns 0
- passing in invalid numbers no longer resolves to whatever number prefix
  could be parsed (e.g. "123foo" was 123)
2021-06-02 07:39:41 +00:00
Peter Hutterer 1a5faa7b52 spa: add a header for ANSI color sequences
Makes the code more readable and guarantees we use the same sequences for the
same colors everywhere.
2021-06-02 14:17:29 +10:00
Barnabás Pőcze 4c13eced55 pulse-server: detach clients from server
When the server or client goes away, detach the client
from the server to avoid potential use-after-free issues
that might occur if the client causes the
unloading of the server it is connected to.

E.g.:

  pactl load-module module-protocol-native-tcp port=4713
  pactl -s localhost:4713 unload-module module-native-protocol-tcp

See #1240.
2021-06-01 22:11:49 +02:00
Wim Taymans 3889ea5277 pulse-server: add ref to client while processing
Add a ref to the client while processing messages. This way we don't
destroy the client if we destroy the server it is on.

Fixes #1240
2021-06-01 17:48:24 +02:00
Wim Taymans 102b77ea03 pulse-server: don't request already requested data
When we are flushing, don't ask for already requested bytes
or else we end up with too much data in our buffer.

Fixes #1243
2021-06-01 16:59:00 +02:00
Wim Taymans 0f55ff9e60 stream: clarify buffer onwership and lifecycle
Fixes #1126
2021-06-01 12:25:44 +02:00
Wim Taymans e994949d57 properties: make safer serialize_dict implementation
Don't use alloca for the serialized string but instead write the
serialized string directly to the file.

Fixes #1249
2021-06-01 10:37:15 +02:00
Barnabás Pőcze 1cb613ee4b pulse-server: terminate connection in more cases
If any of those two branches are taken, the connection
cannot make forward progress since no data will be read/sent
from/to the client.

For example, sending just 21 invalid bytes to the server
causes the first 20 bytes (client descriptor) to be read,
then rejected, leaving `client->message == NULL`. But since
polling is level triggered, `on_client_data()` and thus
`do_read()` will continue to be called ceaselessly,
thereby spamming the log and wasting resources.
2021-05-31 21:34:58 +02:00
Barnabás Pőcze bc6adbe15d pulse-server: make control flow easier to unserstand
Use a switch statement to make the control flow
a bit easier to understand.
2021-05-31 21:34:58 +02:00
Barnabás Pőcze 87c00a6f00 pulse-server: add missing EWOULDBLOCK check 2021-05-31 21:34:58 +02:00
Barnabás Pőcze ebed44db79 pulse-server: support absolute unix socket paths
If a unix socket address starts with '/', use it
directly as an absolute path, do not prepend
the runtime directory.
2021-05-31 21:34:58 +02:00
Barnabás Pőcze 70c6e6ccc8 pulse-server: only unlink sockets
If the entity specified in a unix socket address exists, check
if it is a socket, and bail out if it is not.
2021-05-31 21:34:58 +02:00
Wim Taymans a248391939 echo-cancel: set latency on the right streams 2021-05-31 16:15:37 +02:00
Wim Taymans 7f912a1cff impl-port: improve Latency param check
We can use the latency param when we have a Writable entry in the
param_info.
2021-05-31 16:13:42 +02:00
Wim Taymans 743eaf4aa2 filter: add PARAM_Latency support
Announce the Latency param in pw-filter.
Mark the latency param as writable. It becomes readable when we provide
a value.
2021-05-31 16:12:26 +02:00
Wim Taymans 8485622923 echo-cancel: reuse buffer on error
Queue the dequeued buffers when there is an error so that we can
recover.
2021-05-31 15:53:34 +02:00
Wim Taymans b0068fd46b media-session: use direction to find the node by name
Also use the stream direction when finding a node by name. We should
only select nodes that have the right direction.
2021-05-31 15:40:26 +02:00
Wim Taymans d37ea7851a echo-cancel: copy some more node properties 2021-05-31 15:17:00 +02:00
Wim Taymans a2cab35365 echo-cancel: use the right node.group 2021-05-31 15:01:33 +02:00
Wim Taymans c803444123 impl-port: only send latency param when supported
Check if the port has latency param and only try to set the
latency param when it appears available. This avoids sending unknown
latency params to an old client and erroring out.
2021-05-31 11:31:18 +02:00
Evgeniy Khramtsov 3cf4bf7cf7 modules: build module-rt only on Linux
RLIMIT_RTTIME is Linux specific, there is no equivalent replacement
for FreeBSD. Save trouble and build module-rt for Linux only, rtkit
WIP fork should be fine on FreeBSD for now.
2021-05-30 15:30:45 +03:00
Barnabás Pőcze 2a8d511be8 pipewire: map: initialize free_list to SPA_ID_INVALID
If `struct pw_map::free_list` is not initialized to `SPA_ID_INVALID`,
then `pw_map_insert()` will try to read `map->items.data[0]` when
inserting the first element, but `data` is a `NULL`
pointer after initialization.
2021-05-30 00:21:43 +02:00
Wim Taymans 0eb46d8ef4 filter: call the process rt_callback 2021-05-29 08:41:37 +02:00
Wim Taymans 934caab1e1 stream: emit events from only one thread
Emitting events using the listener_list can not be done from multiple
threads at the same time.  For this reason, make a copy of the events
with the process event and call it explicitly from the data thread.

See #1122
2021-05-28 13:24:10 +02:00
Wim Taymans a138152bef pulse-server: free message when resize fails
Based on patch by Peter Hutterer

Fixes !701
2021-05-28 11:52:29 +02:00
Wim Taymans 913434167d modules: remove some useless device names 2021-05-28 11:20:06 +02:00
Wim Taymans b9efb25605 pulse-tunnel: handle latency a little better
Set a limit on the buffer size.
Announce our latency on the streams.
2021-05-28 11:19:05 +02:00
Barnabás Pőcze 48f03f85a7 pulse-server: add support for IPv6
Add support for listening on IPv6 addresses.
The following address formats are supported:
 * tcp:[<ipv6-addr>]:<port>,
 * tcp:<ipv4-addr>:<port>,
 * tcp:<port>, and
 * unix:<path>.

The IP addresses are parsed using `inet_pton()`,
only the formats supported by that function
are accepted.

The IPv6 address must be surrounded by square brackets,
they do not mean "optional" here. Specifying only the
port is equivalent to the following two addresses:
 * [::]:<port>, and
 * 0.0.0.0:<port>.

Address parsing has been made stricter: the port
must always be specified explicitly.

Fixes #1216.
2021-05-27 21:12:14 +02:00
Barnabás Pőcze 279470bc07 pulse-server: native-protocol-tcp: do not hardcode port
Use `PW_PROTOCOL_PULSE_DEFAULT_PORT` from pulse-server.h
instead of hard-coding the default port.
2021-05-27 19:32:02 +02:00
Wim Taymans 06cf1e1c00 module: proxy latency params 2021-05-27 16:07:25 +02:00
Wim Taymans e7eba82002 port: keep both output and input latency on port
But only emit latency changes for the latency matching the port.
2021-05-27 15:26:09 +02:00
Wim Taymans 07f8a0d275 impl-port: remove useless code
We already check for 0 as the undefined value in the combine
function.
2021-05-27 15:26:09 +02:00
Wim Taymans f383ac21dd pw-cat: remove debug 2021-05-27 15:26:09 +02:00
Wim Taymans bae0622311 filter-chain: pass latency param along
Intercept the latency param and pass it on the right stream.
2021-05-27 15:26:09 +02:00
Wim Taymans d8e9a43b9c stream: handle Latency param
Handle the latency param and remember the latency. Add the latency
to the delay value in the time.

Also make it possible to add custom Latency params.
2021-05-27 15:26:09 +02:00
Wim Taymans 80d48ad3b6 link: recalc latency when the peer latency changed
Trigger a recalculation of the port latency when the peer port
latency changed.

This makes the latency update from a port propagate through the
pipeline.
2021-05-27 15:26:09 +02:00
Wim Taymans cd58c51582 port: implement latency_changed event
Emit the latency changed event when the latency was updated.
2021-05-27 15:26:09 +02:00
Wim Taymans b9b89b92b2 spa: add some latency helpers
Add more fields to the latency object.
Add methods to create, parse and process latency info.
2021-05-27 15:26:09 +02:00
Wim Taymans cd32404e92 port: implement latency reporting some more
Implement a port recalculate latency method that takes the min
and max latency of all peer ports and sets that as the new port
latency.
When a link is made, let the output and input port recalculate
latencies.
Pass latency param in audioconvert.
2021-05-27 15:26:09 +02:00
Wim Taymans 46ef88e520 spa: save the old change_mask and restore when emitting full
When we add a new listener to an object, it will emit the full state
of the object. For this it temporarily sets the change_mask to all
changes. Restore the previous state after this or else we might not
emit the right change_mask for the next listener.

Consider the case where one there are two listeners on an object.
The object emits a change and the first listener wants to enumerate the
changed params. For this is adds a new listener and then triggers the
enumeration. If we set the change_mask to 0 after adding the listener,
the second listener would get a 0 change_mask and fail to update
its state.
2021-05-27 15:21:44 +02:00
James Henstridge 733ad43d3f module-portal: direct GetConnectionUnixProcessID call to /org/freedesktop/DBus
The D-Bus specification says that the message bus accepts method calls
on other object paths for backwards compatibility, and may reject
security sensitive calls on unexpected object paths:

https://dbus.freedesktop.org/doc/dbus-specification.html#message-bus-messages
2021-05-27 11:24:04 +00:00
Wim Taymans 751f9a9ea0 dbus: make sure we don't unref a NULL dbus connection
See #1213
2021-05-26 10:52:38 +02:00
Wim Taymans 492caf4456 pulse-server: handle errors during create
If a stream is being created and an error occurs we always need to
reply with the pending create_tag.

Fixes #624
2021-05-26 10:44:59 +02:00
Wim Taymans 4e4294dc13 pulse-server: handle NULL dbus connection
Fixes #1224
2021-05-26 10:23:17 +02:00
Wim Taymans f007ca475c pw-cli: handle failure to create context
Fixes #1234
2021-05-26 10:18:15 +02:00
Wim Taymans 8027c9225e context: log some more errors when config file fails 2021-05-26 10:17:40 +02:00
Peter Hutterer b64f0d581f doc: switch from .md to .dox files and impose some general structure
This is an attempt of breaking up the documentation, currently spread across
several pages. We're left with a few high-level topics with various things
grouped underneath those.

Further refinement is necessary, but this can now be done in incremental steps
over massive reworks.
2021-05-26 10:02:10 +02:00
Peter Hutterer 13bb152840 doc: fix a copy/paste-o 2021-05-26 10:02:10 +02:00
Peter Hutterer 5e5b9e3050 conf: PIPEWIRE_CONFIG_DIR should take precedence if set
This matches the behavior of most applications - check environment variables
first, then fall back to the various built-in options (in our case xdg, /etc/
/usr/share, in that order).
2021-05-26 07:54:29 +00:00
Peter Hutterer 25a58fd939 examples: fix scan-build errors for unused variables
All cases of value stored but never read
2021-05-26 07:51:27 +00:00
Peter Hutterer e1211e6a94 tools: fix scan-build errors for unused variables
All cases of value stored but never read
2021-05-26 07:51:27 +00:00
Peter Hutterer 0b5f19f1d2 pipewire: fix scan-build errors for unused variables
All cases of value stored but never read
2021-05-26 07:51:27 +00:00
Peter Hutterer 049eaac821 modules: fix scan-build errors for unused variables
All cases of value stored but never read
2021-05-26 07:51:27 +00:00
Peter Hutterer 07503410c7 stream: fix scan-build errors for unused variables
All cases of value stored but never read
2021-05-26 07:51:27 +00:00
Peter Hutterer 2cb7b19b7d pulse-server: fix scan-build errors for unused variables
All cases of value stored but never read
2021-05-26 07:51:27 +00:00
Peter Hutterer 6d19dd0162 pulse-server: if all transport methods failed, fail server creation
No point in keeping a server running if it doesn't listen to anything.
2021-05-26 07:46:55 +00:00
Barnabás Pőcze 1e9442e6b8 pulse-server: fix memory issue
Previously, when `pw_protocol_pulse_new()` returned NULL,
the code would jump to the `error` label, which would
call `impl_free()`. At this point, however, `impl->module_listener`
is not initialized, which would lead to a SIGSEGV when
`spa_hook_remove()` is called from `impl_free()`.
2021-05-25 14:55:00 +02:00
Wim Taymans 8e36353311 pulse-server: module-combine-sink remove right property 2021-05-24 12:58:10 +02:00
Arun Raghavan 25f9765e9c pulse-server: Implement module-combine-sink 2021-05-24 08:34:23 +00:00
Fabrice Fontaine fa64d93e64 fix linking with -latomic
Linking with -latomic has been added to pipewire-jack since
b8c58c74d8

However, this is not the right place to add this dependency, atomic_dep
should be added to pipewire_dep to avoid the following build failure:

/home/giuliobenetti/autobuild/run/instance-0/output-1/host/opt/ext-toolchain/bin/../lib/gcc/sparc-buildroot-linux-uclibc/9.3.0/../../../../sparc-buildroot-linux-uclibc/bin/ld: src/pipewire/libpipewire-0.3.so.0.326.0.p/filter.c.o: in function `impl_node_process':
filter.c:(.text+0xf28): undefined reference to `__atomic_fetch_add_4'

Indeed, atomic operation such as __atomic_fetch_add is used in libcamera
as well as in ./spa/plugins/libcamera/libcamera_wrapper.cpp,
./spa/include/spa/utils/ringbuffer.h and ./spa/include/spa/graph/graph.h

Fixes:
 - http://autobuild.buildroot.org/results/b5305e8e7dd1a5e8bfaba72b06251056ba7d1af1

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
2021-05-24 08:33:50 +00:00
Barnabás Pőcze 22d874cdeb filter-chain: handle LADSPA_PATH as colon separated list of paths
Split up LADSPA_PATH at colons, and try to load the particular
plugin from each directory specified in LADSPA_PATH.

Fixes #1217.
2021-05-24 08:23:21 +00:00
Barnabás Pőcze 67e588f382 filter-chain: actually use ladspa_handle_list
Add successfully loaded handles to the list in `ladspa_handle_load()`,
and remove them when they are freed in `ladspa_handle_unref()`.
2021-05-24 08:23:21 +00:00
Barnabás Pőcze a8a6def20f filter-chain: fix reference counting issue
Fix a reference counting issue that resulted in
ladspa_handle's refcount being equal to the
sum of the refcounts of its descriptors.

This would result in a memory leak when a descriptor
is loaded more than once from the same handle.
This cannot happen because `ladspa_handle_list` is
not  populated by `ladspa_handle_load()`.
The next commit implements exactly that, so
the fix is applied before the change that
would introduce the problem.
2021-05-24 08:23:21 +00:00
Barnabás Pőcze e9ba0899c2 filter-chain: fix rnnoise example configuration
Other filter-chain configuration file examples do not prefix
the plugin key with 'ladspa/'. And in the absence of
the LADSPA_PATH environmental variable, this would lead
to "/usr/lib64/ladspa/ladspa/librnnoise_ladspa.so" being used
as the path, which is not correct.
2021-05-24 08:23:21 +00:00
Sjoerd Simons d2e1b968af Let pipewire-pulse services conflict with their pulseaudio counterparts
You can only run either pulseaudio *or* the pipewire-pulse daemon at one
time. So make the pipewire-pulse units conflict with their pulseaudio
counterparts to avoid both running at the same time
2021-05-22 14:26:30 +02:00
Wim Taymans 3c503ca240 impl-link: improve debug, log param name 2021-05-21 10:46:14 +02:00
Wim Taymans 36000ea508 stream: clean up the params
Use defines for the param index.
Fix params for filter. Make it possible to use Props params.
2021-05-21 10:45:19 +02:00
Peter Hutterer cbe29c070c doc: switch doxygen to using groups instead of pages and classes
C code doesn't lend itself well to using classes and pages are best for prose.
A doxygen group is a set of related functions - which is exactly what we have
here, e.g. pw_context.

This patch basically adds the following lines to each header:
\defgroup pw_whatever
\addtogroup pw_whatever
\{
....  function declarations ....
\}

Doxygen is smart enough to merge documentation in the header with
documentation in the correspondin .c file where the function is implemented.
2021-05-21 15:05:30 +10:00
Peter Hutterer 7c4bfe5a15 doc: use markdown ticks instead of escaped html for readability 2021-05-21 15:04:22 +10:00
Peter Hutterer 923e7c8b59 doc: doxygen can't document a nonexisting enum 2021-05-21 15:04:22 +10:00
Peter Hutterer 1567dd4e3a doc: fix some missing parameter warnings
Where both declaration and definition are documented, drop one and rely on the
other. Drop the obvious documentations where not needed, doxygen wants either
none or all parameters documented.
2021-05-21 15:04:22 +10:00
Peter Hutterer ac9de03672 doc: document some missing parameters 2021-05-21 15:04:22 +10:00
Peter Hutterer c9cab11a82 doc: drop two references to entities we don't include in doxygen 2021-05-21 15:04:22 +10:00
Peter Hutterer f47f85bbcb doc: fix broken references
These pages never existed, let's not try to reference them.
2021-05-21 15:04:22 +10:00
Peter Hutterer 0c41f24401 doc: fix an outdated reference 2021-05-21 15:04:18 +10:00
Peter Hutterer ef6528c513 doc: fix an obsolete reference to pw_fill_stream_properties
As of f724319e8a this happens automatically and
the function is no longer available.
2021-05-21 14:19:13 +10:00
Peter Hutterer ff7675b142 doc: escape the use of <pid> and <username> with markdown
Doxygen complains about invalid HTML tags, let's mark them as code.
2021-05-21 14:18:50 +10:00
Peter Hutterer 2b626bc31a doc: add a missing endcond to the context 2021-05-21 14:18:50 +10:00
Peter Hutterer 1ce6db47e3 doc: drop meaningless cond/endcond 2021-05-21 14:18:50 +10:00