Commit graph

56 commits

Author SHA1 Message Date
Wim Taymans
78219471ff spa: remove some obsolete functions
The spa_audio_info array now always holds enough positions for all
channels and we don't need to wrap around.
2025-10-24 09:35:59 +02:00
Wim Taymans
5e1e3fca1e modules: handle format parsing errors 2025-10-23 18:01:35 +02:00
Wim Taymans
11f1298f53 spa: make a function to make a channel short name
Make a function that can generate and parse a short name for
the positions that are not in the type list, like the AUX channels.
2025-10-22 13:04:53 +02:00
Wim Taymans
818d1435ce treewide: access the position information using helpers
Make sure we don't access out of bounds and that we use the helpers
wherever we can to access the position information.
2025-10-21 13:06:25 +02:00
Wim Taymans
8bbca3b8f3 spa: add spa_audio_parse_position_n
Add a function that accepts the size of the position array when reading
the audio positions. This makes it possible to decouple the position
array size from SPA_AUDIO_MAX_CHANNELS.

Also use SPA_N_ELEMENTS to pass the number of array elements to
functions instead of a fixed constant. This makes it easier to change
the array size later to a different constant without having to patch up
all the places where the size is used.
2025-10-21 09:59:13 +02:00
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
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
564c9b1ba5 Use "8 bit raw midi" for control ports again
There is no need to encode the potential format in the format.dsp of
control ports, this is just for legacy compatibility with JACK apps. The
actual format can be negotiated with the types field.

Fixes midi port visibility with apps compiled against 1.2, such as JACK
apps in flatpaks.
2025-05-23 16:46:13 +02:00
Wim Taymans
4f53136891 netjack2: reverse send/recv roles in driver/manager
The params contain the send/recv streams from the point of view of the
manager (and not the driver as was assumed before). This means we need
to swap send/recv in the driver, not the manager.

This makes things interoperate with JACK/netjack2.

See #4666
2025-05-12 12:57:11 +02:00
Wim Taymans
20246b5c0e netjack2: add driver.mode again
This configures the default number of audio and midi ports per stream
to 0 depending on the mode.

Improve docs a little.

See #4666
2025-05-06 10:44:14 +02:00
Wim Taymans
a9083c7519 netjack2: improve shutdown
Destroy the sources from the io handler immediately when there is an
error so that we don't end up in endless error wakeups.

Schedule the free from the main loop and make sure only one can ever
run.
2025-04-30 11:00:42 +02:00
Wim Taymans
6e8db1cd4a netjack2: handle connection errors in more cases 2025-04-29 18:09:02 +02:00
Wim Taymans
3856d29646 netjack2: implement driver and manager roles correctly
The manager is actually not supposed to decide much about the number of
audio and midi ports. It should just suggest a default when connecting
driver doesn't know.

Add a audio.ports parameters to manager and driver to suggest/ask for
the amount of audio ports. Let the audio.position/audio.channels be a
specification of the channel mask in case it matches the requested
channels, otherwise use AUX channels for the ports.

This means that we must derive the mode (sink/source/audio/midi) from
the ports that are negotiated in the manager and the driver, so delay
this until after negotiation.

Make sure all the possible modes work. For midi only streams, we can't
wait for the session manager to perform a PortConfig so do that
ourselves. Make sure we only use a source trigger when we have a sink.

Fixes #4666
2025-04-29 17:17:14 +02:00
Wim Taymans
78fe234bfe netjack2: copy the node.group to streams
Just in case we want them to be scheduled in the same group.
2025-04-29 09:17:35 +02:00
Wim Taymans
40dbc5f00f netjack2: keep per stream io_position
And handle the trigger failure with a warning and fallback.
2025-04-29 09:16:54 +02:00
Wim Taymans
b6cb76bf8d netjack2: implement ifname in the driver
See #4666
2025-04-28 11:13:33 +02:00
Gleb Popov
aafe815556 Move the ifr_ifindex FreeBSD definition into a header file to reduce code duplication 2024-09-23 08:09:45 +00: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
Wim Taymans
d9e7a10b0d modules: accept and produce UMP only 2024-07-30 09:38:40 +02:00
Wim Taymans
57b495f775 module-netjack2: support local.ifname for manager
Fixes #4141
2024-07-22 13:34:14 +02:00
Wim Taymans
7447dedef4 module-netjack2: implement netjack2.connect
When netjack2.connect is true, make streams and set the autoconnect
property on them. Otherwise, make sink/source as it was before.

Fixes #4125
2024-07-19 11:48:14 +02:00
Wim Taymans
0062d64b3a module-netjack2: stop follower when setup io errors out
Just disable the data socket when it errors out but stop the follower
when the setup socket is in error.

This makes shutdown work properly when the setup socket is stopped,
which is what actually happens eventually.
2024-07-19 11:47:07 +02:00
Wim Taymans
b5a7a1f224 module-netjack2: improve port names
Let the default port logic make the port names. For network nodes this
will be with a send/recv prefix.
2024-07-19 11:42:51 +02:00
Wim Taymans
c73b56db38 fix compilation 2024-07-18 14:24:53 +02:00
Wim Taymans
280bbd88d4 modules: don't unload module on stream error
Unloading the module on stream errors is a bit too much because a
suspend can clear the stream error again (or the error might not be
fatal)

This can happen for example when negotiation fails on some stream ports
(wireplumber tries to link the midi ports to audio ports) and it's
better to not completely fail on that.

Fixes #4121
2024-07-18 14:15:22 +02:00
Wim Taymans
c3d4abd7f1 modules: use acquire/release loop
Expose the acquire_loop/release_loop functions and use them in the
modules.

Make sure the nodes created from the module use the same data loop as
the module. We need to ensure this because otherwise, the nodes might
be scheduled on different data loops and the invoke or timer logic will
fail.
2024-04-22 16:19:02 +02:00
Wim Taymans
c0966f026a modules: prefix network-utils methods with pw_net 2024-02-26 15:17:48 +01:00
dsee
4888b35284 Support IPv6 link-local addresses
Use `getaddrinfo` in `parse_address` instead of `inet_pton`.
Display Ipv6 addresses with scope identifiers correctly in `get_ip`
functions using `if_indextoname`.
2024-02-25 18:20:54 +00:00
Gleb Popov
4ea02f5c80 Fix building module-netjack2 on FreeBSD 2024-02-10 20:52:15 +03:00
Wim Taymans
d0a2e6316b spa: small cleanups
Initialize result variable.
Use strncpy to avoid warnings about using non-NULL terminaded strings.
2024-01-10 15:51:01 +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
4bb3e292c5 netjack2: remove hardcoded buffer size 2023-10-13 13:40:22 +02:00
Wim Taymans
b094057b0b handle NULL latency param
Fixes #3504
2023-09-13 11:13:48 +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
Barnabás Pőcze
12be42ed6b pipewire: module-netjack2-manager: remove unused module_schedule_destroy() 2023-07-03 19:40:31 +02:00
Wim Taymans
da86c2030c module-netjack2: improve OPUS fallback 2023-06-12 18:37:47 +02:00
Wim Taymans
fb63bb3c5c module-netjack2: start follower after START message 2023-06-12 17:56:20 +02:00
Wim Taymans
19f3e422e1 module-netjack2: add int support 2023-06-12 17:01:13 +02:00
Wim Taymans
8dfb22d12b module-netjack2: add opus support 2023-06-12 11:44:50 +02:00
Wim Taymans
4bf526ddf4 module-netjack2: handle NULL socket
The socket might be NULL when it got destroyed due to an error.
2023-06-09 20:49:27 +02:00
Wim Taymans
9dd5bab535 module-netjack2: add MIDI send and receive 2023-06-08 16:38:53 +02:00
Wim Taymans
04e17a8b1c module-netjack2: handle driver reconnect
Let the driver keep announcing.
Keep track of when a message was received in the driver. If we don't
receive anything for a while, reconnect.

Don't connect twide in the manager.
2023-06-05 13:30:16 +02:00
Wim Taymans
a70a89289b module-netjack2: fix driver name 2023-06-05 10:36:30 +02:00
Wim Taymans
f2a0df9ac2 module-netjack2: lock and force rate and quantum 2023-06-05 10:36:08 +02:00
Wim Taymans
407ee3940c module-netjack2: set latency param 2023-06-05 10:21:18 +02:00
Wim Taymans
cc82715325 module-netjack2: refactor
Move common code to a separate file.
2023-06-05 10:20:43 +02:00