Commit graph

48 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
e35a8554f8 control: improve UMP to Midi conversiom
Improve the spa_ump_to_midi function so that it can consume multiple UMP
messages and produce multiple midi messages.

Some UMP messages (like program changes) need to be translated into up
to 3 midi messages. Do this byt adding a state to the function and by
making it consume the input bytes, just like the spa_ump_from_midi
function.

Adapt code to this new world. This is a little API break..
2025-08-19 18:33:59 +02:00
Sertonix
3914d0cab3 module-jack: fix name of LIBJACK_PATH environment variable
Fixes 0629647cb5 module-jack: load libjack.so.0 with dlopen
2025-08-13 07:15:16 +00:00
Wim Taymans
8495bffee5 modules: use safer pod parsing for control sequence 2025-07-31 11:50:11 +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
33584dae1d ump: handle sysex from UMP to MIDI1 better
SysEx in UMP can span multiple packets. In MIDI1 we can't split them up
into multiple events so we need to collect the complete sysex and then
write out the event.

Fixes SysEx writes to ALSA seq by running the event encoder until a
valid packet is completed.

Also fixes split MIDI1 packets in the JACK API when going through the
tunnel or via netjack.
2025-03-19 17:53:05 +01:00
Wim Taymans
ada2146692 jack-tunnel: improve port names
Prefix midi port names with midi_ and number ports from 1 instead
of 0.
2025-03-19 17:53:05 +01:00
Wim Taymans
a241495eaf jack-tunnel: support passing port names to link
Add jack.connect-audio and jack.connect-midi to specify an array of port
names to link to instead of the default phyisical ports.

Also actually fixes linking the midi ports correctly.
2025-03-19 17:53:05 +01:00
Wim Taymans
ae0dd9195a modules: add ratelimit to xrun warnings in jack-tunnel
Take the current cycle times early and in all cases. We can use this to
get the current frame time for debugging purposes instead of the more
heavy jack_frame_time().

Rate limit the xrun warnings.
2024-11-06 12:29:21 +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
Wim Taymans
d9e7a10b0d modules: accept and produce UMP only 2024-07-30 09:38:40 +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
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
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
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
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
20434e8669 module-jack: init latency correctly 2023-06-22 17:57:49 +02:00
Wim Taymans
7805a454df module-jack: fix jack scheduling
Our sink and source callbacks are called twice, once when the graph
starts and once when it completes, make sure we don't signal the jack
graph twice or we get corrupted output.

Fixes #3255
2023-06-19 16:37:03 +02:00
Wim Taymans
407ee3940c module-netjack2: set latency param 2023-06-05 10:21:18 +02:00
Wim Taymans
4353f9eb75 module-jack: make stream ports physical
Just like the ports we connect to.
2023-05-10 18:00:44 +02:00
Wim Taymans
67df9d2251 module-jack: add midi support.
Move streams in separate struct, refactor and reuse some code.

Add midi ports and convert to/from pw and jack midi.
2023-05-08 17:06:17 +02:00
Wim Taymans
d2cd65b6e2 module-jack: add volume control 2023-05-08 11:34:00 +02:00
Wim Taymans
c324a9fb42 improve module docs 2023-05-07 20:13:46 +02:00
Wim Taymans
0629647cb5 module-jack: load libjack.so.0 with dlopen
This way we can search for the real jack library instead of using our
custom libjack.so. Add an option to override the search path with
LIBJACK_PATH and an option to select the library name to load.
2023-05-05 15:42:14 +02:00
Wim Taymans
0b3a06192e module-jack: add jack.connect option 2023-05-04 11:55:01 +02:00
Wim Taymans
43b6054631 module-jack: add jack.client-name option 2023-05-04 11:44:55 +02:00
Wim Taymans
7ac8e29160 module-jack: handle non-duplex case 2023-05-04 11:41:17 +02:00
Wim Taymans
7a82fc7fc7 module-jack: fix compilation without fastpath 2023-05-04 09:29:51 +02:00
Wim Taymans
107061bb77 module-jack: implement with pw-filter
It is faster and allows us to add midi easily as well.
2023-05-03 18:37:43 +02:00
Wim Taymans
e24d7cc8b7 module-jack: don't crash when NULL source/sink
It is possible that we destroyed the source/sink when we get a latency
update from jack, don't try to update the source/sink in that case or
we will crash.
2023-05-03 13:04:58 +02:00
Wim Taymans
ea1385ffe0 jack-tunnel: use cycle_wait/cycle_signal
Use cycle_wait and cycle_signal so that we can avoid using a semaphore
and resume the jack graph right after we finish the pipewire graph.
2023-05-03 11:51:13 +02:00
Wim Taymans
39f9fa9c05 jack-tunnel: let client cleanup continue in on_shutdown
We should close the client eventually so don't set the client to NULL.
2023-04-30 10:19:51 +02:00
Wim Taymans
56c59630c9 Revert "jack-tunnel: run graph from JACK thread"
This reverts commit d89df144f0.

This is not better than using a semaphore and the regular data thread.
2023-04-28 17:17:04 +02:00
Wim Taymans
d89df144f0 jack-tunnel: run graph from JACK thread
Stop our own data-loop and enter/iterate/leave it from the jack thread.
This runs all our nodes in the JACK thread and removes 2 context
switches (jack to and from pw thread).

We can possibly do this nicer by only pushing our own streams onto a
new custom data-loop but that's for later.
2023-04-28 17:06:29 +02:00
Wim Taymans
9e7921b37d module-jack: improve xrun reporting 2023-04-27 18:10:41 +02:00
Wim Taymans
381aa90b54 module-jack-tunnel: improve some docs 2023-04-27 17:22:05 +02:00
Wim Taymans
ab0cee29dd doc: add jack-tunnel to docs 2023-04-27 17:03:10 +02:00
Wim Taymans
73f5f7ae65 jack-tunnel: add a new 0-latency JACK sink/source module
Add a new JACK sink/source pair that translates to a single JACK
client.

The JACK playback port appears as PipeWire source and is processed
directly, synchronously, through the complete pipewire graph into
the PipeWire sink that is then made available on the JACK capture
ports.

Because all this happens in the same JACK cycle with no delay, the
latency is 0. A jack_iodelay on the JACK server has exactly the same
latency as the jack_iodelay on the PipeWire side.

The PipeWire sink and source are forced into the same rate and
buffer_size as the JACK server and can't dynamically change.

This only supports Audio for now.
2023-04-27 16:27:54 +02:00