Commit graph

630 commits

Author SHA1 Message Date
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
Wim Taymans
41ec84185f jack: make a real notify queue
Use a ringbuffer to store notify events. Emit them when no method is
running.

See #3183
2023-05-11 18:28:03 +02:00
Wim Taymans
36fdceef71 jack: don't emit portregistration when inactive
Remove the port complete when the client is inactive. Otherwise we might
get a portregistration Off the next time the client is activated.
2023-05-10 17:22:43 +02:00
Wim Taymans
742039ff3f jack: destroy port only after emitting the portregistration
In jack_port_unregister(), don't free the port completely but mark it
as removing. This will then do the portregistration callback before
freeing the port.

Add some more debug.
2023-05-10 16:49:41 +02:00
Wim Taymans
981428a9fc jack: only emit graph order changes for new links 2023-05-10 16:48:57 +02:00
Wim Taymans
844ab48db8 jack: use refcount for freezing callbacks
In case the callbacks are called recursively, use a refcount for
blocking the callback emission.

See #3183
2023-05-10 16:46:42 +02:00
Wim Taymans
ccece8316b jack: Don't call callbacks from blocking function
It is possible that the callback notify event is dispatched in do_wait()
while we are blocking for a method reply. In that case, don't perform
the callbacks, they will be rescheduled before the function exits.

Try to only dispatch the notify event when there are callbacks pending.

Fixes #3183
2023-05-10 12:10:03 +02:00
Wim Taymans
045cb95a27 jack: only emit callbacks when active
Most callbacks can only be emited when the client is active.

Fixes #3183
2023-05-09 15:34:51 +02:00
Wim Taymans
5485db09dc jack: Assign unique name to client_name
First try to make a unique node name and then assign this as the
client_name. This ensures we can detect a client name change because of
a name conflict and we properly handle the JackNameNotUnique and
JackUseExactName client open options.

Also emit a new client event when the client name existed but was from
another client and we made a unique name.

Fixes #2833
2023-05-09 11:34:12 +02:00
Wim Taymans
39bba88544 jack: emit a warning when disabled 2023-05-05 15:41:18 +02:00
Wim Taymans
be59d2b5d0 jack: don't emit callbacks from do_wait()
Some functions need to wait for the reply of the server before they can
complete but the JACK API does not allow us to emit notifications while
blocking a function.

Delay emiting notifications when we are in selected methods and send a
notify to an eventfd to call the queued notifications.

Fixes #3183
2023-05-02 14:41:46 +02:00
Wim Taymans
7c5b61295d JACK: update to newer headers
Fixes #3181
2023-04-28 17:32:04 +02:00
Wim Taymans
472a948974 loop: keep loop and system around
So that we don't have to go through the context all the time.
2023-04-28 11:12:02 +02:00
Wim Taymans
0ac465854b jack: improve error reporting 2023-04-27 09:52:35 +02:00
Wim Taymans
78e54b1b2a jack: make spa_return macros log a warning
.. instead of using fprintf to stderr.
2023-04-24 13:23:40 +02:00
Wim Taymans
5a65d67f3a jack: we don't need a completed link in jack_port_connected
Return true from jack_port_connected() right after jack_connect(), there
is no reason to wait for the completed state of the link.

See #2638
2023-04-24 12:59:32 +02:00
Wim Taymans
b87f7251d8 jack: activate/deactivate should trigger port register
Port added before activate should trigger a port_register callback when
the client is activated.

When calling jack_deactivate, the port_register callback should be
called.

See #2638
2023-04-24 12:55:56 +02:00
Wim Taymans
0f0d56e783 jack: avoid registering same port names twice
Don't register port names that are too long or that already exist.

See #2638
2023-04-24 12:53:56 +02:00
Wim Taymans
84a6f38ea6 jack: on do shutdown on EPIPE
There are core errors that should not trigger a shutdown, like invalid
or destroyed proxy replies. Only do shutdown when we get EPIPE, which is
when the server is stopped.

See #3070
2023-04-21 16:28:01 +02:00