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.
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.
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
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
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
This also brings the advantage that all tools, examples, modules, components
can also be compiled standalone out-of-tree using libpipewire from the system
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.
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
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.
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
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
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.
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.
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.
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>
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.
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).
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
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.
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
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
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.
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
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#725Fixes#769
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
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.
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.
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
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.
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.
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>
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.
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.
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.
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.
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.
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>
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>
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>
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.
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.
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.
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.
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
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.
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.