Clang 15 at least with my build configuration emits warnings about
function prototypes that lack argument types. Most notably this
happens with functions that take no arguments which in compiler view
equates to the void type i.e. void f(void) instead of void f(). As I
understand, this will become an error in some future Clang release,
so might as well fix it now.
Since these were discovered not by a linter but by the actual compiler
for my particular build configuration, some f() may have escaped for
now. But at least it's enough to build PipeWire with most optional
features enabled even when -Werror=strict-prototypes is enabled.
For anyone else wanting to have a go at this, these can be upgraded
from warnings to errors by adding -Werror=strict-prototypes to the
custom CFLAGS which probably works with GCC, too, but has only been
done with Clang 15.0.2.
Finally my editor automatically stripped trailing spaces upon saving
the modified files. I assume it's probably not worth keeping those
invisible bytes around but this may have slightly dubious implications
as it did also turn indented empty lines of JACK license header into
regular empty lines.
Signed-off-by: Niklāvs Koļesņikovs <89q1r14hd@relay.firefox.com>
Make sure all jack nodes from the same pid are in the same group.
It is normally not a problem for different JACK clients to live in
different groups and be scheduled by different drivers with different
quantum and rate.
Some applications (like Carla), however, make multiple clients and
expect all of them to use the same quantum and rate. Enforce this by
adding all jack clients to the application jack group.
When the `client` argument is NULL, return a zero initialized
`pthread_t` object from `jack_client_thread_id()`. Returning
`-EINVAL` can be problematic because even though `pthread_t` is
a typedef for `unsigned long` in glibc, it is still a pointer,
not a numeric identifier. And in musl, it is a typedef to a
pointer, which results in a warning:
In file included from ../spa/include/spa/support/cpu.h:34,
from ../pipewire-jack/src/pipewire-jack.c:40:
../pipewire-jack/src/pipewire-jack.c: In function 'jack_client_thread_id':
../spa/include/spa/utils/defs.h:274:11: warning: returning 'int' from a function with return type 'jack_native_thread_t' {aka 'struct __pthread *'} makes pointer from integer without a cast [-Wint-conversion]
274 | return (val); \
| ^
../pipewire-jack/src/pipewire-jack.c:3775:2: note: in expansion of macro 'spa_return_val_if_fail'
3775 | spa_return_val_if_fail(c != NULL, -EINVAL);
For a JACK client, the context and node is the same. It makes sense to
also run the rules on the context properties so that application
name etc. can be matched as well.
Fixes#2580
Pass MIDI events as they are.
JACK requires NoteOn 0-velocity midi events to be patched to NoteOff
events for compatibility with LV2 plugins. Let's do this patchup in
the JACK layer then and add an option to disable it.
It's best to pass the midi messages unmodified and then patch them up
wherever they need patching up.
The client needs to be cleaned up properly, otherwise references
to its storage may remain, which can later result in use-after-frees.
For example, the via the various embedded `spa_hook`s in it.
See #2394
Check pointers before calling the destructors (where needed), so that
a not fully constructed `client` object may be passed to `jack_client_close()`.
Furthermore, remove the metadata proxy and object listeners as well.
Move the initialization of some of `client`'s members right after
allocation, so that it will be simpler to tear down the client object
even if `jack_client_open()` fails later.
Furthermore, initialize `client::driver_id` to `SPA_ID_INVALID`.
Fixes#1867, as this is the only u64 atomic access in the tree
All other accesses to pw_node_activation::sync_timeout are unprotected,
so they must assume lock ownership
When some blocking method is performed on the process thread, like
jack_connect() mark the data thread as blocked while we wait for the
thread loop to process the result.
If we then try to do a blocking _invoke from the thread loop on the
data thread, make sure we don't wait for it to complete or else we
deadlock.
Make all streams and filters handle PIPEWIRE_PROPS.
The order for applying stream/filter properties is:
1) application provided properties.
2) generic config.
3) match rules.
4) environment variables (PIPEWIRE_PROPS, ...) from generic to
more specific.
5) defaults.
Make helper method to parse thread properties and add 2 new properties
to control name and stack-size of the thread.
Use properties when creating threads with the default utils.
Use the default thread utils instead of pthread_create so that the
properties are used.
The alias is not a good property to sort on, it contains the object
path and could sort playback_11 before playback_2.
Just group ports of the same node together, then sort by port_id and if
that fails, use the serial number.
See #2260
Setting a global thread-utils is not a good idea, especially
when multiple contexts will register their own interface.
Instead, set the thread-utils as a context object and use this to
configure the data loop in the context.
In JACK we need a per context implementation of the interface so that
we can find the context specific thread-utils.
See #2252
Make a custom thread_utils that can use the configured global
thread creator and set this in the data-loop.
This ensure that the data loop uses the creator thread when activated.
See #1495
We are really interested in the error code of the statements we queued
before the sync so clear any previous error first. Otherwise we might
pick up a previous random error, which never gets cleared.
See #1714
If we do_sync from the data thread, release the rt_lock so that any
callbacks that may happen while waiting can grab the rt_lock.
We could also temporarily disable the rt_lock grabbing before the
callbacks.
In any case the callbacks will need to be called while we execute
the blocking function in the process callback.
Remove limit on max results from _get_ports() and _get_all_connections()
by using a dynamic array.
Keep the limit on the max number of midi inputs we can mix.
As soon as a JACK app is started, the automatic quantum change is
disabled. This means no pulse/alsa app can change the quantum.
The only way to change the quantum is with node.force-quantum or
with the settings metadata.
This means only a JACK buffersize change (usually controlled from the
JACK app, such as in ardour) or a metadata change (from the command
line) can modify things. Both of those are usually caused by a user
action.
For JACK apps where the quantum is allowed to change automatically,
explicit rules need to be placed in the config.
Add a node.force-quantum and node.force-rate property. When no global
quantum or rate is enforce with settings, the last updated node property
is used as the quantum.
Make jack use the force-quantum property when set_buffersize is used to
make sure that the quantum is not just a suggestion but a hard forced
one. This makes it possible for ardour or other jack apps to raise the
quantum above the max-quantum but also ensure that it will not change
by any other application (unless other jack apps).
Fixes#2079
We must use the serial for generating the uuid.
We use the serial for the port_id and jack_port_uuid_generate() can
be used to turn that into a uuid. So all mappings to and from
uuid need to be with serials.
That tries to both set the buffersize and the samplerate of the graph.
Document them in README.md
Also add the same env variables to pw-stream and pw-filter.
The port struct's `id` member has been renamed to `port_id`,
but the `pw_log_trace_fp()` invocation sites weren't changed.
Fixes: 029539831d ("jack: rework port allocation")
Port ids should be allocated using a map.
Only keep a port_id for the ports we allocate ourselves.
Keep just one port free list, there is no reason to keep per direction
free lists.
Get the port from the object directly.
See #1714
Now that object ids are not reused we can simplify some things. We
don't need to keep a map around with our own unique ids.
Keep all objects in one per client list, mark the removed ones as
removed, allow lookups of the removed objects, recycle half of the
oldest removed objects when there are too many of them.
Remember what we last returned from jack_get_buffer_size and only
emit a buffersize change event when somwthing new is configured.
Fixes startup of jconvolver.
Fixes#1989
pipewire-jack/src/meson.build:
Add the custom `jack_implementation=pipewire` pkgconfig variable to the
generated jack.pc file to be able to distinguish jack implementations.
As jack implementations exist with jack1, jack2 and pipewire-jack, it is
not (easily) possible to distinguish them by looking at the version
alone (particularly the case with jack2 vs. pipewire-jack, as they share
the same headers).
Related to #1666
Make the alignment parameter optional when negotiating buffers.
Default to a 16 bytes alignment and adjust for the max cpu
alignment.
Remove the useless align buffer parameter in plugins, we always
set it to 16 anyway.
After we get a reposition request, bring the state to the SYNC state
again so that clients can align with the new position.
Fixes a problem with reposition when using the jack transport.
Fixes#1907
As per JACK API description the call to jack_deactivate should
disconnect all ports because an inactive client can't have connections.
This disconnect is missing in the current API and results in left-over
links after the call and malfunction to clients (e.g. Music Player
Daemon).
To fix it this commit goes through the list of links to owned ports and
disconnect them.
Signed-off-by: Hendrik Borghorst <hendrikborghorst@gmail.com>
When a client produces output on a port and there is a link between the
output port and an input port of the client, make sure that the new
data appears on the input port.
We do this by keeping track of what links are between our ports and when
we get the peer id of a port input, we can related this to our port
again. Some mixer inputs will then fetch content from our own ports and
so we can prepare the output for them. This can be converting midi to
control messages or moving the output buffer id to the io area so that
the input mixer can pick up the new buffer.
Fixes#1839
Always pause processing until the main loop has processed the buffer
change callback. This makes it less likely for clients in the same
process to use a new buffersize before the other client has received
the callback.
In carla, one client is receiving the buffer size callback and the other
clients are expexted to be paused until the callback for the client is
completed.
Move some warnings when a wakeup was missed to info messages. The
warning can repeat a lot and is otherwise quite useless and already
reported elsewhere.
Don't do the default latency calculation, it might interfere with
the client latency values. Instead just use the client values and
fold multiples of quantum in the quantum latency field.
0 is a valid min latency so we can't use it as an unset value. Use
some large value instead and when nothing was configured, assume it
is 0.
Fixes#1839
Keep per type free_lists so that we can't reuse an old port object for
a link/node. This makes it more likely that ports are still available
after being freed.
Keep all allocated objects indexed in a global cache map. Use the global
cache index as the jack_port_id_t in connection and port registration
callbacks. Since the port_id is unique per allocated object and since
the objects types are never changed, we can always find a port with the
given port_id in the cache.
This vastly improves tools like catia that insist on querying objects
after they have been removed/destroyed.
Sort ports per node and then per node-specific port_id. This will
keep related ports together and will sort them based on when they
were created.
Fixes#1780
Add a jack.show-monitor option (default true) that makes it possible
to hide the monitor ports.
Monitor ports are not enabled by default on JACK and maybe they also
should not for PipeWire. Or maybe we need some tweaks for some apps.
See #1760
Dequeue a new buffer only once and reuse this queued buffer when
jack_port_get_buffer() is called multiple times in process().
Recycle an old buffer in the next cycle.
After calling process, mark all input buffers as consumed, process the
empty buffers and move the output buffers to the mix ports.
Fixes#1748