Commit graph

4031 commits

Author SHA1 Message Date
Peter Hutterer 2306124f49 doc: fix listing of the new No DSP media-session module
And copy the text from the comment into the public documentation, better
than just having an empty page there.
2021-09-07 07:52:45 +00:00
Wim Taymans 7e4d5b142f pulse-server: don't leak format info 2021-09-07 09:51:58 +02:00
Peter Hutterer 8bb0e340c7 protocol-pulse: fix two -Wformat-nonliteral warnings
For the stream group, we break into the three components we write out
and print those.

For the IPv6 address printing inside [], we can make this a condition on
the printf statement.
2021-09-07 08:57:28 +10:00
Peter Hutterer 6a18272fed spa: mark the gettext wrappers with __attribute__((format_arg))
This removes the -Wformat-literal warnings for all _("some message")
calls. Remaining warnings are those where we pass in a custom buffer.
2021-09-07 08:26:10 +10:00
Pauli Virtanen b5ad37c7ac bluez5: make codec loading compatible with old conf files
Change codec factory names to api.codec.bluez5.*, so that they won't
conflict with old config file lib name rules for api.bluez5.*

Specify the fallback library name when loading the codecs, so that it
works without the rules in config files.
2021-09-06 18:04:35 +03:00
Wim Taymans 435de99428 Increase pod buffer size
The props of a 64 channel node are at least 2048 bytes long so make sure
we can build and filter them.

Fixes #1574
2021-09-06 15:09:28 +02:00
Peter Hutterer 8d741d6077 alsa-monitor: document this module in some detail 2021-09-06 07:29:28 +00:00
Peter Hutterer 7cb718833b alsa-monitor: reword the match rule comment in the config file
Each dictionary needs to fully match but out of the dicts we have, only
one needs to match to apply. Reword that for clarity.

Also document regex vs normal string comparison vs the magic null
string.
2021-09-06 07:29:28 +00:00
Peter Hutterer 6f9586bf54 media-session: use more descriptive names for parsing match rules
Easier to understand this way what is being passed around and where
we're at with the parsing.
2021-09-06 07:29:28 +00:00
Peter Hutterer 6b6f5f3659 doc: mention xdg-desktop-portal in the media-session access-portal module
Makes it slightly easier to connect the dots.
2021-09-06 07:29:28 +00:00
Peter Hutterer 55f01ae679 media-session: document the access-flatpak module 2021-09-06 07:29:28 +00:00
Peter Hutterer 08be841a9e doc: fix a doxygen undocumented parameter warning 2021-09-06 07:29:28 +00:00
Pauli Virtanen abc01083d4 context: fixup integer overflow 2021-09-05 06:26:58 +00:00
Pauli Virtanen f85d3907ef bluez5: add a device to hw-volume blocklist 2021-09-03 19:09:16 +00:00
Pauli Virtanen 68e8846096 bluez5: update kernel version blocklist
Patch fixing ALT1 mSBC is in Linux 5.10.62, 5.13.14, 5.14.1, 5.15-rc
2021-09-03 19:09:16 +00:00
Pauli Virtanen 59d572de09 bluez5: split A2DP codecs to separate SPA plugins
Make easier to package A2DP codecs separately, by splitting each to a
separate SPA plugin.  Adjust the code to not use a global variable for
the codec list.

The A2DP SPA interface API is in the bluez5 private headers, and not
exposed in installed SPA headers, as it's too close to the
implementation.
2021-09-03 20:40:30 +03:00
Pauli Virtanen 3115775c02 context: add SPA plugin loader interface to support plugins 2021-09-03 20:12:28 +03:00
Julian Bouzas 90371440b0 media-session: add alsa-no-dsp module
Instruct the policy to not configure audio adapter nodes in DSP mode. Instead,
Device nodes will always be configured in passthrough mode, and client nodes
will be configured in convert or passthrough mode depending on whether the
client format matches the device format or not.
2021-09-03 14:00:27 +00:00
Wim Taymans 91f1b44499 introspect: improve info updates
The current _info_update() methods will always reset the change_mask in
the new info structure.

This causes problems if multiple updates are applied to the info before
the rescan in the session manager of pulse-server is excuted. The first
update is cleared and this causes the session manager to sometimes miss
the state changes of nodes and fail to suspend them.

Add a new method to merge with optional reset of the various
introspection info structures. We can use this instead and simply
accumulate all changes until the rescan code has processed all changes.
2021-09-03 13:41:14 +02:00
Wim Taymans a5e37540ff impl-node: recalc graph when destroying a node with driver
When we destroy a node that still has another driver, recalculate the
graph so that the driver has a chance to idle.

This can happen when we add an inactive node to the driver and then
destroy the node, like for jack clients.
2021-09-03 11:12:51 +02:00
Wim Taymans 5fa1ae99ae media-session: implement passthrough for S/PDIF
Make sure we always suspend before reconfiguring a device.

Put the node and the device in passthrough mode when requested. Move
back to DSP mode after the node is unlinked.

Parse the exclusive flag of a stream once when the node info changes.

Use a new variable 'passthrough' to remember the current state of
a node and the peer.

Parse non-raw formats as well.

Check if two nodes can passthrough by intersecting the EnumFormat
params. If it is possible, configure the node for passthrough.

Don't try to reconnect nodes in passthrough.

Fail if we can't find a node compatible with passthrough.

See #629
2021-09-02 16:12:03 +02:00
Wim Taymans ef795cc2e3 pulse-server: add quirk for skypeforlinux
Or else it refuses to show the output devices in some cases for some
reason.
2021-09-02 15:22:27 +02:00
Wim Taymans 9052b1be33 media-session: add option to restore bluetooth profile
Add default-profile.restore-bluetooth option to restore the BT
profile.

See #1567
2021-09-02 11:39:17 +02:00
Wim Taymans f277487887 media-session: save and restore IEC958 Codecs 2021-09-02 10:27:59 +02:00
Wim Taymans 80628f38e7 alsa: move codec config to acp-device
Just like the latency, move the codecs to the device Route param.
This way, it is easier for the session manager to save and restore
the codecs as part of the Route settings.
2021-09-02 10:27:59 +02:00
Julian Bouzas 1a93165e84 impl-port: use audiomixer for RAW media subtype when setting up mixer 2021-09-01 17:35:47 -04:00
Jonas Holmberg 28cf342bb8 media-session: Change some warnings to info
If a program using pipewire-alsa calls snd_pcm_close() immediately after
snd_pcm_prepare() without reading or writing any data the client node
may be removed before the session manager can link it, which would
result in the following log warnings:

can't link 35:40 -> 43:48: link-factory: unknown input port 48
error id:25 seq:11467 res:-22 (Invalid argument): link-factory: unknown input port 48
can't link 35:41 -> 43:46: link-factory: unknown input port 46
error id:16 seq:11468 res:-22 (Invalid argument): link-factory: unknown input port 46
2021-09-01 15:15:51 +00:00
Wim Taymans eafef40430 pulse-server: remove pod debug 2021-09-01 13:25:52 +02:00
Wim Taymans ea7a731106 pulse-server: set the SINK_SET_FORMATS flag
When we have an iec958Codecs property on the node, we can use it to
configure the codecs on the sink.
2021-09-01 13:24:50 +02:00
Wim Taymans 49eb31f670 pulse-server: add device-restore extension
This is mostly to read and set the supported formats of a sink.
2021-09-01 13:23:10 +02:00
Wim Taymans a25396c1eb pulse-server: filter out iec958 PCM formats
Convert the iec958 PCM formats differently when enumerating the sink
formats. This way we can still convert the param to a format_info.
2021-09-01 13:23:05 +02:00
Wim Taymans 592163fb0a stream: rename a variable 2021-08-31 16:04:34 +02:00
Wim Taymans e7a43f6d91 filter-chain: add 7.1 virtual sink example 2021-08-31 13:52:52 +02:00
Wim Taymans dce6f30954 filter-chain: rename sink-convolver
Rename to what it actually does.
2021-08-31 13:46:36 +02:00
Wim Taymans 3300f5ddc4 context: activate loopback to drivers
We start with setting the visitied flag on the driver. Still follow the
links to other visited nodes because it might make them active. for
example, adding a link between two midi ports should make the midi
driver running so that data flows between the ports.

See #1559
2021-08-31 11:45:14 +02:00
Konstantin Kharlamov a4f3a23095 tools/pw-dump: add support for --color-always 2021-08-31 08:42:15 +00:00
Konstantin Kharlamov e7db65b133 media-session: remove unused props from struct profile 2021-08-31 08:42:15 +00:00
Wim Taymans d34c4facc0 module-roc: fix properties
Actually set the right properties on the source and sink.

Not quite right because the pulseaudio ROC has a sink-input or a
playback stream in pipewire.

See #1538
2021-08-30 23:27:51 +02:00
Wim Taymans 9f57341699 module-pulse-tunnel: set the bufferattr right
tlength for playack and fragsize for capture.

See #1434
2021-08-30 21:26:33 +02:00
Wim Taymans cff9dbf9dd echo-cancel: improve properties
Make the streams passive so that things can suspend.
Use a differend node.name for the input and output streams so that
autoconnect can actually remember the right target.
Make the media.name and description nicer.

See #1557
2021-08-30 10:50:03 +02:00
Julian Bouzas d4b06431ff pulse-server: calculate buffer size based on the frame size
Audio with big frame sizes (especially audio with multiple channels) needs more
buffer size than the one calculated with the current formula. This patch uses
the frame size to calculate the buffer size, fixing playback issues for clients
configured in passthrough mode.
2021-08-30 08:01:52 +00:00
Julian Bouzas b136bb8ca5 pipewire-pulse: delay create stream reply if the peer is not found
When the client adapter is configured in passthrough mode, the stream param
changed event in pipewire-pulse is emitted before the session manager creates
the link, and not after. Therfore, the peer can never be found when replying
create stream, and the pulseaudio application receives a stream error.

This patch delays the create stream reply until the link is added if the peer
cannot be found, fixing the above race conditon to allow passthrough mode to
work with pulseaudio applications.
2021-08-30 08:01:52 +00:00
Konstantin Kharlamov 60480f422e media-session: simplify save_profile 2021-08-30 01:12:14 +03:00
Konstantin Kharlamov 2c7cdcfa41 media-session: constify various params 2021-08-30 01:12:09 +03:00
Wim Taymans e90c436f3a filter-chain: remove another copy 2021-08-27 21:05:32 +02:00
Wim Taymans 4677cc348c stream: clear the draining/drained state when inactive
When we inactivate the stream, clear the draining/drained state.
Otherwise, the stream stays in the drained state and won't call the
process function anymore when we activate it again.

This used to work before because we called the process function from the
Start command, which would queue a buffer and unset the drained flag.
Calling the process function from Start was however not right when the
process function needed to be called from the RT thread or when the
stream is a driver.

Fixes the issue where speaker-test would only play one channel.
2021-08-27 17:12:03 +02:00
Wim Taymans 994630cb3a filter-chain: optimize convolver some more
Add function to convolve without accumulate and use that when possible
to avoid some memset and memcpy.
2021-08-27 17:11:45 +02:00
Wim Taymans 73854e9ec9 filter-chain: improve convolver
Make the input buffer a little larger and leave the top blockSize
samples zero. That way we can fill up the lower part, leave the upper
part zero padded and feed this to the fft directly. Also only clear
the lower part when we can't fill it completely.

This removes some memcpy and memset operations.
2021-08-26 17:19:48 +02:00
Julian Bouzas 34b1ecc244 pw-cat: calculate number of samples properly with io_rate_match
Fixes wrong buffer sizes when adapter is configured in passthrough mode.
2021-08-25 19:23:23 +00:00
Wim Taymans a701a500af filter-chain: add hilbert function
Can be used to perform a 90 degree phase shift.
2021-08-25 21:20:42 +02:00
Wim Taymans 09a0fdcc0f protocol-simple: avoid freeing client multiple times
Ensure we only queue one cleanup operation and cancel all pending
operations when we destroy the client.

Fixes #1550
2021-08-25 21:19:25 +02:00
jakobrs d1f521af40 Add missing > in link factory usage string 2021-08-25 15:39:06 +00:00
Wim Taymans a9169cf491 pulse-server: Handle formats of virtual devices better
Virtual devices tend to start with partial fields set in the EnumFormat
param (usually rate is missing). This causes virtual devices to be
invisible until they are used in some way.

Fix this by relaxing the parsing of EnumFormat and by falling back to
the server defaults for the unspecified fields.

Fixes #1413
2021-08-25 17:33:22 +02:00
Wim Taymans 3526e33fe1 impl-node: send Pause when a Play reply is pending
When we send a Play request to the client but it deactivates before
sending the reply, make sure we send a Pause request as well so that
Play/Pause is always matched up.

Fixes #1548
2021-08-25 16:29:59 +02:00
Wim Taymans 67965d60be stream: fix debug message 2021-08-25 13:08:49 +02:00
Wim Taymans 11cb77c577 context: fall back to default rate in case of errors
When the allowed rates does not contain the default rate, also
fall back to only the default rate.
See the configured rates in the properties so it can be inspected.
2021-08-25 09:28:23 +02:00
Wim Taymans df92c09ff5 filter-chain: fix loop index 2021-08-24 16:45:11 +02:00
Wim Taymans 1e4e83d305 filter-chain: add more mixer ports
Add option to set NULL data as the port data so that plugins can
skip processing.
Add 8 mixer ports and skip NULL data.
Move silence and discard samples to static area.
Improve the virtual sink examples. use the correct mixing for the HRIR
channels.
2021-08-24 16:26:06 +02:00
Wim Taymans 123fe3d1c5 filter-chain: improve pffft compilation and CPU support
Compile different pffft versions per CPU.
Plug the right version depending on the runtime CPU.

See #1543
2021-08-24 12:07:37 +02:00
Wim Taymans 0f5face73f filter-chain: use pffft for the convolver
It is faster.
2021-08-23 21:00:45 +02:00
Wim Taymans 34e53113e2 pulse-server: handle the case where rate-match returns 0
Still feed the minreq amount of data into the converter.
2021-08-23 17:27:45 +02:00
Wim Taymans 454a9bd55f media-session: detect passthrough and passthrough only nodes 2021-08-23 13:28:02 +02:00
Wim Taymans 44d575ba70 stream: enable adapter for all audio streams
This way, we can support streams with normal and passthrough
formats by switching the adapter mode.
2021-08-23 13:06:06 +02:00
Wim Taymans 10c3bf5ff3 media-session: detect and block passthrough-only streams
If we see that the stream only has passthrough formats, make them
error immediately for now.
2021-08-23 13:03:50 +02:00
Wim Taymans 1a713e963a pulse-server: fix parsing and creation of iec958 formats
Implement creating IEC958 format EnumFormat params.

Fix parsing of negotiated IEC958 formats and convert to our internal
format.
2021-08-23 12:09:53 +02:00
Wim Taymans bceb9a4b6e pipewire-pulse: enumerate iec958 formats for sinks 2021-08-23 11:58:29 +02:00
Wim Taymans 9dfe35b17c alsa: add enumeration of iec958 format
For hdmi and iec958 devices, enumerate the iec958 formats and
codecs. Initially only PCM is supported as a codec but with
a property or an init option, the list of codecs can be dynamically
configured.
2021-08-23 11:31:52 +02:00
Wim Taymans 24f61deefd media-session: also check restore-stream when info updates
We only need an info update to restore the stream so check for that
in addition to a param update.

The info update can be used to restore the stream and the param update
to update the stored value.
2021-08-23 10:58:29 +02:00
Pauli Virtanen 7362a6be04 bluez5: update mSBC kernel version blocklist
Also versions 5.10.y, y >= 51 contain patch that removes ALT 1 support,
and fix has not reached stable yet.
2021-08-23 08:21:44 +00:00
Pauli Virtanen 82fc54f252 media-session: bluez-autoswitch: save user-selected headset profile
When switching back from the recording mode, save currently selected
profile as the default headset profile to use in future.

This allows users to select a specific profile they want to use for
input, and to avoid autoswitching to HFP/HSP if they want to use a
different microphone, without needing to edit configuration files.
2021-08-23 08:21:13 +00:00
Pauli Virtanen e08cdf27d5 bluez5: add FastStream codec
A2DP codec that uses SBC.  Has a duplex channel, which sends an SBC
stream back.
2021-08-23 08:17:46 +00:00
Pauli Virtanen dedc08cdf8 bluez5: enable duplex for aptx-ll
aptX-LL sink devices may send back mSBC encoded data corresponding to
microphone input.  It appears to be enabled when the bidirectional link
is set in the caps, and the device also supports this.

Implement mSBC decoding in the duplex channel.

Tested to be working on Avantree Aria Pro.
2021-08-22 17:41:50 +03:00
Wim Taymans 4ab8ecfe06 pipewire: allow : in SPA_PLUGIN_DIR to scan multiple paths 2021-08-20 10:15:21 +02:00
Wim Taymans abf37f618e modules: ensure node.name and description are set
Most apps need this and some even crash when they are not set.
2021-08-20 09:26:17 +02:00
Stefan Riesenberger bb2f637839 pipewire-pulse: set description for ladspa sources 2021-08-19 17:33:31 +02:00
Pauli Virtanen 90b62ba2b3 bluez5: add aptx-LL codec
Support the low-latency variant of the aptx codec.

The magic mostly seems to be on the device side, since the stream is the
same as standard aptx, but latency is smaller even if stream/packet
sizes are the same.

Sound output latency is noticeably less than with the standard aptx.
Tested on Sennheiser HD 250 / Avantree Aria Pro.

The codec in principle also supports bidirectional duplex streams,
but that is not implemented here.
2021-08-18 19:55:22 +00:00
Wim Taymans f96fa1bf36 pulse-server: find the rate in the format_info
Also look for the highest rate in the format_info to suggest as
the graph sample rate.

See #1523
2021-08-18 16:58:22 +02:00
Wim Taymans f8aa4dcfcc context: only prepared nodes can make a node non-passive
This avoid starting the node before the link has been prepared.
2021-08-18 16:20:24 +02:00
Wim Taymans 2d4ded2384 conf: waitpid needs a cleared status
It might not change the status when the process has changed state.
2021-08-18 09:45:15 +02:00
Wim Taymans 0bad741d45 pw-cat: suggest samplerate as graph rate 2021-08-18 09:44:53 +02:00
Wim Taymans c25e6cee50 pulse-server: add an example of context.exec in the config file
Extra setup with pactl or scripts can be run here.
2021-08-17 20:31:47 +02:00
Wim Taymans bf66a3b236 pulse-server: use NODE_RATE to suggest a graph rate
When the rate is in the allowed rates and the graph is idle, it
will switch to the new rate.
2021-08-17 20:05:19 +02:00
Wim Taymans 49c1c0386f pw-cat: fix raw read
raw read needs bytes, so use the stride to calculate it from frames.
Move ulaw/alaw to packed formats.
2021-08-17 17:56:31 +02:00
Wim Taymans f7c91491cb pw-cat: support ulaw/alaw formats 2021-08-17 17:35:31 +02:00
Wim Taymans 961f478af8 pulse-server: add alaw/ulaw support 2021-08-17 17:35:05 +02:00
Wim Taymans c3db68a219 gst: support ulaw/alaw conversion of caps 2021-08-17 17:34:14 +02:00
Wim Taymans 5a05ee8753 media-session: fix defaults for internal latency 2021-08-17 10:28:28 +02:00
Wim Taymans a2083d12d4 alsa: add params to set default internal latency 2021-08-17 10:15:40 +02:00
Wim Taymans ee6d363481 filter-chain: add the 2 stage convolver
So that the tail is processed with a larger fft size to make it
faster for larger convolutions.
2021-08-16 20:31:43 +02:00
Arun Raghavan ffb7893f20 doc: Fix minor copy-pasto in impl-module 2021-08-15 17:09:02 +02:00
Pauli Virtanen 5071589aea bluez5: enable SBC-XQ codec by default, if allowed by quirks
Enable SBC-XQ by default, and move it at the end of the codecs list, so
that bluez does not connect to it automatically except when it is the
codec used previously.

When the codec is disabled by quirks, it won't appear in the codecs
list, and so can't be selected by user (and so won't be connected
automatically).

However, since SelectConfiguration does not carry information which
device is in question, we cannot prevent BlueZ connecting to the codec
even if it's disabled for a specific device. If the "impossible" occurs
regardless, we won't reject the connection and the profile will be shown
as the generic "A2DP" one.  If the sound is garbled, the user can select
some other profile that works.
2021-08-13 18:45:16 +00:00
Torkel Niklasson eff67c3c03 Add log level argument to ratelimit_test function
If a log message is rate limited, we only need to know about it if we
are actually interested in that log level. We therefore add an argument
to the ratelimit_test function to set the log level of the message
printed if a message is skipped

Change-Id: I5ccd4a78bf7e972fe8b0e7133cd7e08c1e38835f
2021-08-12 18:59:31 +00:00
Wim Taymans f816f702a5 filter-chain: make sndfile optional
Replace the code paths that require sndfile with a fallback when the
dependency was not found.
2021-08-12 09:59:56 +02:00
Wim Taymans ce2b385318 filter-chain: protect against bad values 2021-08-11 21:33:56 +02:00
Wim Taymans 755eab0cd3 filter-chain: add more convolver options
Add gain, delay, offset, length, channels options.
Make default blocksize depend on the ir length.
2021-08-11 21:33:56 +02:00
Wim Taymans dbe9f02471 filter-chain: add support to read from offset
So that the channel of the response file can be set
2021-08-11 21:33:56 +02:00
Wim Taymans be9ac91ce1 filter-chain: read samples correctly 2021-08-11 21:33:56 +02:00
Wim Taymans 44c6ec146e filter-chain: parse config options
Remove LADSPA dependencies, only use it in ladspa_plugin.c
Parse convolver config, like filename
2021-08-11 21:33:48 +02:00
Wim Taymans a2aaa71392 filter-chain: simplify plugin API some more 2021-08-11 21:12:38 +02:00
Wim Taymans 48136b4c2b filter-chain: simplify the plugin API 2021-08-11 21:12:38 +02:00
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