Commit graph

406 commits

Author SHA1 Message Date
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
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