Commit graph

78 commits

Author SHA1 Message Date
Wim Taymans
13b8c23767 Don't use SPA_AUDIO_MAX_CHANNELS directly
Make a MAX_CHANNELS define and use that one in code. This makes it
easier to change the constant later.
2025-10-21 09:43:06 +02:00
Wim Taymans
a75cea96fb modules: port modules to timer-queue
Instead of using timerfd, use the context timer-queue to schedule
timeouts. This saves fds and removes some redundant code.

Make the rtp-source timeout and standby code a bit better by using
atomic operations.
2025-10-15 16:57:24 +02:00
Sam James
2cec77e7df *: unify config.h handling
config.h needs to be consistently included before any standard headers
if we ever want to set feature test macros (like _GNU_SOURCE or whatever)
inside. It can lead to hard-to-debug issues without that.

It can also be problematic just for our own HAVE_* that it may define
if it's not consistently made available before our own headers. Just
always include it first, before everything.

We already did this in many files, just not consistently.
2025-05-30 10:24:13 +00:00
Wim Taymans
a9f12537d1 pulse: clamp channel numbers to right values
When converting between pipewire and pulse channelmaps, make sure we
clamp the channel numbers to the the right limit.
2025-04-04 15:46:03 +02:00
Wim Taymans
804df3389a modules: use pw_stream_set_rate() when we can 2024-11-22 09:49:27 +01:00
Wim Taymans
e3a7035e8f spa: make helper to init spa_audio_info_raw from dict
Make a function that can initialize raw audio info from a dict and fill
in the defaults. We can use this in many of the modules when the audio
format is parsed.
2024-09-18 15:48:27 +02:00
Wim Taymans
e2991f6398 json: add helper function to parse channel positions
Use the helper instead of duplicating the same code.

Also add some helpers to parse a json array of uint32_t

Move some functions to convert between type name and id.
2024-09-18 09:54:34 +02:00
Pauli Virtanen
ec5684302c doc: in user-facing config examples, indicate which file it goes into
Add suggestions for config fragments in config file examples, as
applicable.
2024-09-16 15:51:59 +00:00
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