Commit graph

6609 commits

Author SHA1 Message Date
Peter Hutterer ed3f882fa9 test: add the pwtest test framework
Heavily inspired by libinput's litest framework (built around check), this is
a from-scratch framework that simplifies adding tests for various parts of
pipewire. See the pwtest.h documentation for details but the basics are:

- PW_TEST() and PWTEST_SUITE() specify the tests to be run
- Test are run in forked processes, any errors/signals are caught and printed
  to the log
- Tests have a custom pipewire daemon started on demand to talk to [1]. The
  daemon's log is available in the test output.
- Output is YAML to be processed into whatever format needed

[1] There are limits here, since we can't emulate devices yet there is only
so much we can rely on with the daemon.
2021-06-09 18:00:06 +10: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
Peter Hutterer fee4d0eae1 spa: switch the include header test to C++ by default
If we have a C++ compiler, compile all the #include tests with that - it'll
pick up any issues that a C compiler will pick up anyway. This saves us from
having a separate C++ compiler test and it'll test each header separately for
C++ compatibility..
2021-06-09 07:43:46 +00:00
Wim Taymans 750cafd7d1 context: use pw_context_destroy() in error cases
Make sure we free all the resources of a context when it can't be
created.
2021-06-09 09:41:50 +02:00
Wim Taymans c12bdb8c6c pipewire: cleanup on error
To make leak checks more accurate.
2021-06-09 09:41:50 +02:00
Wim Taymans 4c64afc4ff acp: add hw-mute and hw-volume as properties 2021-06-09 09:41:49 +02:00
Wim Taymans e857856be7 0.3.30 2021-06-09 09:14:11 +02:00
Wim Taymans db245fd0ce context: override the CORE_NAME in context
Override the CORE_NAME using the env variable in the context instead
of pipewire.c. This avoids needing the _add_string() property method.
Remove the properties_add_string() method, there are new improved
plans for property parsing and merging: See #207
2021-06-08 16:56:22 +02:00
Peter Hutterer f3a98debec spa: don't run the spa_scnprintf abort test under valgrind
valgrind doesn't know we expect this to fail, so let's not confuse it
2021-06-08 20:21:50 +10:00
Peter Hutterer 10270621c2 spa: fix a missing include 2021-06-08 20:21:50 +10: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
Evgeniy Khramtsov 98ce5acb69 utils: define SIGABRT for FreeBSD 2021-06-07 20:53:16 +03:00
Wim Taymans 8132c4e2b4 acp: add fallback alibpref just in case
Until we are sure that everybody has a recent enough version of
alsa-lib 1.2.5
2021-06-07 13:04:03 +02:00
Wim Taymans 1f85d06317 module-adapter: clear bound-resource when destroyed
So that we don't reference it anymore or try to remove the listener.
2021-06-07 12:57:09 +02:00
Barnabás Pőcze b6c6a21747 pipewire: module-adapter: remove resource listener
Unregister the resource listener when the node is going
away to avoid use-after-free issues.

Fixes #1276
2021-06-07 10:54:19 +00:00
Barnabás Pőcze bec615971c spa: utils: hook: use tab 2021-06-07 10:54:19 +00:00
Wim Taymans 16674a07a5 logger: improve formatting
Make enough room for the timestamp to include the last ]
Add a space before the actual log line.
2021-06-07 12:52:21 +02:00
Peter Hutterer 83f8a2896f alsa-mixer: drop the VALGRIND_HAVE_MEMCHECK hacks
Cause for this was a missing ioctl, fixed in 2014. See valgrind commit
4ef60ef1029e6933773b7de9966ece7185129d84
2021-06-07 10:44:27 +00:00
Peter Hutterer b6e27822e5 pipewire: use RUNNING_ON_VALGRIND to determine if we're in valgrind
This removes the use of the VALGRIND environment variable
2021-06-07 10:44:27 +00:00
Peter Hutterer d9cc1a25f1 Include the valgrind headers in our tree
These headers are designed for including in the project. So the user doesn't
need to install valgrind-devel and we don't have to worry about whether the
headers are available or not.
2021-06-07 10:44:27 +00:00
Peter Hutterer d08d989412 spa: add a test for missing includes
For each header in the spa directory, generate a compilation test that
includes just that header. This way we can pick up missing #includes.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-06-07 10:31:17 +00:00
Peter Hutterer 6499f96396 spa: add missing #includes 2021-06-07 10:31:17 +00:00
Peter Hutterer c049689884 logger: set linebuffering for the log
Set this once during setup so we don't have to remember to call fflush() after
each logging operation.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-06-07 10:29:36 +00:00
Peter Hutterer 1c083a6d69 logger: clamp the log time to 5 digits
In the interested of making the logs narrower, let's drop some digits from the
clock_gettime() seconds value. Clamping to 5 digigts, this gives us just under
28h before we wrap which is likely good enough for debugging.
2021-06-07 10:29:36 +00:00
Peter Hutterer 9737d6e3da logger: align debug messages better
Taken from https://gitlab.freedesktop.org/pipewire/pipewire/-/merge_requests/655#note_912691
2021-06-07 10:29:36 +00:00
Peter Hutterer 1a710cad3c logger: reduce the number of appending snprintf calls
Write the timestamp and location into a temporary buffer, then include them in
the message print. This makes bugs involving size vs length less likely and
provides a fixed limit for how much space the filename can take in the
message.
2021-06-07 10:29:36 +00: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 9a90030596 pw-cli: fix command parsing after pw_split changes
Don't assume anything about the way the split function maintain the
state.
2021-06-07 11:17:45 +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
Peter Hutterer db989d851d spa: auto-generate the cpp compilation test
Replace the manually maintained header list with a Python script that finds
all header files and includes them in order. This adds another 25 or so
previously headers to the C++ compilation tests.
2021-06-07 07:20:21 +00:00
Peter Hutterer fb75367975 spa: add a missing include
../spa/include/spa/node/node.h:639:14: error: ‘ENOTSUP’ was not declared in this scope
2021-06-07 07:20:21 +00:00
Peter Hutterer 48eadac1f1 logger: switch snprintf to spa_snprintf
The two are functionally equivalent, but spa_snprintf never returns a value
higher than the size, preventing memory corruption where our input string
exceeds the target buffer size (see c851349f1).

Niche case: we can no longer differ between real overflow and fitting an
N-byte string into an N+1 sized buffer, we now get a "...truncated" message
now for log messages of exactly 999 bytes long.
2021-06-07 15:37:51 +10:00
Peter Hutterer 47c173c83f spa/util: add spa_scnprintf to use over snprintf
Wraps the glibc snprintf/vsnprintf calls, but aborts if given a negative size
and zero-terminates the buffer on error.

The returned value is clipped to size - 1 which avoids issues like the one
fixed in c851349f17.
2021-06-07 15:16:35 +10: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
Arun Raghavan 08daf3f4f4 pulse-server: Add a module-echo-cancel
Fairly straightforwad module to load libpipewire-module-echo-cancel
2021-06-05 17:54:02 +00:00
Huang-Huang Bao 8c42e6aecb alsa,bluez5: handle SPA_PARAM_Latency in port_set_param
Simply return 0 instead of -ENOENT.

Fixes #1262
2021-06-05 17:52:40 +00:00
Huang-Huang Bao d3fcc0a37a bluez5: correct parameter names in spa_bt_sco_io_create declaration
From its definition and parameters passed to its function call, the 3rd parameter
is read_mtu and the 4th is write_mtu.

Fixes #1256
2021-06-05 15:17:10 +00:00
Barnabás Pőcze 4e5b20b1f5 meson.build: add devenv
Add meson devenv with the appropriate env variables
set up. Largely based on pw-uninstalled.sh
2021-06-05 15:49:17 +02:00
Barnabás Pőcze b433a6920f pw-uninstalled: override ALSA_PLUGIN_DIR 2021-06-04 21:33:00 +02:00
Barnabás Pőcze afd92a4272 pw-uninstalled: remove pipewire-pulse from library path
The library has been replaced by a PulseAudio server
reimplementation.
2021-06-04 21:33:00 +02:00
Wim Taymans 431bcb6805 pw-uninstalled: set PKG_CONFIG_PATH 2021-06-04 13:53:57 +02:00
Wim Taymans a2cb5f3394 properties: try to keep full doxygen docs out of headers
Try to keep the full docs out of the headers and into the .c file.
A small short blurb in the header is enough for quick lookups.
Also try to use a regular comment to not confuse the doc system.
2021-06-04 12:08:23 +02:00
Peter Hutterer 2e6621fae0 daemon: use getenv(PIPEWIRE_CORE) for the core.name if it exists
As documented in pipewire/keys.h, PIPEWIRE_CORE is supposed to overwrite the
default value.
2021-06-04 08:58:18 +00:00
Peter Hutterer f775547528 pipewire: merge, not overwrite the context.properties from the config file
Any values already set in the properties list (e.g. from earlier getenv())
calls should not be overwritten by the value in the config file.
2021-06-04 08:58:18 +00:00
Peter Hutterer b179e81070 pipewire: add pw_properties_add_string()
Equivalent to the existing pw_properties_update_string() but only adds new
properties from the given string, it doesn't overwrite existing ones.
2021-06-04 08:58:18 +00:00
Peter Hutterer 81cc466752 spa: the cpp test is a compilation test only
No point installing or even running it, we don't do anything here.
2021-06-04 18:46:29 +10:00
Peter Hutterer a71e68e945 spa: add missing header guards and extern C define for spa/pod/filter.h 2021-06-04 18:46:29 +10:00
Peter Hutterer a179e0fecd spa: fix a C++ typecast warning
void* cannot be automatically type-casted so let's do this explicitly.

../spa/include/spa/param/latency-utils.h: In function ‘spa_pod* spa_latency_build(spa_pod_builder*, uint32_t, const spa_latency_info*)’:
../spa/include/spa/pod/builder.h:651:1: error: invalid conversion from ‘void*’ to ‘spa_pod*’ [-fpermissive]
2021-06-04 17:57:11 +10:00
Peter Hutterer 3332e271be spa: fix compiler warnings about missing braces in initializer
First element is a spa_list, so {{0}} it is.

../spa/include/spa/node/utils.h:98:40: warning: missing braces around initializer for ‘spa_list’ [-Wmissing-braces]
   98 |         struct spa_hook listener = { 0 };
2021-06-04 17:57:11 +10:00