Commit graph

464 commits

Author SHA1 Message Date
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
Wim Taymans 3e52c6598b jack: add more port checks
Check if the port id and direction is valid before accessing the
port array.
Handle unknown and invalid ports in many methods.
Free the port item after we removed the item from pipewire because
more methods are being called while removing the port and we don't
want them to fail.
2021-06-17 09:23:11 +02:00
Wim Taymans 61bcd4f988 jack: only use the "default" metadata 2021-06-16 12:17:52 +02:00
Wim Taymans e3a2f4a645 jack: keep context lock locked for callbacks
Also keep the context lock locked with emiting the registration,
portregistration and connect callbacks.

All the other callbacks are emited with the lock and it makes sense to
also emit these ones with the lock so that code in the callback gets
a consitent view.

See #1265
2021-06-13 19:26:10 +02:00
Peter Hutterer da339c286f meson.build: drop HAVE_CONFIG_H
This is an autotools leftover, with meson we're always guaranteed to have
the config.h file.
2021-06-10 09:04:16 +10:00
Wim Taymans a10cb3a597 jack: unlock mutex on error path
This needs some more fixing because it leaks everything.
2021-06-09 17:57:05 +02:00
Peter Hutterer 0054319d88 meson.build: add -D_GNU_SOURCE to the project arguments
This appends it to every compilation command so we can get rid of the c_args
for (almost all) executables.
2021-06-09 07:47:51 +00:00
Wim Taymans ec39cbee68 jack: improve debug
Add quotes around the port and client names.
2021-06-08 09:50:13 +02:00
Wim Taymans 2dcab4580f jack: store renamed port
When we rename the port, also store the new name in the port structure
so that we can actually find the port with the new name.

See #1265
2021-06-08 09:40:14 +02:00
Wim Taymans b142e7f09f jack: stop freewheeling correctly
Setting a NULL value for the property will remove the property and
will thus not send an update to the server and will thus not stop
freewheeling. Use "" to remove ourselves from the freewheel group
instead of looping forever.

See #1265
2021-06-07 12:22:47 +02:00
Wim Taymans 0792c690c2 jack: schedule port latency update from main thread
Ardour does the port latency update from the process thread. Schedule
an update on the main thread in all cases to avoid deadlocks.

See #1265
2021-06-07 11:16:24 +02:00
Wim Taymans 5a054cfc9e jack: call pw_ methods from within the lock
We're using a thread loop so always call methods with the lock or
we might cause lockups and crashes.

See #1265
2021-06-05 20:17:37 +02:00
Peter Hutterer 1d4b24d02b pipewire: allow NULL pointers in pw_memmap_free()
Just like the real free() we should just ignore a NULL pointer, makes the
caller code easier for those instances where properties are optional.
2021-06-02 10:56:46 +00:00
Arun Raghavan f19d998906 pw-jack: Fix empty string checks
shellcheck seems to hate x"$FOO" = x checks, so let's use the
appropriate test arguments instead.
2021-05-31 12:46:18 -04:00
Wim Taymans c319ed68d1 jack: implement more latency
Keep both input and output latency on the ports.

When setting the port latency only apply the rate latency values
and assume the node latency does not depend on buffer-size or time.
This is likely true because jack only knows about latency relative
to the rate.
2021-05-27 15:26:09 +02:00
Wim Taymans 12a3ea9539 jack: implement default latency handler
It combines all latency from one direction and sets it as the latency
for the other direction.

Also keep only one latency value per port, in the object.
2021-05-27 15:26:09 +02:00
Wim Taymans 4af2014168 jack: add latency reporting
Rework the param handling a little.
Keep properties for ports. Use this in the client and port info.
Trigger the latency callback when the port latency changed.
Update the port latency when it changed.
2021-05-27 15:26:09 +02:00
Wim Taymans b9b89b92b2 spa: add some latency helpers
Add more fields to the latency object.
Add methods to create, parse and process latency info.
2021-05-27 15:26:09 +02:00
Wim Taymans b588cc6b03 jack: listen to latency updates on ports
Listen for the latency updates on ports and use this to report
latency.
2021-05-27 15:26:09 +02:00
Peter Hutterer 5596e350ea pipewire-jack: fix scan-build errors for unused variables
All cases of value stored but never read
2021-05-26 07:51:27 +00:00
modula t 3aacc719b2 fix floating point exception when s->clock.position' is less than s->offset` 2021-05-26 07:46:14 +00:00
Fabrice Fontaine fa64d93e64 fix linking with -latomic
Linking with -latomic has been added to pipewire-jack since
b8c58c74d8

However, this is not the right place to add this dependency, atomic_dep
should be added to pipewire_dep to avoid the following build failure:

/home/giuliobenetti/autobuild/run/instance-0/output-1/host/opt/ext-toolchain/bin/../lib/gcc/sparc-buildroot-linux-uclibc/9.3.0/../../../../sparc-buildroot-linux-uclibc/bin/ld: src/pipewire/libpipewire-0.3.so.0.326.0.p/filter.c.o: in function `impl_node_process':
filter.c:(.text+0xf28): undefined reference to `__atomic_fetch_add_4'

Indeed, atomic operation such as __atomic_fetch_add is used in libcamera
as well as in ./spa/plugins/libcamera/libcamera_wrapper.cpp,
./spa/include/spa/utils/ringbuffer.h and ./spa/include/spa/graph/graph.h

Fixes:
 - http://autobuild.buildroot.org/results/b5305e8e7dd1a5e8bfaba72b06251056ba7d1af1

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
2021-05-24 08:33:50 +00:00
Peter Hutterer 4e70799922 treewide: drop strzcmp implementations in favor of spa_streq 2021-05-18 22:10:27 +10:00
Peter Hutterer 522f87d5ea treewide: replace strcmp() != 0 with !spa_streq
This change is only done in source files for now, header files will be done
separately.
2021-05-18 22:10:27 +10:00
Peter Hutterer 95a84e797a treewide: replace !strcmp() with spa_streq()
This change is only done in source files for now, header files will be done
separately.
2021-05-18 22:10:27 +10:00
Peter Hutterer 7697ed0757 treewide: replace strcmp() == 0 with spa_streq()
This change is only done in source files for now, header files will be done
separately.
2021-05-18 22:10:27 +10:00
Peter Hutterer 20f8838f7b pw-jack: correct nested quotes
Found by ShellCheck, reformatted output:

In pipewire-jack/src/pw-jack.in line 58:
echo "	-s                  samplerate (default "$SAMPLERATE")"
	 SC2027: The surrounding quotes actually unquote this. Remove or escape them.
	 SC2086: Double quote to prevent globbing and word splitting.
2021-05-11 07:01:21 +00:00
Peter Hutterer 056d06da88 pw-jack: remove unecessary $ from arithmetic variables
Found by ShellCheck: SC2004: $/${} is unnecessary on arithmetic variables.
2021-05-11 07:01:21 +00:00
Wim Taymans 830f52cbb1 jack: join the freewheel group when freewheeling 2021-05-07 09:03:34 +02:00
Wim Taymans efc497a38a spa: make a new FREEWHEEL clock flag
When freewheeling, the clock is going faster than real time.
When freewheeling, skip samples in alsa sink/source.
2021-05-07 09:03:34 +02:00
Peter Hutterer 2405f0942b spa/buffer: rename SPA_MEMBER to SPA_PTROFF
SPA_MEMBER is misleading, all we're doing here is pointer+offset and a
type-casting the result. Rename to SPA_PTROFF which is more expressive (and
has the same number of characters so we don't need to re-indent).
2021-05-06 09:39:39 +00:00
Andrea Gelmini 85b136d8ce Fix typos
Signed-off-by: Andrea Gelmini <andrea.gelmini@gelma.net>
2021-04-30 16:27:34 +00:00
Andrea Gelmini 47ef2b6b09 Fix typos 2021-04-30 07:40:20 +00:00
Nils Tonnätt b48d1facf4 Add server_libs variable to jack pkgconf file 2021-04-18 18:31:32 +00:00
Nils Tonnätt 01951fd278 Generate JACK pkgconfig file 2021-04-18 18:31:32 +00:00
Nils Tonnätt bd6d72be8f Install jack headers 2021-04-18 18:31:32 +00:00
Peter Hutterer 223f20709d meson: replace join_paths(a, b) with a / b
More readable and from the meson reference manual:
(since 0.49.0) Using the/ operator on strings is equivalent to calling join_paths.
2021-04-15 06:57:00 +00:00
Wim Taymans 877309bfbe use priority.session to select the default sink/source
priority.session is meant to be used to set routing priorities.

priority.driver is meant to be used by the scheduler to select what
nodes is best for driving the graph. This usually depends on the
hardware quality and the use case (Pro Audio devices are likely
to be used as driving the graph).

See #1028
2021-04-08 17:48:13 +02:00
Wim Taymans c50c0b91c5 jack: improve registration callbacks
Pass the type to the alloc function to make things pretier.

Emit the client added only for the first client and the removed
callback for the last client. Things like pavucontrol will make
many nodes with the same name, which we map to the same client,
only when the last node is gone, we emit the client removed.
2021-03-30 12:57:38 +02:00
Wim Taymans 74c6af1c55 jack: handle _port_get_buffer() on foreign ports
Some apps (ardour6) does a port_get_buffer() on a port that is not
its own port. This is not possible in PipeWire so make sure it
simply return NULL instead of crashing.

Fixes #988
2021-03-29 11:14:37 +02:00
Wim Taymans 222cffc850 jack: small cleanups and erro checks 2021-03-27 18:33:22 +01:00
Wim Taymans 27a5ebb87e jack: free server in error case 2021-03-25 19:07:13 +01:00
Wim Taymans c78901f9f9 jack: free client in error case 2021-03-25 17:54:24 +01:00
Wim Taymans df9644f109 jack: add jack.self-connect-mode
Add a property to restrict self-connections. This can be used to
stop clients from connecting themselves automatically.

Fixes #952
2021-03-23 12:24:38 +01:00
Wim Taymans 53024c1747 jack: free the global map when the client is closed 2021-03-22 11:21:44 +01:00
Florian Hülsmann 41d4039ee4 jack: omit debugging macros in jack_{error,info,log} 2021-03-16 08:59:01 +00:00
Florian Hülsmann 21ff2740d6 jack: jackctl_server_create2 add dummy driver 2021-03-16 08:59:01 +00:00
Florian Hülsmann 1a59711ce1 jack: jackserver sources, add stubs for control.h 2021-03-16 08:59:01 +00:00
Wim Taymans 196fe8b51b jack: use configured node.latency when inactive
In the inactive state, use the configured latency values for the
node instead of the current values used in the graph. We need to
do this because the graph only changes the buffer-size to our
requirements when the node becomes active.

Some clients do get_buffer_size before activating and would then
get a different value from when they would activate, causing some
apps to be confused and stop.

See #886
2021-03-12 15:58:34 +01:00
Wim Taymans 3e2d897f97 jack: improve debug 2021-03-07 10:46:08 +01:00
Wim Taymans 6c8c58ab4e jack: also match system ports in get_ports
Fixes #850
2021-03-07 09:44:40 +01:00
Wim Taymans ffab69f651 jack: move some debug to info
Use info to lay out the general app flow
2021-03-07 09:44:04 +01:00
Wim Taymans c8fd34a41d metadata: store default-nodes as JSON
Don't just store the id in the metadata but a JSON object with
the node name. This makes it possible to easily introspect the
metadata and also extend the metadata with more fields later.

Instead of matching the metadata id to the global ids we now
have to match it against the name.
2021-03-05 17:37:12 +01:00
Wim Taymans 0ad603375f jack: keep midi ports on the midi-bridge client
Separating them causes problems because there is no actual
client for the resulting ports then.
2021-03-04 18:06:07 +01:00
Wim Taymans d98d947e54 jack: handle "default" server name 2021-03-04 18:02:11 +01:00
Wim Taymans 052bc85dad jack: ship our own jack headers and build against them 2021-03-03 15:54:48 +01:00
Wim Taymans eacda22a7b jack: make constant of Monitor extension
See #788
2021-02-24 22:23:20 +01:00
Wim Taymans 8768cf1b68 jack: increase client name size
Increase the client name size and try hard not to exceed the client name
size especially when adding the Monitor suffix.
Also avoid some potentially unsafe strncpy.

See #788
2021-02-24 22:05:14 +01:00
Wim Taymans e340a44a35 jack: fix names of our ports
Write our port name into the port.name

See #796
See #780
See #569
2021-02-23 21:11:05 +01:00
Wim Taymans d54da879bf jack: add config option to shorten and filter names 2021-02-23 16:13:08 +01:00
Wim Taymans 149319819a jack: apply PIPEWIRE_PROPS after reading config
First apply config properties, then PIPEWIRE_PROPS.
We can set the node.latency in jack.conf
2021-02-20 21:02:05 +01:00
Wim Taymans 71e37f93f3 PIPEWIRE_LATENCY always overrides app settings 2021-02-20 20:59:41 +01:00
Wim Taymans 686524ce40 context: use the log.level from the config file
Use log.level from the config file if not otherwise set with
PIPEWIRE_DEBUG env.
Make client log.level = 0 by default to avoid spamming the console
with errors.

Fixes #725
Fixes #769
2021-02-19 12:44:03 +01:00
Wim Taymans 60233e30a7 jack: tweak names a little
Move the Description in the main node/port name. This then matches
the device names seen in pavucontrol.
Make the port alias contain the node nick.
2021-02-17 11:36:16 +01:00
Wim Taymans e66cb18659 jack: find system: port names as well
Make a system:capture_N or system:playback_M name for each port
and use this also in find_node when the node is a default node.
This makes it possible to

jack_connect system:capture_1 system:playback_1

and make it link the default source to defaukt sink.

Fixes #446
2021-02-17 11:16:02 +01:00
Wim Taymans 39cf575210 jack: don't log errors, let app deal with it 2021-02-17 11:15:31 +01:00
Wim Taymans af686653a9 jack: add option to merge monitors
Make a different name for the monitor port prefix so that they
appear as different clients.
Add an option to restore the previous behaviour.

See #736
2021-02-16 13:23:47 +01:00
Wim Taymans 0945b10227 jack: handle bridge nodes
Bridges have the device name in the port names so use this info
to construct better port names. Makes midi devices show up
as separate clients.
2021-02-12 21:15:14 +01:00
Wim Taymans ac910c7c1c Revert "jack: improve short name"
This reverts commit 8101334b1e.

We should use the same logic as jack1 and jack2 to improve
compatibility.
2021-02-12 20:46:34 +01:00
Wim Taymans 1e89b7cdc4 Revert "jack: sanitize client and port names"
This reverts commit 0ad8f0a6aa.

We should not do this here. We should instead sanitize the names
at the source.
2021-02-12 20:45:33 +01:00
Wim Taymans 0ad8f0a6aa jack: sanitize client and port names
Avoid : in client names and port names.

See #714
2021-02-12 12:29:45 +01:00
Wim Taymans 8101334b1e jack: improve short name
Search the : backwards so that we can deal with client names with :
in them.

See #714
2021-02-12 11:57:27 +01:00
Wim Taymans 80825aeaea conf: more work on config changes
Add -c option to pipewire to select config file. Use this to select
the uninstalled conf file.
Rename conf properties, prefix with context.
Simplify the main daemon now that everything can go in config.
Simplify pipewire-pulse now that we can put everything in config, it's
now virtually the same as pipewire but with a differenct config file.
Parse server addresses as array of strings.
2021-02-12 10:31:29 +01:00
Wim Taymans fc90a4e48a Implement config/state file handling
Make methods to load_config and load/save state. For now the config
and state directories are the same but it might not be. Implement
the search path for all config/state files as:

  $XDG_CONFIG_HOME/[$prefix]/$name
  $HOME/.config/[$prefix]/$name
  $PIPEWIRE_CONFIG_DIR/pipewire/[$prefix]/$name
  /etc/pipewire/[$prefix]/$name

Make some config files for jack and RT clients. Make pw-cat use the
client-rt config.

Use core state and config management in media-session.
Move all session manager state and config files to the build dir and
set the PIPEWIRE_CONFIG_DIR to this build dir.
2021-02-12 10:25:11 +01:00
Wim Taymans 83c403ed1c jack: use PIPEWIRE_PROPS for the context as well
Use PIPEWIRE_PROPS to create and connect the context as well. This
makes it possible to pass configuration to the modules loaded by
the context such as:

PIPEWIRE_PROPS="context.modules.args={nice.level=-14}" jack_simple_client

To set the nice level of the jack app.

See #698
2021-02-10 11:23:52 +01:00
Wim Taymans 51cfb98ea6 jack: Pass custom flags as port.extra info
Make a port.extra property that contains API specific extra port
information that is passed in the global object properties.
Use this to pass the custom jack flags for a port. Carla uses this
to mark CV ports.
2021-02-09 16:09:53 +01:00
Wim Taymans ef150bfb3c jack: return an empty session command
We need to return an empty message because apps don't expect a
NULL pointer.
2021-02-09 10:26:14 +01:00
Wim Taymans 19b6942965 jack: use PIPEWIRE_PROFILE_MODULES first
We want to respect the PROFILE_MODULES settings if any or else
we use the default,rtkit profile.

See #683
2021-02-08 18:02:58 +01:00
Wim Taymans 0f028dab40 jack: use the context data thread
Configure the data thread as cancelable, there is no need to make
another thread.

See #683
2021-02-08 15:29:48 +01:00
Wim Taymans 210950dc0a context: disable mlock warnings by default
Make this a tunable option instead.
2021-02-08 10:59:02 +01:00
Wim Taymans 3450bea416 jack: implement some missing methods
to make qjackctl 0.9.0 work
2021-02-04 15:48:36 +01:00
Wim Taymans 2b44f42845 pass the complete buffer size to snprintf
There is no reason to pass size-1, snprintf will always put a \0
at the end.
2021-02-02 12:09:29 +01:00
Wim Taymans abfc67a3ca Revert "remove mlock and use MAP_LOCKED"
This reverts commit ab91e94b59.

When no memory can be locked, the mmap fails with -EAGAIN.

Fixes #592
2021-01-19 14:47:52 +01:00
Wim Taymans ab91e94b59 remove mlock and use MAP_LOCKED
The warnings are confusing and a properly tuned system would have
the limits set correctly.
2021-01-19 11:59:21 +01:00
Wim Taymans c430b1de58 jack: move monitor ports after playback ports
Enumerate monitor ports after their playback ports, like how
jack does this.

See #527
2021-01-05 15:38:52 +01:00
Wim Taymans 776147c125 jack: also find port by aliases
one can also use the aliases to connect ports, qjackctl does this.

Fixes #527
2021-01-03 21:25:55 +01:00
Wim Taymans 2b507cbe79 jack: use the node activation position after connecting
Until we get assigned to a driver, use our own activation position
to report samplerate and buffer size.
2020-12-09 20:48:59 +01:00
Elliott Sales de Andrade 86fd6a0d3e Fix some possible-NULL pointer usage. 2020-11-23 15:36:08 +00:00
Wim Taymans fb44d3428c jack: block some cases
Refuse to run when we run in the daemon, we can't really do a blocking
connect to the daemon from its main thread.

Also refuse to run when we detect an old pipewire libaray. Blocks the
case where some app linked against 0.2 wants to use the replacement
libjack.so.
2020-11-19 12:37:10 +01:00
Wim Taymans f42da492f9 warn about lock just once 2020-11-14 21:21:20 +01:00
Wim Taymans 38bcab4610 jack: handle connect errors
Listen on the proxy for errors and report this to the caller. This
avoids hanging in jack_connect.
2020-11-04 21:05:45 +01:00
Wim Taymans c43026d93e don't handle EINTR and EAGAIN as the same
EAGAIN means a non-blocking operation would block and we should not
try again right away but leave the loop and wait instead.

See #358
2020-11-02 16:43:56 +01:00
Wim Taymans e094640c7b handle EINTR and EAGAIN
Just do the call again instead of failing or logging an error.

Fixes #358
2020-11-02 14:51:07 +01:00
Wim Taymans acfb48e3da pulse: improve debug 2020-10-27 16:46:12 +01:00
Wim Taymans 70e9e622eb jack: declare constants like jack does again 2020-10-22 15:23:56 +02:00
Wim Taymans 4dd1e02526 jack: return error when out of midi events
Fixes #334
2020-10-19 23:30:44 +02:00
Wim Taymans 68bff629b3 jack: optimize get_buffer
Keep track of global mix port.
Calculate the get_buffer function beforehand.
2020-09-30 11:59:41 +02:00
Wim Taymans 2a630dbecd jack: move some debug to fastpath 2020-09-29 16:57:50 +02:00
Wim Taymans c2fc8423eb jack: move metadata to exports file
So that we don't have to depend on the header file.

Fixes #306
2020-09-25 17:39:26 +02:00
Wim Taymans 136f556d79 jack: lock for accessing the globals 2020-09-22 13:10:58 +02:00
Wim Taymans c979f181a5 jack: return useful version number (major version 3)
Also add the PipeWire string in there to give apps a chance to
report this.
2020-09-11 11:28:04 +02:00
Wim Taymans dc2cfb2bd2 jack: only report latency for terminal ports
Only report latency for terminal ports for now and use the buffer
size as the latency.
2020-09-10 09:15:47 +02:00
Simon McVittie b8c58c74d8 Link pipewire-jack to libatomic if required
This is necessary on some 32-bit architectures that implement atomic
operations on 64-bit quantities as library calls, including Debian's
armel and mipsel ports.

Signed-off-by: Simon McVittie <smcv@debian.org>
2020-09-07 15:17:57 +00:00
Wim Taymans d995df95f8 jack: small cleanup 2020-09-07 16:16:26 +02:00
Wim Taymans 4c372a87ca pw-jack: add samplerate and period options 2020-09-03 11:14:29 +02:00
Wim Taymans 0c04481ba7 metadata: improve default sink/source
Only check defaults when subject is PW_ID_CORE
Handle NULL keys: remove the defaults
2020-08-18 17:56:05 +02:00
Wim Taymans 759e1ccb6b jack: fix default source and sink handling 2020-08-18 17:18:37 +02:00
Wim Taymans 8c893cbc4a jack: improve debug 2020-08-18 16:52:27 +02:00
Wim Taymans 36c10046da metadata: fix string compare 2020-08-12 18:58:48 +02:00
Wim Taymans cc044b0e08 jack: don't overwrite any PIPEWIRE_PROPS values 2020-08-11 12:12:37 +02:00
Wim Taymans f73a0c97e3 jack: use empty area when get_buffer frames is 0
Client that call port_get_buffer with 0 frames get the empty scratch
buffer because we can't know the final output size.
2020-08-11 12:09:50 +02:00
Wim Taymans 753af7c7b3 jack: improve buffer size callbacks
Make sure we emit the buffer callback either from the calling thread
or from the thread_loop. Mark the callback as pending and don't call
the process function until the callback has been handled.
2020-08-11 11:11:00 +02:00
Wim Taymans e71936f870 Improve naming
master -> driving
priority_master -> priority_driver
segment_master -> segment_owner
2020-08-06 13:49:33 +02:00
Wim Taymans 3abd46b619 jack: Use out node name from the server
Get the node name from the global info when we see it.
Check if the name changed and set the right result flag for the app.
2020-08-05 12:26:59 +02:00
Wim Taymans d76b509995 jack: prefer nick for node name
The nick is shorter and nicer for jack applications. We have the
full description in the port alias 2.
2020-08-03 18:13:31 +02:00
Wim Taymans 407ea74513 don't use qsort_r, it's not implemented everywhere
Fixes #260
2020-08-02 12:50:56 +02:00
Wim Taymans 2b3a58ed13 jack: improve client name
Only append app name and node name when they are different
Use / to separate app name from node name because : is used to
separate client name from port name.
2020-07-30 12:56:20 +02:00
Wim Taymans 2e95f7dd85 jack: improve metadata callbacks
Only emit callbacks when something changed.

When setting a value, first update the local store. This triggers
the emit from the calling thread (as expected by jack clients) and
when the update arrives from the server, it will not emit the callback
anymore because the value didn't change.
2020-07-30 12:11:24 +02:00
Wim Taymans f888c58b83 jack: fix client uuid 2020-07-30 12:10:46 +02:00
Wim Taymans bb20e0646c jack: parse varargs and use server name
Parse the varargs and use the server name as the remote
2020-07-23 13:18:14 +02:00
Wim Taymans 266e1301d2 use id to store default sink/source
This is easier to handle in general and we should not use the name
as a unique id. If the session manager wants to save things, it can
use whatever fields it wants from the object to create a unique
persistent name.
2020-07-23 11:59:13 +02:00
Wim Taymans ca066fbf3b jack: use PIPEWIRE_PROPS env to add properties to jack nodes 2020-07-21 16:50:45 +02:00
Wim Taymans d4d80c16c1 jack: handle NULL keys 2020-07-21 16:47:58 +02:00
Wim Taymans 8b291ada27 jack: increase client name size 2020-07-21 15:41:52 +02:00
Wim Taymans 13492fd282 jack: include application name in client name 2020-07-20 16:54:38 +02:00
Wim Taymans ee2c1f3882 jack: enforce unique port names as well 2020-07-20 16:27:26 +02:00
Wim Taymans 7711c98123 jack: use default sink/source to sort ports 2020-07-17 17:23:43 +02:00
George Kiagiadakis a108752514 jack: fix crash on close when metadata are not available 2020-06-17 12:13:34 +00:00
Wim Taymans 0441653ce4 jack: use PIPEWIRE_LINK_PASSIVE environment var
Let the jack client make passive links when the PIPEWIRE_LINK_PASSIVE
variable is set. Makes it possible to start qsynth with passive links
so that it suspends when not in use.
2020-06-17 13:17:28 +02:00
Wim Taymans 660d77cff0 jack: allocate mix structure dynamically 2020-06-16 21:12:12 +02:00
Wim Taymans c9d4c1ba95 jack: dynamically fill the port array
Don't preallocate ports, do so on demand to reduce memory
usage.
2020-06-16 20:57:52 +02:00
Simon McVittie b852b58f82 Optionally install examples and tests
This makes it easier to test PipeWire in its "as-installed" state,
for example in an OS distribution.

The .test metadata files in ${datadir}/installed-tests/${package} are
a convention taken from GNOME's installed-tests initiative, allowing a
generic test-runner like gnome-desktop-testing to discover and run tests
in an automatic way.

The installation path ${libexecdir}/installed-tests/${package} is also
a convention borrowed from GNOME's installed-tests initiative.

In addition to the automated tests, I've installed example executables
in the same place, for manual testing. They could be separated into
a different directory if desired, but they seem like they have more
similarities with the automated tests than differences: both are there
to test that PipeWire works correctly, and neither should be relied on
for production use. Some examples are installed in deeper subdirectories
to avoid name clashes.

Signed-off-by: Simon McVittie <smcv@debian.org>
2020-06-16 17:58:02 +00:00
Simon McVittie e493be3844 scripts: Use special ${LIB} token for architecture-independence
On GNU/Linux systems, the literal string '${LIB}' in dynamic linker
paths expands to "lib", a biarch libQUAL directory such as "lib64", or
a Debian-style multiarch directory such as "lib/x86_64-linux-gnu".
If we're installing libraries to such a directory, and we have both
word-sizes' compatibility libraries available, then pw-pulse can
use LD_LIBRARY_PATH='/usr/${LIB}/pipewire-0.3/pulse' to make both
i386 and x86_64 programs load the correct version.

Signed-off-by: Simon McVittie <smcv@debian.org>
2020-06-05 13:40:50 +00:00
Simon McVittie 96eb6e4df8 scripts: Don't add an empty entry to LD_LIBRARY_PATH
LD_LIBRARY_PATH="/path/to/lib:" is interpreted as equivalent to
LD_LIBRARY_PATH="/path/to/lib:.", loading libraries from the current
working directory, which could lead to malicious libraries being loaded
if the current working directory is untrusted. To avoid this, only add
the current LD_LIBRARY_PATH to the new LD_LIBRARY_PATH if it is
actually set.

This commit also single-quotes the interpolated @VARIABLES@ so that
their values can contain shell special characters (other than single
quotes).

Signed-off-by: Simon McVittie <smcv@debian.org>
2020-06-05 13:40:50 +00:00
Wim Taymans 6ee9853133 jack: free old mem after we configure new mem 2020-06-05 13:02:56 +02:00
Wim Taymans 814b74265c jack: stop the thread loop before we destroy objects 2020-06-04 13:08:39 +02:00
Wim Taymans 253e304124 jack: destroy link proxy
Destroy the link proxy immediately so that we don't leak it.
The link is marked as 'linger' and will thus keep on living
even when our proxy is gone.
2020-06-04 12:59:55 +02:00
Wim Taymans 38cfa2d71d jack: fix leaks 2020-06-04 12:59:20 +02:00
Wim Taymans c546167ad3 require meson 0.49 2020-05-20 15:26:35 +02:00
Wim Taymans a898f21c87 improve debug
When we fail to read the eventfd, don't try to use the value.
2020-05-20 15:24:25 +02:00
Wim Taymans e6ccc72feb fix compiler warnings 2020-05-08 20:40:02 +02:00
Wim Taymans c117ca0899 jack: fix unlock 2020-04-30 16:18:40 +02:00
Wim Taymans 420c186124 jack: also sync position area with data thread 2020-04-30 16:15:22 +02:00
Wim Taymans 0fd46d057e remote: free io area after we set the new area
First set the new area, then destroy the old one. Otherwise the
data thread might still be using the old area and crash.
2020-04-30 16:13:50 +02:00
Wim Taymans 8141c92dde jack: free some objects 2020-04-30 13:11:01 +02:00
Wim Taymans 30d5a247e1 jack: improve locking
Protect the global metadata with a lock because we update this from
multiple clients. Avoid updating the metadata if it didn't change.

Add a simple lock to protect the session objects, they could be
accessed from the main thread or data thread. Use the simple lock
in methods that just read.

Use the new data loop invoke to make sure we sync the data update
with the data thread.

Stop the data loop when our position io is removed.
2020-04-30 12:57:56 +02:00
Wim Taymans d8d4e2f335 jack: make dummy server and net libraries 2020-04-29 16:32:15 +02:00
Wim Taymans 9f810d1bbc add pw-jack and pw-pulse to set the library path
pw-pulse and pw-jack set the replacement library path correctly
so that pulse and jack apps run on top of PipeWire.
2020-04-29 13:28:08 +02:00
Wim Taymans 293386c21a install replacement libraries in modules directory
Don't use a special name for the replacement libraries but install
them into the modules directory by default. Add an option to install
them into another location.

This way, we don't need to set up symlinks in development, distros can
choose to install them where they want and/or we can use symlinks or
LD_LIBRARY path to select the replacement versions.
2020-04-29 11:24:24 +02:00
Wim Taymans 83b30dcd3d jack: always initialize the port buffer
Init the port buffer after we create it, not only after we get a buffer
on the port.
Cleanup a little.
2020-04-28 14:15:49 +02:00
Wim Taymans 730c85e5b0 metadata: fix order of type/value 2020-04-27 12:54:14 +02:00
Wim Taymans 90e1eb1b22 jack: add more metadata keys 2020-04-27 12:22:32 +02:00
Wim Taymans aafd1e7298 improve debug
Improve log so that debug level 3 gives a reasonably readable overview
of what is going on.
2020-04-22 12:47:18 +02:00
Wim Taymans 2e06d0819b jack: only do transport when there is a driver 2020-04-21 16:15:45 +02:00
Wim Taymans 90054f5f3e jack: clear buffers when freeing the mixer 2020-04-21 15:53:43 +02:00
Wim Taymans 539296069d jack: implement more metadata API
Rework the metadata implementation without pw_properties to make
it easier to delete all subjects and implement the metadata API.
Remove metadata from all objects when they are destroyed.
2020-04-20 15:19:06 +02:00
Wim Taymans 16ca53e592 jack: implement get_property 2020-04-20 11:51:20 +02:00
Wim Taymans 0db9c4ef6b jack: use current buffer and samplerate 2020-03-18 17:52:48 +01:00
Wim Taymans e8cf29a7c8 jack: remove some hardcoded defaults
We get those from the server instead.
2020-03-18 17:42:11 +01:00
Wim Taymans 72d70b0f48 Add and fix some more warnings
Fixes #216
2020-03-17 11:37:56 +01:00
Wim Taymans cb7bfdf98a sprinkly SPA_LIKELY/UNLIKELY around 2020-03-16 12:52:28 +01:00
Wim Taymans 5273320825 jack: fix midi output 2020-03-15 08:45:56 +01:00
Wim Taymans b070752add context: don't load rtkit by default
Don't load and use rt-kit by default because it can cause sigkill in
the app, which is not good when it happens in a compositor.

Make the module profile a comma-separated list of profiles and make
it possible to explicitly load rtkit as well.

load the rtkit profile as well in jack.
2020-03-05 12:12:46 +01:00
Wim Taymans c4b2be2aad use true and false for boolean properties
So that it's easier to convert them to booleans in introspection
code later.
2020-03-03 18:17:46 +01:00
Wim Taymans 37a1dc5265 jack: use constant for type_id 2020-03-02 16:50:37 +01:00
Wim Taymans 73da0f8878 jack: use pthread cancel to stop the data thread
Activate the new option to pthread_cancel the data thread because
that is what jack apps expect.

Fixes #211
2020-03-02 15:47:52 +01:00
Wim Taymans bcdd47273d jack: call buffer_size callback right after activate
Some jack clients expect this callback right after activate.
Should fix jackaudiosink in gstreamer.
2020-02-25 18:02:49 +01:00
Wim Taymans a4d744e3cf jack: improve sample_rate callback
Call the sample rate callback when we install it and we know the
sample rate. Otherwise, the sample rate callback might never be
triggered.
2020-02-24 15:39:19 +01:00
Wim Taymans cde7fa797c jack: improve timemaster install
When we get the driver activation try to install ourselves as
timemaster.
2020-02-24 15:38:21 +01:00
Wim Taymans 9e44b957f0 jack: check arguments
Guard against some evil jack clients
2020-02-24 11:25:31 +01:00
Wim Taymans ea911f2e3f tweak buffers a little
JACK can handle 2 buffers at most, make the default buffer allocator
allocate 2 buffers when no params are given.
Prefer 2 buffers, it allows some form of async fill/consume
2020-02-19 10:17:00 +01:00
Wim Taymans b3d94cde87 jack: fix stride of midi
Midi has a stride of 1
Error when the number of buffers is too big
2020-02-18 18:03:30 +01:00
Wim Taymans 1f3cb3d207 jack: fix invalid unlink
Don't unlink the mix->link when freeing, it is only linked when
in the free pool.

Protect against invalid number of buffers that could corrupt our
state.
2020-02-18 17:37:02 +01:00
Wim Taymans e6c3619521 jack: don't try to consume port without data
Or else we handle old data.
2020-02-18 13:38:25 +01:00
Wim Taymans 905e5af058 jack: implement the jack_info_callback and function 2020-02-10 10:59:24 +01:00
Jan Koester 656c58fd98 jack: add error callback 2020-02-10 10:48:49 +01:00
Wim Taymans ee67ab9c04 client-node: keep target links in list
Don't allocate the links in an array because they might be moved
when the array is resized. Instead just use calloc and add them
to a list.

Make sure we update the list used in the real-time thread from a
safe context.
2020-02-07 16:45:58 +01:00
Wim Taymans 936c290cc1 plugins: fix the licence of alsa and jack libraries
It's all MIT
2020-02-07 15:43:13 +01:00
Wim Taymans 9acf592e9c jack: remove leftover printf debug 2020-02-07 13:33:59 +01:00
Wim Taymans ed1cf46c31 jack: add jack_get_video_image_size extension
Add a JACK PipeWire extension to get the video size of the DSP
pipeline and use this instead of the hardcoded values in the example.
2020-02-07 13:31:49 +01:00
Wim Taymans 14fbd4f520 jack: wait for transport
Wait for the transport to be configured before we exit from
client_open. We then have at least an activation or even a driver
set.
2020-02-07 13:30:24 +01:00
Wim Taymans ae4e17e9a2 Remove old LICENSE files and README 2020-02-07 13:24:06 +01:00
Wim Taymans 5c4be385ad jack: only append node id when name already taken 2020-02-05 10:27:37 +01:00
Wim Taymans 41b47e726e context: add some more defaults
Make a property to allow mlock and use it.
mlock in stream and filter when asked to mmap mem.
2020-02-04 17:09:41 +01:00