Commit graph

648 commits

Author SHA1 Message Date
Wim Taymans
13f52f4297 jack: don't require global-mix in prepare_output
We can directly use the port io, which is always available. This ensures
the mix->io status is set to NEED_DATA even when there is no global
mix.

This reverts part of 56786aedc4

See #3514
2023-10-19 12:20:58 +02:00
Wim Taymans
69d0f586b2 jack: use a separate thread for notify
Some jack clients will take a lock before doing IPC and then will
take the same lock in a notify callback. This prevents the IPC from
progressing and causes a deadlock.

Make a separate thread to dispatch the notify so that we don't block the
IPC in any case.

Fixes #3585
2023-10-17 13:05:19 +02:00
Wim Taymans
40cc2f7068 jack: don't wait for mix_set_io
Some jack clients like to lock the process function and so we can't be
sure we will deadlock while we try to wait for the data-loop.

Instead, don't sync with the data-loop when setting the mix-io, it will
happen later when it is possible. Queue a free operation of the memmap
after the mix_set_io if we need to clean up.

See #3585
2023-10-17 13:01:53 +02:00
Wim Taymans
7d5b809b19 jack: make option to make input writable 2023-10-16 11:40:03 +02:00
Wim Taymans
8f2ee0a29c Revert "jack: use a private writable mapping on input"
This reverts commit 6fefd49a8a.

We can't use PRIVATE because mmap docs say that we then might not see
changes in the data anymore from other processes.

Fixes #3575
2023-10-16 09:36:16 +02:00
Wim Taymans
6fefd49a8a jack: use a private writable mapping on input
See #3571
2023-10-14 12:23:39 +02:00
Wim Taymans
11320cf203 tweak number of buffers
In most cases we can use just 1 buffer.

The alsa-pcm-source needs at least 2 buffers so increment the min
limit.
2023-10-13 14:00:29 +02:00
Wim Taymans
6eb17393bf jack: remove fixed buffer size limit
Use the quantum_limit as the max buffer frames and allocate the ports
with the right samples at the end.
2023-10-13 13:04:28 +02:00
Wim Taymans
bafa890aef jack: schedule all jack clients in the same group
Always group the jack clients together to avoid them using different
drivers (and transport/timing).

See #3562
2023-10-13 09:43:00 +02:00
Wim Taymans
45bab72abc jack: fix midi events in destination buffer
Don't fix up the midi events in the (read only) input buffer but
after we have converted it into the JACK midi buffer.

See #3560
2023-10-11 10:56:19 +02:00
Wim Taymans
fcde479a82 env: PIPEWIRE_QUANTUM now uses FORCE_RATE and FORCE_QUANTUM
Make it force a RATE and QUANTUM on the graph. The non-force options
can already be done with PIPEWIRE_RATE and PIPEWIRE_LATENCY.
2023-10-10 15:10:19 +02:00
Wim Taymans
4568d90565 jack: sync after setting metadata
Do a do_sync after setting the metadata to ensure the messages are
flushed to the server and processed. Fixes an issue where jack_property
would exit before the messages are flushed and so nothing happens.
2023-09-19 12:44:59 +02:00
Wim Taymans
bb10a7cb98 jack: setting the Latency to NULL clears the latency 2023-09-15 11:37:58 +02:00
Jan Alexander Steffens (heftig)
fa7cd96b6e pipewire-jack: Disable LD_LIBRARY_PATH when libjack is in libdir
This avoids prepending /usr/lib to the LD_LIBRARY_PATH, which supersedes
DT_RUNPATH and can cause library confusion.
2023-09-15 08:49:36 +00:00
Jan Alexander Steffens (heftig)
43db03909b ci: ShellCheck preprocessed scripts separately
Change the shellcheck job so that we configure the build and check the
preprocessed versions of the scripts, not the bare ones, which might not
be syntactically valid yet.
2023-09-15 08:49:36 +00:00
Wim Taymans
6abc6e6693 jack: mark client active a little earlier
So that we get all the notifications queued and emitted when we complete
the activation.
2023-09-13 17:48:28 +02:00
Wim Taymans
b094057b0b handle NULL latency param
Fixes #3504
2023-09-13 11:13:48 +02:00
Wim Taymans
56786aedc4 jack: safely update the mixer io areas
The buffer io area is used to enable/disable a port and should be
synchronized with the processing loop. Use invoke to safely update the
mixer io area.

Keep track of the number of mixers on a port and clear the global mixer
buffer io when there are none. Check and use the global mixer io when
processing output to avoid using an inactive output without buffers and
crashing.

Fixes #3506
2023-09-13 10:59:35 +02:00
Wim Taymans
18f29bd840 jack: make sure we emit port registration events
When we activate, emit the port registration events of our own port,
even when they were suppressed (and marked registered) when we created
them. This is what JACK2 does as well.
2023-09-12 15:54:34 +02:00
Wim Taymans
42b23bddc3 jack: always emit buffer frames after activate
This seems to be what JACK2 does as well.
2023-09-12 15:54:34 +02:00
Wim Taymans
c8c2f5902c jack: emit connect unregister before port unregister
When we deactivate a client, first emit the connection unregister
and then the port unregister callbacks.
2023-09-12 15:54:34 +02:00
Wim Taymans
f404168739 jack: mark object registered when emit is suppressed
When we don't manage to emit the notify, still mark the object as
registered. Otherwise we might not emit the unregistered
notify later on.

This usually happens when a client connects and the notifies are
suppressed for all the objects in the graph. When they later disappear
we do want to emit the unregistered notify.
2023-08-30 18:23:07 +02:00
Wim Taymans
001c6e1cc1 jack: support jack_port_tie
We can't really do zero copy because our downstream peer does not have
access to the memfd of our upstream peer. Instead, just memcpy the
data for now.
2023-08-25 14:28:38 +02:00
Wim Taymans
c41c812325 jack: make sure we can always find our own ports
find_port_by_name() is used to find our own ports before they become
visible so make sure we can always find them.

Fixes #3485
2023-08-24 19:28:57 +02:00
Wim Taymans
88e4a69765 jack: emit latency notify when buffer_frames changes
When the buffer frames change, make sure we emit a latency recalculation
even if we don't have a buffer_size callback.

Remove the unused GRAPH notify.

Protect ringbuffer writes to the notify queue with a lock because we
can't know what thread they execute in.

Make a new TOTAL_LATENCY notify type to trigger a complete latency
recalculation.
2023-08-23 17:28:24 +02:00
Wim Taymans
cbf97d4b00 jack: handle node.always-process = false jack nodes
Node that have the node.always-process = false property do not conform
to the jack API because they will be suspended even when they don't
inactivate themselves. Don't hide the ports for those clients when
inactive.

Fixes #3416
2023-08-07 19:58:20 +02:00
Wim Taymans
31f91ce9f4 jack: ports become visible when the registration is queued
As soon as the port registration is queued (but not yet emited) the port
becomes visible.

See #3416
2023-08-07 19:57:01 +02:00
Sandro Bonazzola
a1c109772b Update FSF address 2023-08-07 09:36:59 +00:00
Wim Taymans
0055cc613d jack: always do graph update when link changes
Don't make a special event but do the graph change callbacks when
a link was notified. Bundle all graph updates together when we can.
2023-08-03 11:43:42 +02:00
Wim Taymans
da464853e5 jack: handle port registration events for jack clients
The jack client API expects the ports to unregister when a jack client is
deactivated and to register when it is activated. We use pause/resume
for deactivate/activate and don't really destroy the ports.

Track the state of the node (client) and emit port registration when it
changes state. Also make sure we don't emit a port registration when the
node is deactivated.

Fixes #3260
2023-08-02 17:30:35 +02:00
Nedko Arnaudov
1cb17c05e9 Use 0.3.PWVER for soname versioning, instead of 0.PWVER.0 2023-08-01 11:08:56 +02:00
Wim Taymans
0501ef165a spa: add atomic.h and port macros to it 2023-07-13 12:25:22 +02:00
Wim Taymans
e86a770349 private: we only ever decrement activation with 1 2023-07-13 12:18:11 +02:00
Wim Taymans
af48398577 jack: avoid using private fields 2023-07-13 12:08:36 +02:00
Wim Taymans
d225a192a1 Revert "modules: enforce equal library and compiler versions"
This reverts commit 697daeedf7.

This is too much, we should do better and only disallow incompatible
versions.
2023-07-12 11:16:56 +02:00
Wim Taymans
697daeedf7 modules: enforce equal library and compiler versions
For all the modules that include the private header we require that the
library and compiler versions match.

Otherwise we might end up poking into new or old fields that got moved or
changed in the private struct and crash.

See #3243
2023-07-11 19:50:36 +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
b95ed6dcc1 jack: create mix explicitly
When we create a port, we should make the SPA_ID_INVALID mix_id for the
shared info on the mixer ports.
Only mix_info should create and destroy mix structures.
2023-07-06 12:53:28 +02:00
Barnabás Pőcze
ac5dfbe197 pipewire-jack: include "jack/intclient.h"
So that definitions are checked against declarations.
2023-07-03 19:40:31 +02:00
Wim Taymans
1ce94628ee client-node: rework mix_info
Use the port_set_mix_info to add and remove mix info information to the
client.

Previously it was impossible to clean up mix_info.

With this change we can also simplify the jack peer port detection.
Because the mix info is always sent before the link appears we can
simply look up the info when the link appears.
2023-06-22 11:59:39 +02:00
Wim Taymans
a6ebcc62db jack: set peer_port to NULL in mix 2023-06-22 11:59:19 +02:00
Wim Taymans
85af2bdef2 jack: set peer_id correctly 2023-06-20 20:59:27 +02:00
Wim Taymans
001f0656d4 remote-node: refactor init/create/ensure mix
Make a create_mix function that also takes the peer_id.
2023-06-20 19:24:38 +02:00
Wim Taymans
6fc9914431 jack: don't update srate/bufsize when there is a callback
When we have a callback installed but the bufsize/srate can not be
notified yet because the client is inactive, try again in the next
cycle.

Fixes #3297
2023-06-19 09:31:17 +02:00
Wim Taymans
a14483ed61 jack: also allow signaling ourselves.
If we are a driver we can also ignal ourselves.
2023-05-22 12:15:01 +02:00
Wim Taymans
ce71b37b58 jack: update bufsize and samplerate when skipping notify
When we skip the notify because we are not active or we don't have a
callback, still update the buffer_size and sample_rate fields or else
we will keep on trying forever.

Fixes #3226
2023-05-18 09:59:26 +02:00
Wim Taymans
4206f6bbdb jack: align sample rate callbacks with buffersize callbacks
Don't emit when no value has been queried before.
2023-05-18 09:46:40 +02:00
Wim Taymans
a25c021074 jack: don't fill aliases by default
JACK does not automatically generate aliases, so don't do that either.

The problem is that no new ports can be created if one already exists
with the same name or any of the aliases. This causes problems when a
port is renamed and a new port is created with the old name because the
alias might still be the old name and port creation fails.

Add a jack.fill-aliases for this purpose.

Fixes #3154
2023-05-12 17:58:07 +02:00
Wim Taymans
b3eb4518cb jack: only emit register notify in pairs
Only emit Off when On was sent.
2023-05-12 15:30:44 +02:00
Wim Taymans
8b18cbdce1 jack: restore previous global thread_utils
When a jack client is opened, the thread_utils from the context are
stored globaly. Replace this with a generic thread_utils when we close
the client again to avoid referencing freed memory.
2023-05-12 13:30:32 +02:00