Commit graph

56 commits

Author SHA1 Message Date
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
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
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
743d86500c netjack2: fix trace_fp compilation 2025-04-29 18:36:54 +02:00
Wim Taymans
c7b318523d netjack2: set timeout to sane value again 2025-04-29 17:35:40 +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
3d6e77e96d netjack2: warn when the trigger fails 2025-04-29 09:16:01 +02:00
Wim Taymans
07f033c8da netjack2: keep position io per stream
Keep a position info for the stream it was set and then use the position
info for the stream that is driving the graph. Otherwise we might use a
destroyed position info.
2025-04-28 12:23:15 +02:00
Wim Taymans
b6cb76bf8d netjack2: implement ifname in the driver
See #4666
2025-04-28 11:13:33 +02:00
Wim Taymans
93ee66dcab netjack2: Improve docs
Remove unused option.
Clarify that channels and midi port are chosen by the server.

See #4666
2025-04-28 11:12:48 +02: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
0ecac098c7 modules-netjack2-driver: add source.ip and source.port
Instead of binding the socket to 0.0.0.0 with port 0, make some config
options source.ip and source.port to configure this. This makes it
possible to bind to other interfaces or to use a fixed port for the
data messages.

Fixes #4144
2024-08-29 12:44:53 +02:00
Wim Taymans
d9e7a10b0d modules: accept and produce UMP only 2024-07-30 09:38:40 +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
f2f60ee0ec jack-tunnel: convert JACK time to MONOTONIC
JACK current_msec can be in MONOTONIC_RAW or MONOTONIC, depending on how
JACK was compiled (but it's likely MONOTONIC_RAW). PipeWire requires the
nsec field to be in MONOTONIC so take some time snapshots from both
clocks and apply a translation.

Also make sure we only get the nsec time from streams that exist.

See #3886
2024-03-04 15:34:42 +01:00
Wim Taymans
f4e391dd41 stream: add pw_stream_get_nsec() to get current time
Make a method to get the current time to compare agains the pw_time-now
field. This is currently CLOCK_MONOTONIC but make this into a method
so that we can more easily change it later.
2024-03-04 12:59:26 +01: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
Wim Taymans
a59a551202 module-netjack2: improve channel positions
If the manager gave us a different channel count than we had by
default or configured, assume everything is AUX channels.

Also handle the case where the manager is sending more than our
MAX_CHANNELS channels.
2024-01-25 17:59:39 +01: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
Wim Taymans
de954655bc modules: fix doc 2023-11-22 17:48:05 +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
34809d3081 pipewire: module-netjack2-driver: 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
0cfd94eb52 module-netjack2: support int and opus in driver 2023-06-12 17:40:16 +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
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
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
Wim Taymans
7bd74a67f4 module-netjack2: use frames from graph and sync
The params are the initial period_size, use the ones used to
encode the packets.
2023-06-02 15:43:34 +02:00