Commit graph

70 commits

Author SHA1 Message Date
Wim Taymans
cd81b5f39a spa: add spa_json_begin_array/object and relaxed versions
Add spa_json_begin_array/object to replace
spa_json_init+spa_json_begin_array/object

This function is better because it does not waste a useless spa_json
structure as an iterator. The relaxed versions also error out when the
container is mismatched because parsing a mismatched container is not
going to give any results anyway.
2024-09-16 09:50:33 +02:00
Barnabás Pőcze
ec521ca870 meson.build: enable -Werror=format 2024-06-27 21:18:06 +00:00
Wim Taymans
1ae4374ccf Fix compilation with -Werror=float-conversion
Better make the conversions explicit so that we don't get any surprises.

Fixes #4065
2024-06-18 12:17:56 +02:00
Wim Taymans
3da66734bd modules: add reconnect support to module-pulse-tunnel
When the pulse connection is broken, reconnect with the given interval.

Add the reconnect_interval_ms property to the pulse modules.
2024-01-05 13:34:19 +01:00
Wim Taymans
6c772a1843 module-pulse-tunnel: don't block the main thread
Do the pulse context and stream connect async so that we don't have to
block the main thread.

Fixes #3221
2023-11-30 10:42:48 +01:00
Pauli Virtanen
fdcb02ed75 modules: add Module Name section to the module reference docs 2023-11-20 08:41:13 +00:00
Pauli Virtanen
eca773fc12 modules: strip "PipeWire Module:" from Doxygen page name
Make them appear nicer in the output.
2023-11-19 16:39:15 +00:00
Wim Taymans
016d15e598 ratelimit: missed -> suppressed
To avoid confusing with missed samples.
2023-09-08 12:18:23 +02:00
Wim Taymans
f25da522a4 pulse-tunnel: fix index after overrun
First advance the index, then fix the avail value or else we don't end
up changing the index at all.
2023-08-31 11:39:54 +02:00
Wim Taymans
3d0b662c5e pulse-tunnel: Make sure we send available data
Round down the size and avail to the frame size to make sure we always
send aligned frames.

When we don't have the required size, set the buffer to 0 but still send
whatever we have in the ringbuffer or else it stays there until some
unknown time when it gets flushed out again with new data.
2023-08-30 18:27:19 +02:00
Wim Taymans
5e2a7dbc4e modules: remove include of private.h
Remove some includes of private.h
Add some methods to get the mempool of client and context so that we can
remove direct access.
Move some things around.
Use methods to get pw_loop variables.

See #3243
2023-07-11 19:31:27 +02:00
Wim Taymans
dc07c2321b spa: add spa_ratelimit 2023-07-11 19:25:35 +02:00
Barnabás Pőcze
8c17a6626d treewide: mark some functions static
These were found by enabling the "missing-declarations" warning.
2023-07-03 19:40:31 +02:00
Wim Taymans
ffa21d696d module-pulse-tunnel: avoid using NULL module
Set the module to NULL when unloading. Check if the module exists before
attempting to unload it.

Flush any pending invokes on the mainloop before destroying the impl.

Fixes #3199
2023-05-04 20:28:10 +02:00
Wim Taymans
bbf0ed063e pulse-tunnel: proxy volume/mute
Intercept the stream volume/mute and set it as the remove volume/mute.

Listen for remote volume/mute changes and set this as the local stream
volume. Make sure the adapter is using 1.0 software volume but reports
the real channelVolume of the remote stream.
2023-04-17 17:53:23 +02:00
Wim Taymans
f6e25c239f module-pulse-tunnel: don't unload module from pulse thread
We are not allowed to call pipewire methods from any other thread than
the main thread so use invoke to schedule a module unload from the
pulseaudio thread.

Fixes some infinite loops when the work-queue list gets corrupted.
2023-03-27 11:10:12 +02:00
Wim Taymans
07e6f44e58 modules: clean up USAGE arguments
use () to mark optional arguments to avoid confusion with arrays.
Add some more optional arguments.
2023-03-22 16:35:55 +01:00
Wim Taymans
b4ef9fa333 pulse-tunnel: improve rate matching
Add the current fill level to the last known latency measurement right
before de do the rate matching. This improves accuracy of the matching.
2023-03-16 11:20:31 +01:00
Wim Taymans
b757638000 module-pulse-tunnel: fix rate correction sign for capture
The capture delay calculation had the wrong sign, making the resampler
go in the wrong direction and causing pitch changes.

Fixes #3093
2023-03-16 09:48:47 +01:00
Wim Taymans
bc6c19ccdf pulse-tunnel: translate pulse error to spa error
Pulseaudio has its own error enumeration, convert them to spa errors so
that we report the right errors.
2023-03-13 12:26:20 +01:00
Barnabás Pőcze
934ab3036e treewide: use SPDX tags to specify copyright information
SPDX tags make the licensing information easy to understand and clear,
and they are machine parseable.

See https://spdx.dev for more information.
2023-02-16 10:54:48 +00:00
Wim Taymans
f472fd736d fix includes
Only include debug we need. We usually only need the debug types.
2023-01-18 13:12:16 +01:00
Wim Taymans
2254c74fb9 use TARGET_OBJECT instead of the deprecated NODE_TARGET
Clarify the docs.
2023-01-10 16:51:47 +01:00
Wim Taymans
860b8fc27f modules: fix rate update
Setting the rate with the PROP_rate would actually result in a rate
adjustment of 1.0f / rate, so do the same here.

See #2891
2022-12-29 12:22:56 +01:00
Wim Taymans
2f397035b8 modules: don't call pw_stream_set_control in process
pw_stream_set_control can only be used from the pipewire main_loop, not
the process callback. Instead, use the rate_match field directly.

Fixes #2633
2022-12-08 11:01:24 +01:00
Wim Taymans
72912c9589 pulse-tunnel: improve latency property docs
To make it clear it needs to a number only (without ms at the end)
2022-11-17 19:04:46 +01:00
Wim Taymans
945529f029 modules: actually copy the network property to the stream
Fixes #2384
2022-11-17 15:56:39 +01:00
Wim Taymans
e5881e9afb module-pulse-tunnel: rate limit some messages 2022-10-20 09:24:54 +02:00
Wim Taymans
88785c42e5 modules: avoid partial writes to pulseaudio
Pulseaudio requires that we call pa_stream_write with a multiple
of frame_size bytes. Because our ringbuffer is a power of two, this
might cause problems at the edge of ringbuffer where a sample is
split between the end and beginning of the ringbuffer.

Avoid this by letting pulse allocate a buffer instead and memcpy
the requires samples into it.

Fixes multichannel output on module-pulse-tunnel.
2022-10-18 13:14:32 +02:00
Wim Taymans
e6356f7415 module: pass a channel map in pa_stream_new
Convert the PipeWire channelmap to pulseaudio and pass it in
pw_stream_new().
2022-10-17 18:58:15 +02:00
Wim Taymans
6f235f344f modules: set tunnel minreq and prebuf more like pulseaudio
See #2755
2022-10-12 12:18:14 +02:00
Wim Taymans
c20790c64b pulse-tunnel: destroy the module on errors
When the pulse context or stream is in error, destroy the module.
2022-08-30 16:09:04 +02:00
Wim Taymans
9248ce3c19 pulse-tunnel: fix rate adjustement argument
The sign of the error was wrong, making the rate controller adjust in
the wrong direction and make things worse.

See #2548
2022-08-30 16:01:14 +02:00
Wim Taymans
de65fd442f modules: use TARGET_OBJECT instead of NODE_TARGET 2022-07-11 13:52:35 +02:00
Wim Taymans
60cbc44526 modules: improve docs 2022-06-23 12:48:45 +02:00
Wim Taymans
c8b8b24a9c modules: fix format parsing
Use the same logic for parsing the format.
2022-06-23 12:39:51 +02:00
Wim Taymans
0f839c7b61 modules: clamp input offset and size
So that we don't cause memory errors with invalid input.
2022-06-04 11:47:48 +02:00
Wim Taymans
87172fde06 modules: align tunnel.mode
Source for a source, sink for a sink. We use capture and playback for
streams that link to a source/sink respectively.
2022-06-03 10:52:45 +02:00
Wim Taymans
de4b021b34 modules: add docs 2022-04-22 16:44:15 +02:00
Wim Taymans
d1207422e0 make NODE_WANT_DRIVER=true the default
So that all nodes attach to some driver to be scheduled.

For the virtual sink/sources this is a normal thing and we can remove
the custom settings.

For normal stream, this now makes it possible to link pw-play directly
to pw-record and have it transport data.

Fixes #1761
2022-04-21 10:14:53 +02:00
Wim Taymans
26db2f1ec9 module-pulse-tunnel: clear ringbuffer on cork 2022-04-19 10:51:45 +02:00
Wim Taymans
4cc0082634 module-pulse-tunnel: move some info log to debug 2022-04-19 09:58:18 +02:00
Wim Taymans
cdbdcd6771 module-pulse-tunnel: improve error recovery
Track the end-to-end latency of the stream and use that to drive
the resampler.
Hard reset the ringbuffer when under/overflow happens so that we
can recover quickly.

See #2230
2022-04-19 09:41:28 +02:00
Wim Taymans
c73c852413 pulse-tunnel: improve debug 2022-04-18 16:48:10 +02:00
Wim Taymans
3c38794886 pulse-tunnel: recover from xruns better 2022-03-30 17:59:25 +02:00
Wim Taymans
da6687e6ec module-pulse-tunnel: use dll to keep latency under control
Assign half the latency to the internal ringbuffer and half on the
network and remote end.
Use a dll to calculate the drift from our target ringbuffer fill
level and use the stream rate property to driver the resampler.

This should reduce uncontrolled latency over the tunnel.

PulseAudio wants us to be a driver will pull requests from the remote
side. We would need to provide a clock based on the remote end and
also try to follow it when we are not a driver. It would be slightly
better because in the normal playback case we would be able to
avoid resampling. We might do this eventually.
2022-03-30 17:23:09 +02:00
Wim Taymans
4ae94a6ca6 modules: use NODE_WANT_DRIVER=true instead of NODE_GROUP
For the modules that require a driver, don't add ourselves to
the pipewire.dummy group but instead just use the NODE_WANT_DRIVER
property to be assigned to a driver.

This makes it possible for the nodes to move to another driver than the
dummy driver (which has very high priority) and it avoids resampling in
cases where the nodes are linked to an audio source or sink.
2022-03-30 14:56:28 +02:00
Barnabás Pőcze
45bd8532eb pipewire: use newly added function for deferred module destroy
Use the newly introduced `pw_impl_module_schedule_destroy()`
for deferred module destroy in all modules except
module-example-{sink,source}.
2022-02-18 12:30:53 +01:00
Barnabás Pőcze
4d4c6f20df pipewire: remove work queue checks
Since now `pw_context_get_work_queue()` cannot
fail, the checks can be removed.
2022-02-18 12:30:53 +01:00
Wim Taymans
8c346ab3a7 pulse-server: list NETWORK flag on devices
Mark network sinks and sources with node.network.
2021-10-14 13:45:58 +02:00