Commit graph

359 commits

Author SHA1 Message Date
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
Peter Hutterer 51a177eb6d tree-wide: replace strstr(a, b) == a with spa_strstartswith()
spa_strstartswith() is more immediately understandable.

Coccinelle spatch file:
	@@
	expression E1, E2;
	@@
	- strstr(E1, E2) != E1
	+ !spa_strstartswith(E1, E2)

	@@
	expression E1, E2;
	@@
	- strstr(E1, E2) == E1
	+ spa_strstartswith(E1, E2)

Applied to the tree except for alsa/acp/compat.h because it looks like
that header is still mostly as-is from PA.
2021-08-02 08:24:21 +00:00
Wim Taymans 4e087caa2b jack: add per client match rules
This makes it possible to configure per client settings such as
latency and later also to lock the quantum for certain clients.

See #1456
2021-07-27 17:57:30 +02:00
Wim Taymans d2826a5dab jack: emit client unregister event
Because we only remove the client from the list after doing the lookup,
we will always find the removed node and the unregister event is
never called.

Fix this by marking the object as removing so that the lookup function
can skip the nodes being removed.
2021-07-27 12:07:33 +02:00
Wim Taymans 40f1d2b881 jack: only call callbacks when active
JACK applications expect the callbacks only when activated.

Fixes #1461
2021-07-26 23:03:55 +02:00
Wim Taymans cea8a95a59 jack: emit more graph_order callbacks
We should actually emit the graphorder callback whenever something
changed, also when a client or port was added/removed.

Also emit the graphorder callback right after a client is activated to
make jackdbus work.
2021-07-20 11:44:35 +02:00
Wim Taymans 1531f78965 jack: ensure transport frame_rate is not 0
Try harder to get the transport frame_rate from the position.
If we can't find an activation structure, use the configured frame_rate
instead of 0.

Fixes #1432
2021-07-19 11:50:28 +02:00
Wim Taymans 99b1ce96ed jack: avoid overflow in time calculations 2021-07-06 17:55:38 +02:00
Wim Taymans 1ff535e6eb spa: move thread to SPA support
It can be more generally useful eventually.
2021-07-06 15:48:20 +02:00
Wim Taymans aab72ded6e jack: emit graph callbacks as well
When a link is added and removed, emit the graph callback.
2021-07-06 10:40:31 +02:00
Wim Taymans a3549deb48 jack: remove a lock
The thread loop is already taken when calling port_update_latency.
Improve some debug, add some comments.
2021-07-06 10:40:31 +02:00
Wim Taymans 831fb9ea01 JACK: implement jack_recompute_total_latencies()
Still acts a little weird in Ardour sometimes as if ardour is not
getting the updates in time.

See #1388
2021-07-05 16:06:34 +02:00
Wim Taymans 4abcfcdfb9 improve some debug 2021-07-05 16:06:22 +02:00
Wim Taymans dc5ed8f327 thread: add methods to get rt priority range 2021-07-05 11:35:27 +02:00
Wim Taymans 9ceb728dec jack: use the pw_thread_utils interface
Use the pw_thread_utils interface to create/join and acquire/drop
RT priority. This allows JACK apps to also use the configured module to
handle RT priorities.
2021-07-05 10:40:25 +02:00
Wim Taymans 5088ebacc5 jack: drop/acquire RT when enter/exit freewheel
Freewheel can use a lot of CPU and we don't want our realtime threads to
take up all resources while freewheeling.
2021-07-05 09:56:14 +02:00
Wim Taymans e2d6545e77 jack: client_thread_id should return the data thread
Add a function in data-loop to get the natvive thread and use that
in client_thread_id() so that it returns the pthread of the
data thread instead of the caller thread.
2021-07-05 09:56:14 +02:00