Commit graph

620 commits

Author SHA1 Message Date
Wim Taymans
5b01a2e738 jack: fix port sort
When the nodes are equal, sort playback ports befor monitor ports.
Then sort by system-id (port-id) and then by serial number.

See #2260
2022-04-02 09:42:22 +02:00
Wim Taymans
617405e08c jack: don't sort ports on alias
The alias is not a good property to sort on, it contains the object
path and could sort playback_11 before playback_2.

Just group ports of the same node together, then sort by port_id and if
that fails, use the serial number.

See #2260
2022-04-01 17:29:39 +02:00
Wim Taymans
f0424c0b99 thread: deprecate pw_thread_utils_set()
Setting a global thread-utils is not a good idea, especially
when multiple contexts will register their own interface.

Instead, set the thread-utils as a context object and use this to
configure the data loop in the context.

In JACK we need a per context implementation of the interface so that
we can find the context specific thread-utils.

See #2252
2022-03-30 20:39:34 +02:00
Wim Taymans
6041d939a0 jack: make a custom thread-utils
Make a custom thread_utils that can use the configured global
thread creator and set this in the data-loop.

This ensure that the data loop uses the creator thread when activated.

See #1495
2022-03-29 11:37:47 +02:00
Wim Taymans
d306786012 jack: start/stop loop in activate/deactivate
Stop the loop from the context.
Start the loop in activate.
Stop the loop in deactivate.
2022-03-29 11:36:31 +02:00
Wim Taymans
36185b830a jack: clear last error before sync
We are really interested in the error code of the statements we queued
before the sync so clear any previous error first. Otherwise we might
pick up a previous random error, which never gets cleared.

See #1714
2022-03-26 21:35:28 +01:00
Stanisław Pitucha
ca9da0ed5a Fix the comparison parens
The parens were unnecessary and didn't seem to match the intent for the
result.
2022-02-18 14:09:30 +00:00
Wim Taymans
d3f879e4ed jack: only set force-latency property
There is no point in setting a node.latency property when we also set a
force-quantum.
2022-02-11 12:22:02 +01:00
Wim Taymans
f123b58f1f jack: release lock when doing do_sync from data thread
If we do_sync from the data thread, release the rt_lock so that any
callbacks that may happen while waiting can grab the rt_lock.

We could also temporarily disable the rt_lock grabbing before the
callbacks.

In any case the callbacks will need to be called while we execute
the blocking function in the process callback.
2022-02-10 17:13:48 +01:00
Wim Taymans
104f0c766a jack: remove some listeners 2022-02-09 15:52:14 +01:00
Wim Taymans
78a7370bc6 jack: remove some more limits
Remove limit on max results from _get_ports() and _get_all_connections()
by using a dynamic array.
Keep the limit on the max number of midi inputs we can mix.
2022-02-09 15:40:45 +01:00
Wim Taymans
4353fa83d6 pipewire-jack: there is no port max anymore 2022-02-09 15:21:49 +01:00
Wim Taymans
fae7a1f592 jack: use node.lock-quantum by default
As soon as a JACK app is started, the automatic quantum change is
disabled. This means no pulse/alsa app can change the quantum.

The only way to change the quantum is with node.force-quantum or
with the settings metadata.

This means only a JACK buffersize change (usually controlled from the
JACK app, such as in ardour) or a metadata change (from the command
line) can modify things. Both of those are usually caused by a user
action.

For JACK apps where the quantum is allowed to change automatically,
explicit rules need to be placed in the config.
2022-02-08 18:35:12 +01:00
Wim Taymans
3b26af32d0 jack: add an option to display default device as system: 2022-02-04 17:06:54 +01:00
Wim Taymans
877dc77645 conf: move rule matching to config
And remove duplicated code. This is generally useful and sufficiently
generic API to include.
2022-02-04 10:43:31 +01:00
Wim Taymans
3a5c2ec623 jack: exit do_sync when in error
When we are already in error, return the error right away.
2022-02-03 12:01:30 +01:00
Wim Taymans
432f464297 conf: implement match rules with conf_section_for_each 2022-02-01 16:35:16 +01:00
Wim Taymans
65c487564b context: add a function to merge config properties
Add a function that takes a section and merges the properties into
a target properties. Replace some usage of get_config_section().
2022-02-01 15:11:45 +01:00
Wim Taymans
6149c01b51 jack: pass size_t as len 2022-02-01 13:28:10 +01:00
Wim Taymans
24c97b1c7e context: add force-quantum and force-rate property
Add a node.force-quantum and node.force-rate property. When no global
quantum or rate is enforce with settings, the last updated node property
is used as the quantum.

Make jack use the force-quantum property when set_buffersize is used to
make sure that the quantum is not just a suggestion but a hard forced
one. This makes it possible for ardour or other jack apps to raise the
quantum above the max-quantum but also ensure that it will not change
by any other application (unless other jack apps).

Fixes #2079
2022-01-31 17:59:18 +01:00
Wim Taymans
8698d5a548 jack: handle metadata remove
Add a proxy listener to the metadata so that we can remove our ref to it
when it is destroyed.
2022-01-31 15:04:08 +01:00
Wim Taymans
f0cc49766f jack: use serial for uuid
We must use the serial for generating the uuid.

We use the serial for the port_id and jack_port_uuid_generate() can
be used to turn that into a uuid. So all mappings to and from
uuid need to be with serials.
2022-01-26 17:47:03 +01:00
Wim Taymans
910ba5856c jack: uuid is based on id, not serial
So that we can easily map properties to metadata.
2022-01-26 12:24:31 +01:00
Wim Taymans
0bc3d1444a Add PIPEWIRE_QUANTUM env variable
That tries to both set the buffersize and the samplerate of the graph.
Document them in README.md
Also add the same env variables to pw-stream and pw-filter.
2022-01-23 11:21:18 +01:00
Wim Taymans
f4021c7f44 port: add some more warnings when unregister fails 2022-01-23 10:16:42 +01:00
Wim Taymans
6c84b77e4d jack: add some debug to port_register()
See #1714
2022-01-23 09:35:21 +01:00
Wim Taymans
6ab56804e8 jack: uuid of ports is based on the id, not serial 2022-01-23 09:35:21 +01:00
Barnabás Pőcze
899281be60 jack: fix member name in fastpath logs
The port struct's `id` member has been renamed to `port_id`,
but the `pw_log_trace_fp()` invocation sites weren't changed.

Fixes: 029539831d ("jack: rework port allocation")
2022-01-22 23:29:45 +01:00
Wim Taymans
029539831d jack: rework port allocation
Port ids should be allocated using a map.
Only keep a port_id for the ports we allocate ourselves.
Keep just one port free list, there is no reason to keep per direction
free lists.
Get the port from the object directly.

See #1714
2022-01-22 20:59:27 +01:00
Wim Taymans
a77f5131b2 jack: add dummy jacknet implementation
So that applications can link to libjacknet

Fixes #2043
2022-01-19 19:47:28 +01:00
Wim Taymans
ca3fada8cb jack: fix jacknet meson variable 2022-01-19 19:28:08 +01:00
Wim Taymans
709d25f0c4 make key for node.transport.sync 2022-01-18 20:34:03 +01:00
Wim Taymans
1b9a2b6079 jack: use serial for port_id
We can reuse the cache logic, id removal invalidates the object id but
it can still be accessed by the serial until it gets purged.
2022-01-17 12:20:29 +01:00
Wim Taymans
ac919e2a10 jack: add PIPEWIRE_RATE env variable
So that you can make pipewire switch samplerates.
2022-01-14 10:12:05 +01:00
Wim Taymans
13830f2ded jack: update for no id reuse
Now that object ids are not reused we can simplify some things. We
don't need to keep a map around with our own unique ids.

Keep all objects in one per client list, mark the removed ones as
removed, allow lookups of the removed objects, recycle half of the
oldest removed objects when there are too many of them.
2022-01-13 14:53:19 +01:00
Wim Taymans
dcac58609c jack: don't limit max buffer size 2022-01-12 17:41:13 +01:00
Wim Taymans
2b102a1046 jack: remember last return from jack_get_buffer_size
Remember what we last returned from jack_get_buffer_size and only
emit a buffersize change event when somwthing new is configured.

Fixes startup of jconvolver.

Fixes #1989
2022-01-07 17:12:43 +01:00
David Runge
41392eda7f Add custom variable to jack pkgconfig to distinguish implementations
pipewire-jack/src/meson.build:
Add the custom `jack_implementation=pipewire` pkgconfig variable to the
generated jack.pc file to be able to distinguish jack implementations.
As jack implementations exist with jack1, jack2 and pipewire-jack, it is
not (easily) possible to distinguish them by looking at the version
alone (particularly the case with jack2 vs. pipewire-jack, as they share
the same headers).

Related to #1666
2022-01-06 12:37:08 +00:00
Wim Taymans
611591d0fc json: add spa_json_parse_stringn()
It also checks the destination size.
2022-01-04 12:37:00 +01:00
Wim Taymans
c46113faa3 json: spa_json_get_string() writes up to len chars or fail 2022-01-04 10:42:32 +01:00
Wim Taymans
35cbe4e939 buffers: make alignment optional
Make the alignment parameter optional when negotiating buffers.
Default to a 16 bytes alignment and adjust for the max cpu
alignment.
Remove the useless align buffer parameter in plugins, we always
set it to 16 anyway.
2022-01-03 12:32:26 +01:00
Wim Taymans
4c0bba953a jack: avoid metadata updates to monitor nodes
Because there is no difference in the node id of the monitor and
the sink carla has problems.

See #1945
2021-12-24 11:30:56 +01:00
Wim Taymans
1f4d3b0a1b jack: encode monitor uuid with extra bit
So that we can make a difference between monitor and sink uuid.

See #1945
2021-12-23 12:25:59 +01:00
Wim Taymans
f5908dbddf impl-node: start sync after reposition
After we get a reposition request, bring the state to the SYNC state
again so that clients can align with the new position.

Fixes a problem with reposition when using the jack transport.

Fixes #1907
2021-12-22 19:53:28 +01:00
Hendrik Borghorst
205774f3ab jack: Disconnect owned links on jack_deactivate
As per JACK API description the call to jack_deactivate should
disconnect all ports because an inactive client can't have connections.

This disconnect is missing in the current API and results in left-over
links after the call and malfunction to clients (e.g. Music Player
Daemon).

To fix it this commit goes through the list of links to owned ports and
disconnect them.

Signed-off-by: Hendrik Borghorst <hendrikborghorst@gmail.com>
2021-12-15 15:44:28 +00:00
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