Commit graph

375 commits

Author SHA1 Message Date
Wim Taymans 3f2f1971c9 jack: debug driver id and clock name 2021-12-10 12:19:14 +01:00
Wim Taymans 19b53e8dbe jack: fix loopback links to client
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
2021-12-07 15:31:32 +01:00
Wim Taymans 35cec1cf23 jack: recompute latencies after graph changes 2021-12-07 15:31:32 +01:00
Wim Taymans b71f47448c jack: always invoke buffer callback
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.
2021-12-07 15:31:32 +01:00
Wim Taymans fe417bd123 improve latency debug 2021-12-07 15:31:32 +01:00
Wim Taymans dfb82f6f46 jack: refactor recompute_latencies 2021-12-07 11:21:24 +01:00
Wim Taymans fbef731793 make some warnings into log
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.
2021-12-07 10:19:10 +01:00
Wim Taymans c20f22466e jack: improve latency calculation
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.
2021-12-03 17:59:56 +01:00
Wim Taymans 28370fc3cf jack: also call latency callback when buffersize changes 2021-12-03 17:58:25 +01:00
Wim Taymans 97cad7284a latency: fix latency combine calculations
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
2021-12-02 14:49:48 +01:00
Wim Taymans 3df6e77996 jack: handle regcomp errors 2021-11-29 12:46:50 +01:00
Wim Taymans 5cff20eba4 jack: handle chunk offset and size
Use offset and size in captured buffers and make sure we don't use more
than the allocated buffer size.
2021-11-25 15:17:42 +01:00
Wim Taymans dd62b12a1f jack: implement stub internal client API
Fixes #1842
2021-11-22 12:52:15 +01:00
Wim Taymans aeb435087b jack: ensure we don't have negative latencies 2021-11-22 12:12:29 +01:00
Wim Taymans 52b9ca8f2e jack: recompute latency on buffer size change
The latencies might be expressed in quantum, which changes when the
buffer size changes.
2021-11-22 12:11:49 +01:00
Wim Taymans 2e87127700 jack: keep object cache
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.
2021-11-18 12:14:38 +01:00
Wim Taymans fc12e5bed0 jack: improve port sort order
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
2021-11-08 09:23:20 +01:00
Wim Taymans 9facfca45b jack: add option to disable monitor ports
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
2021-10-29 09:27:46 +02:00
Wim Taymans 31f387868a jack: reorganize jack_port_get_buffer()
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
2021-10-26 12:28:31 +02:00
Wim Taymans 6f75b1433c jack: add some more debug 2021-10-26 12:10:15 +02:00
Philippe Normand 1ac57e6e15 pipewire-jack: Fix compound-token-split-by-macro warning 2021-10-25 07:26:15 +00:00
Peter Hutterer fb884b9441 jack: switch to new property helpers 2021-10-13 07:12:00 +00:00
Wim Taymans caf0b2df19 jack: protect against removed ports
Check if the port object is really a port and that it still has
a client associated with it before unreffing the client.

Fixes #1694
2021-10-09 12:49:21 +02:00
Wim Taymans caced1f226 jack: finish statement with; and not , 2021-10-06 20:19:50 +02:00
Wim Taymans f275e3baaa jack: add jack log topic 2021-10-03 08:52:27 +02:00
Wim Taymans 7cf0afe299 jack: fix port check
We need to actually use the port object to check if it's ours.
2021-10-01 09:53:35 +02:00
Wim Taymans 512e4e4b83 jack: wait with emiting connect_callback
For our own ports, wait with emiting the connect_callback until we have
negotiated buffers on them (and have the peer_id). Some applications
use the connect_callback to decide when to start processing so we need
those buffers before we can do that.

Fixes startup issues with jack_midi_latency_test.
2021-10-01 09:33:19 +02:00
Wim Taymans a559b96d61 jack: improve _is_mine() check
Also check the client, in case someone uses a port from another
client.
2021-10-01 09:33:19 +02:00
Wim Taymans 59203c11b8 jack: only update buffer_size/srate when active
As long as we are inactive, don't update our internal buffer_size or
sample rate. This way, when we become active, we will emit the right
callback with the right value instead of doing nothing.

Fixes crashes in Carla.
2021-09-21 18:32:30 +02:00
Wim Taymans 537fc63cc6 jack: set the final midi size as the buffer size.
The buffer has initially a maxsize. After writing we midi events, we can
update it with the real size.
2021-09-20 12:24:09 +02:00
Wim Taymans 2e17cc7901 jack: always check srate/bufsize from data thread
To ensure processing is always happening with the values emited
in the callback.
2021-09-16 11:51:01 +02:00
Wim Taymans cb1c259bc5 jack: check buffersize when we get the io area
We can immeditately update the buffersize when we get the io area.
2021-09-16 11:43:32 +02:00
Wim Taymans 142272e5cc jack: shortcut callbacks when NULL
When the callbacks are NULL, just update the bufsize/srate and be
done. There is no need to wait for a context switch in that case.
2021-09-16 11:29:13 +02:00
Wim Taymans 7543ad0766 impl-node: add node.transport.sync property
When the node support transport sync. That is, when it will clear the
pending_sync flag from its activation area when it completed a new
seek.

Before this patch, the pending sync was always automatically cleared,
which broke some applications that are time masters such as bitwig.

Fixes #1589
2021-09-14 11:06:19 +02:00
Wim Taymans 47a46e198f improve debug 2021-09-14 11:06:19 +02:00
Wim Taymans 939c6e7aa4 jack: always move the timebase owner to the driver
Whenever a timebase owner is moved to a new driver, try to install it as
a timebase owner on the driver.

Before this patch, the timebase owner would only be installed on the
first driver is was assigned to, which was most likely a dummy driver.

See #1589
2021-09-13 17:35:57 +02:00
Wim Taymans 6dde4ea1aa jack: pause processing until callback is emited
Change the buffer_size and sample_rate when we are sure the proces
callback is not running.

Delay process callback until we have called the buffer_size or
samplerate callback. Otherwise the jack application might be called with
the new buffer_size/sample_rate before the callback has been called.
2021-09-11 13:07:10 +02:00
Wim Taymans e4b030fafa jack: add option to disable process lock
Some applications might expect the process function to run concurrently
with the callbacks. PipeWire tries to avoid this by using a lock for the
duration of the process callback. Make an option to disable this.

See #1576
2021-09-08 13:02:04 +02:00
Wim Taymans 8f88792a9a jack: don't emit bufsize_callback from activate()
We just check the initial size of the buffer and remember that, we
should not emit (or schedule) a bufsize change callback.

Emiting the callback should really only be done after the buffer size
changes after activate completed.

Fixes some jconvolver startup problems.
2021-09-08 11:24:57 +02:00
Wim Taymans a54fa5f26d jack: improve do_sync
Keep track of the last scheduled sync operation and wake up listeners
when it completes.

The waiters also compare against the last issued sync so that when multiple
syncs are pending from multiple threads, they will all wakeup instead of
just one.

Fixes some lockups with ardour6.
2021-09-07 17:16:01 +02:00
Wim Taymans 2d88ad179a jack: update format flags when format is set
So that the introspection of the port will show a format when it is set.
2021-09-07 12:20:36 +02:00
Wim Taymans 699bfbc095 jack: improve lookup of removed objects
Keep the original type of the object around in the free list so that we
can still look it up.

Make most methods only find the still active object by checking if the
client matches.

Make some methods (jack_port_by_id() for example) also find the removed
objects for as long as they are in the cache and not overwritten.

This make carla and catia work better because they expect to access the
old object after it has been destroyed.

See #1531
2021-09-03 15:46:21 +02:00
Wim Taymans 2ce1dc113e jack: also find uuid for monitor nodes 2021-09-03 15:45:50 +02:00
Wim Taymans 762f45c5a0 jack: move the free object list to globals
Move the free object list as a global so that we can even access old
objects after client_closed.
Move the objects from a client to the global free list when we close
the client.

Ardour wants to access objects even after calling client_close() so
we need to keep them around a little longer.

See #1546
2021-08-25 11:56:19 +02:00
Wim Taymans 999083105c jack: protect against bad ports and buffers 2021-08-25 11:54:41 +02:00
Niklāvs Koļesņikovs 03a4c0100a
pipewire-jack/src/meson.build: turn jack-devel warning into error
Almost no one will see that warning just like the rest of Meson
configuration warnings. So, if it's gonna yield a build with
dysfunctional JACK SDK, then it's best to make it explicitly fail
before people file bugs about missing jack.pc file.
2021-08-09 13:37:08 +03:00
Nils Tonnätt 8028f9dd6e meson: decrease minimum required meson version to 0.54.0
To generate a correct jack pkg-config file unescape_variable
is required which was introduced with Meson 0.59.0.
When using an older version a warning is printed that no
jack.pc file is generated.
2021-08-08 19:18:40 +00:00
Nils Tonnätt a5e3d3f7a7 [Meson] Change jack-devel option to be boolean 2021-08-06 07:56:16 +00:00
Nils Tonnätt 8dc8fb55f2 [Meson] Unescape pkgconf variable 2021-08-06 07:56:16 +00:00
Wim Taymans 99359c3998 jack: use port_set_mix_info
Use the port_set_mix_info event to get the id of the peer port for the
mixer input.

When asked for the buffer of one of those peer ports, we can get it from
the mixer input buffers.

Fixes #1471
2021-08-03 17:39:14 +02:00