Commit graph

2227 commits

Author SHA1 Message Date
Barnabás Pőcze
7cecb1567d spa: tests: remove double dot from names of test files
Previously, the configured test file would be named like the following:

  spa-include-test-spa_control_control_h..cpp

fix that by removing one of the dots.

Furthermore, use the already existing `find` object instead of
calling `find_program` one more time.
2021-06-16 19:45:27 +02:00
Wim Taymans
a90c86dd47 defs: reorganize the assert macros a little
Make a special Coverity version of spa_assert_se borrowed from
PulseAudio
NDEBUG now compiles the asserts to nop, except for the _se one.

See !755
2021-06-11 20:05:25 +02:00
Wim Taymans
a6b687ee98 audioadapter: proxy Latency param from follower port 2021-06-10 23:42:05 +02:00
Wim Taymans
826f52344f spa: properly re-encode the keys and string values
Instead of pasting quotes around them.
2021-06-10 16:32:16 +02:00
Wim Taymans
1c513464c8 alsa: strip and add the _alibpref from device names
Strip the _alibpref from the device name, it contains a local counter
to identify the ucm card that should remain internal. We set a flag on
the device to notify of this.

Re-add the _alibpref of the local card to the device name if the
device was flagged.

See #1286
2021-06-10 15:36:26 +02:00
Wim Taymans
283e13629c alsa: use the local alibpref of the card
The _alibpref of the device was created in the session manager and
does not match our local _alibpref. Patch the device name with
the local _alibpref to make things match.

See #1286
2021-06-10 13:25:54 +02:00
Wim Taymans
23a0f29d48 acp: don't use the card index for alibpref
The alibpref fallback does not contain the card number but it is
a local counter instead. Just check if it starts with something in
case the alsa library is not patched to return _alibpref.
2021-06-10 13:25:53 +02:00
Wim Taymans
d8e0176bcf alsa: open UCM only once.
See #1286 #1269
2021-06-10 09:58:11 +02:00
takooakes
51d01b33c8 Expose output select for Soundblaster cards
Enable selecting Speakers or Headphones for Soundblaster cards.
This switch was name Output Select.
2021-06-10 07:39:04 +00:00
Peter Hutterer
18b3efa2ed spa: make two headers compatible with older gcc-c++
c++ 7.5.0 can only initialize structs with continuous members, so let's
initialize the fields explicitly to NULL.

Fixes #1284
2021-06-10 15:19:15 +10:00
Peter Hutterer
5cf3c28fa4 config.h is a local header, not a system one
Change the #include accordingly, that's what we use in the rest of the tree
too.
2021-06-10 09:04:16 +10: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
Peter Hutterer
5ba43b8349 audioconvert: add config.h to include directories
Some of the files here #include "config.h"
2021-06-10 09:04:16 +10:00
Peter Hutterer
e38cc427bf spa: fix indentation in audioconvert/meson.build
Was partially using spaces, partially 2-space tabs. Use 2 spaces only and fix
the few lines where the indentation was completely out of whack.
2021-06-10 09:04:16 +10:00
Wim Taymans
eb8546a682 json: also escape '/' as required by JSON 2021-06-09 18:03:42 +02:00
Wim Taymans
4b6fb5e96a v4l2: report latency 2021-06-09 17:15:34 +02:00
Peter Hutterer
9a65d90e88 test: move the spa tests to pwtest
Move the spa tests to the pwtest framework. The pod tests have only been
wrapped in the function callers, they don't use the variuos pwtest helpers -
too much work for very little gain here. Can be done incrementally if needed.

Note that this removes the spa tests from the installed tests. Arguably,
installing those tests was unnecessary anyway since they are static binaries
and don't load anything. So having them installed runs the same tests as
having them run in the source tree.

Goal for the pwtest framework is to allow for installed tests, just not there
yet.
2021-06-09 18:00:59 +10:00
Peter Hutterer
7909c99ead test: convert two spa tests to pwtest 2021-06-09 18:00:39 +10:00
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
4c64afc4ff acp: add hw-mute and hw-volume as properties 2021-06-09 09:41:49 +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
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
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
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
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
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
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
Peter Hutterer
98503a84b3 spa: fix an C++ invalid type conversion
In file included from spa/tests/test-cpp.cpp:49:
../spa/include/spa/param/latency-utils.h: In function ‘int spa_latency_parse(const spa_pod*, spa_latency_info*)’:
../spa/include/spa/param/latency-utils.h:95:25: error: invalid conversion from ‘int’ to ‘spa_direction’ [-fpermissive]
   95 |         info->direction &= 1;
      |         ~~~~~~~~~~~~~~~~^~~~
      |                         |
      |                         int
2021-06-04 17:57:10 +10:00
Wim Taymans
3fcb9c44ef spa: use strtoull for atou32
On machines with a 32 bits long, converting a negative value will
still result in  v == (uint32_t)v and the unit test will fail.
Extend to 64 bits and strtoull to reject negative values in atou32.
2021-06-03 11:40:27 +02:00
Wim Taymans
0b0a4897d6 spa: use unsigned long for strtoul result 2021-06-03 11:18:57 +02:00
Peter Hutterer
4d45182801 spa: add SPA_FOR_EACH_ELEMENT for array traversal 2021-06-03 07:25:32 +00:00