Commit graph

347 commits

Author SHA1 Message Date
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
Hector Martin 1c6326439f jack: make cycle_wait() loop until a valid cycle
pw_data_loop_wait() can return due to activity on another socket, so
keep looping until cycle_run() gets a valid command.

Fixes #1386
2021-07-03 16:58:20 +09:00
Wim Taymans 797e9b3e0b jack: use RESET_ON_FORK when dropping rt priority
Once we set the RESET_ON_FORK flag we might not have permission to
reset again in drop_rt so simply also set it when dropping.
2021-07-01 15:34:19 +02:00
Wim Taymans 4fb878e449 jack: name the thread-loop differently 2021-06-28 12:23:08 +02:00
Wim Taymans 82f02dc502 jack: create threads with FIFO scheduling
Make jack_client_create_thread() create FIFO threads, like the
JACK implementation did. We should probably hook that into the
module-rt functions somehow.

Fixes #1349
2021-06-28 12:22:49 +02:00
Wim Taymans 5e9f6c8ecc jack: use system:monitor_ prefix for monitor ports 2021-06-24 20:31:55 +02:00
Wim Taymans 7ef78b4464 jack: add extra object check
Make an invalid object type and mark removed objects as invalid.
Make sure we don't reference an invalid object for the various
callbacks and methods.

See #1265
2021-06-24 15:49:59 +02:00
Wim Taymans 8c77713a7b jack: don't emit connect callback with unknown ports
Lookup of globals needs a thread lock or context lock. There is no
need to take the context lock when we already have the thread lock.

Make a new method to find an object of a type.

Check that link objects are referencing valid ports. Check that the
connect callback is referencing valid ports.

Only return connections with valid ports.

See #1265
2021-06-22 11:16:45 +02:00
Wim Taymans 6186fc775d jack: improve debug
Log info messages when a port and client are added/removed
Log an info message when port_by_name/id can't find the port.

See #1265
2021-06-21 11:25:17 +02:00
George Kiagiadakis 59407d2f08 includes: update all references to extensions to point to pipewire/extensions
This also brings the advantage that all tools, examples, modules, components
can also be compiled standalone out-of-tree using libpipewire from the system
2021-06-18 17:54:18 +03:00
Wim Taymans d8ad87fd09 context: improve settings and defaults
Make structure with defaults that holds the defaults as they are loaded
from the config file or initialized with default values.

Copy this structure to a settings version that is used at runtime.

Add a force-quantum and force-rate field in the settings that can be
used to force a quantum and samplerate if != 0.
2021-06-17 11:11:45 +02:00
Wim Taymans 0ec760315e jack: there is no need to lock in get_aliases
See #1313
2021-06-17 10:56:39 +02:00
Wim Taymans 0f9fd45a58 jack: rework locking
Ensure all callbacks are called from the thread_loop and release
the thread lock before calling the callback.

Introduce a new rt_lock that is taken while the callbacks are called.
Only call the process_callback when we can acquire the rt_lock in the
data thread. This ensures the process callback is never called
concurrently with any other callback.

Give a warning when we try to call do_sync from the thread_loop
itself. We would deadlock because the thread that is supposed to do
the sync operation would be blocked in wait().

Fixes #1313
2021-06-17 10:46:04 +02:00