Commit graph

2693 commits

Author SHA1 Message Date
Wim Taymans
c474846c42 loop: remove destroy list
Now that sources can't be dispatched anymore after a _remove, we don't
need to keep the destroy_list anymore and we can free the source
immediately.

See #2114
2022-02-08 10:18:02 +01:00
Wim Taymans
45d911641b loop: handle remove while dispatching better
Keep the array of dispatched sources around in the loop. When a source
is removed while dispatching, set the data to NULL so that we don't try
to deref the source again or call its function.

Fixes #2114
2022-02-08 10:17:13 +01:00
Wim Taymans
a16cd95593 spa: move debug log defines to one place
Use spa_debug to debug formats.
Make debug go to stdout by default.
2022-02-07 17:00:38 +01:00
Wim Taymans
8c10080324 pulse-server: make sure we don't exceed maxlength
Make sure the various buffer attributes don't exceed maxlength.
Add some SPA_ROUND_UP and SPA_ROUND_DOWN macros.

Fixes #2100
2022-02-04 11:59:57 +01:00
Barnabás Pőcze
cc73053512 treewide: meson.build: use feature.allowed()
Since meson 0.59.0, a feature object has an `allowed()`
method which returns true when the feature is set to
'enabled' or 'auto'.

Utilize that instead of the previously used

  not feature.disabled()
2022-02-04 00:15:59 +01:00
Barnabás Pőcze
15e7a61aa7 treewide: only define feature macros when the feature is available
Most feature checks already use #ifdef, and do not care about
the value of the macro. Convert all feature checks to do that,
and simplify the meson build scripts by replacing

  if cond
    cdata.set('X', 1)
  endif

with

  cdata.set('X', cond)
2022-02-04 00:15:59 +01:00
Pauli Virtanen
97a5fe80c1 spa/alsa-udev: fix /proc/asound handling without CONFIG_SND_VERBOSE_PROCFS
For kernels compiled with CONFIG_SND_VERBOSE_PROCFS=n, the pcmXX
/proc/asound entries do not exist.  In that case, the "device busy"
check cannot be done, but we should still check existence of PCM devices
correctly.

Count the number of PCM devices from /dev/snd, which should work also
without /proc/asound or /sysfs/class/sound.
2022-02-03 18:28:25 +00:00
Wim Taymans
76417fd2a6 alsa: use MONOTONIC clock for tstamp 2022-02-03 16:22:09 +01:00
Wim Taymans
7480d09589 alsa: update test-timer
Remove the bandwidth reduce, we don't do that.
Clamp large errors.
Add htimestamp mode, which seems more stable.
2022-02-03 16:22:09 +01:00
Pauli Virtanen
b369401c8e spa/alsa-udev: retry busy devices on inotify close event, not timeout
Alsa device acp probe results to missing profiles if some PCM devices
are busy. Currently, we retry based on a timeout and give up after some
retries. However, exposing cards with missing profiles is never
useful.

Never expose cards if some PCM devices are busy. Instead, retry adding
device on inotify fd close events, which arrive when some process has
closed a PCM device.

When probing for devices in alsa-udev, check via /proc to avoid inotify
busy loop.
2022-02-02 16:43:54 +00:00
Pauli Virtanen
f32935ec8a bluez5: sco-sink: fix behavior as follower
When sink is follower, and no data to write is available, it should not
schedule a timeout, but wait for the driver to wake it up again.

Fixes process ending up busylooping in data thread as follower, under
some conditions.

Also, clean up the code to be more clear about timeout logic. Just loop
directly instead of setting timeout 1, if we need to just flush more
immediately.
2022-01-31 21:59:39 +02:00
Pauli Virtanen
4bb3ff739a bluez5: keepalive A2DP source / SCO AG dynamic node transports
When acting as SCO AG / A2DP sink, the remote end should decide when to
close the connection.  This does not work currently properly, because
stopping sources/sinks releases the transport, which causes it to go
idle, and which then destroys dynamic nodes.  The sources/sinks should
not cause the transport to be released.

Implement keepalive flag for spa_bt_transport, such that
spa_bt_transport_release does not actually release the transport when
the refcount reaches zero. Set the flag for dynamic nodes when the
transport becomes pending (remote end connects) and unset the flag when
idle (remote end disconnected, or dynamic node removed).
2022-01-31 21:59:39 +02:00
Pauli Virtanen
a2a5012cb2 bluez5: backend-native: set transport volume on create
Initial transport volume was being set incorrectly to max for new
transports. This is usually masked by route restore, but not always.
2022-01-30 22:00:32 +02:00
Pauli Virtanen
3ffc0452a7 bluez5: backend-native: fallback switch msbc->cvsd on EOPNOTSUPP
If MSBC connect() fails with EOPNOTSUPP, trigger codec renegotiation.

When PW is AG, this also removes the msbc profile.
2022-01-30 22:00:32 +02:00
Pauli Virtanen
1da23145df bluez5: probe adapter msbc capability via hci commands
Using a probe connection to determine adapter msbc capability causes
problems on some adapters (ff8c3d2, 84bc0490a5, 717004334b,
pipewire#2030) and seems to be a bad idea.

Go back to probing for transparent msbc transport capability via HCI
commands. bluetooth/hci.h may be deprecated later, but for now it's
better to go back to using it.  (In practice, adapters not supporting
esco appear to be fairly rare; kernel commit in 2013 refers to "older
devices", so if we can't use HCI, assume the adapter supports the
necessary modes.)
2022-01-30 22:00:32 +02:00
Valentin Hăloiu
483831e514
bluez: handle non-hexadecimal XAPL version strings 2022-01-29 21:13:45 +00:00
Wim Taymans
92198e4d0d spa: clamp required alignment to cpu alignment
pipewire will allocate buffers aligned to the max alignment required for
the CPU. Take this into account and don't expect larger alignment.

Fixes a warning in mixer-dsp when the CPU max alignment is 16 but the
plugin requires 32 bytes alignment for the AVX2 path (that would never
be chosen on the CPU).

See #2074
2022-01-28 11:49:06 +01:00
Maciek Borzecki
78a239a370 spa/bluez: enable sbc-xq for JBL Endurance Run BT headset
Enable SBC-XQ codec for the JBL Endurance RUN BT headset. The codec worked well
with pulseaudio and works equally well with pipewire.

Signed-off-by: Maciek Borzecki <maciek.borzecki@gmail.com>
2022-01-28 07:58:22 +00:00
Wim Taymans
398b04e145 spa: fix the event and command type info
The object id needs to have the object type as the parent.
2022-01-27 12:34:04 +01:00
Wim Taymans
f2906a26f1 alsa: sync TI2902 conf with pulseaudio
Adn reenable it to see if it improves things again.
2022-01-27 11:10:24 +01:00
Wim Taymans
4660e16d5b meson: enable some more warnings
Fix some warnings
2022-01-27 11:07:17 +01:00
Gleb Popov
6c5c3dc090 Fix build on recent FreeBSD 13-STABLE 2022-01-26 14:37:19 +03:00
Gleb Popov
44b18b86cd Fix build on FreeBSD by defining bswap_64. 2022-01-26 14:37:19 +03:00
Fabrice Fontaine
8d9dc023ac spa/meson.build: add atomic_dep dependency
Commit fa64d93e64 moved the atomic_dep
from pipewire-jack to pipewire_dep however atomic_dep should also be
added to spa_dev to avoid the following build failure when building
examples (which don't depend on pipewire_dep):

FAILED: spa/examples/adapter-control
/home/buildroot/autobuild/instance-0/output-1/host/bin/sparc-linux-gcc  -o spa/examples/adapter-control spa/examples/adapter-control.p/adapter-control.c.o -Wl,--as-needed -Wl,--no-undefined -Wl,-O1 -Wl,--start-group -lintl -ldl -pthread -lm -Wl,--end-group
/home/buildroot/autobuild/instance-0/output-1/host/opt/ext-toolchain/bin/../lib/gcc/sparc-buildroot-linux-uclibc/10.3.0/../../../../sparc-buildroot-linux-uclibc/bin/ld: spa/examples/adapter-control.p/adapter-control.c.o: in function `spa_graph_node_trigger':
adapter-control.c:(.text+0xdf4): undefined reference to `__atomic_fetch_sub_4'

Fixes:
 - http://autobuild.buildroot.org/results/192f40a5c6e05fc11507494e19db52a47082fc35
2022-01-25 21:39:04 +01:00
Wim Taymans
8d37451fb8 alsa: ensure period_size is not 0 2022-01-24 12:44:16 +01:00
Pauli Virtanen
a67f38f790 spa/v4l2: better device product names on current kernels
udev/kernel sometimes give "Video Capture N" as ID_V4L_PRODUCT, which is
bogus as a device product name.  The ID_MODEL* field seem to always have
a sensible product name.

Get device.product.name always from ID_MODEL*, and use ID_V4L_PRODUCT
only as the last fallback.
2022-01-23 12:57:11 +00:00
Pauli Virtanen
e1bc1c4569 alsa-udev: postpone emitting if pcm devices are busy, retry later
There is a race condition on udev permission changes (e.g. switching
VTs), when pipewire from one user closes devices, and the other process
from second user tries to open them.  The close/open are not ordered, so
opening a device may fail in alsa-acp-device.c resulting to missing
devices/profiles.

Address this by trying to open devices already in alsa-udev.c. If some
devices are busy, do not emit the device info yet, but retry after a
timeout.  If it still fails, go ahead emitting the device, even if some
profiles may be missing.  The retry with delay should be enough to solve
the race almost always.
2022-01-23 12:33:57 +00:00
Pauli Virtanen
0a55085b14 bluez5: allow setting initial profile to off
This is useful if the session manager wants to set the profile itself,
and has special handling for the off profile.
2022-01-22 20:01:00 +00:00
Wim Taymans
5b3bc4e80e alsa: first start monitor then enumerate devices
So that we can catch the SOUND_INITIALIZED update between enumerating
devices and starting the monitor.This fixes a races in detecting devices.

Thanks to Matthias Fend for finding this.

Fixes #2046
2022-01-21 10:50:13 +01:00
Pauli Virtanen
ee257b148b bluez5: deal with adapters appearing after devices
Devices may appear before or after their adapter does on BlueZ DBus
interface.

When an adapter appears, search the device list, and associated its
devices with it.
2022-01-21 00:01:28 +02:00
Wim Taymans
6a892c27b0 audioconvert: block volume updates when disabled 2022-01-20 20:07:05 +01:00
Pauli Virtanen
a4b1e4c42a bluez5: don't crash in battery_remove
If device has no adapter, then there's no battery provider.
2022-01-20 18:18:09 +00:00
Pauli Virtanen
dda65b95af bluez5: maintain transport->device_list properly
If device != NULL, the transport must be in its transport_list.
2022-01-20 18:18:09 +00:00
Pauli Virtanen
f2630ed6fc bluez5: require adapter before profile connect & after
All exposed bluez devices should have an adapter specified at all times.
Adapter-less devices appear in some race conditions in BlueZ interface.

Require device has non-null adapter, in all cases before adding any
profiles (which exposes the device), and reject BlueZ profile connection
attempts in that state.

If an adapter gets removed by BlueZ, remove also all its devices, so
that device->adapter pointers stay valid.
2022-01-20 18:18:09 +00:00
Pauli Virtanen
870cd0136a spa: allow spa_dict.items to be NULL for zero items
For dicts with zero items, don't dereference dict->items, or give it to
qsort or bsearch where passing in NULL is not allowed.
2022-01-20 20:04:18 +02:00
Wim Taymans
aa128ed489 spa: make common function to find type from short name 2022-01-20 18:08:30 +01:00
Wim Taymans
ba7e5d619d audioconvert: add option to disable channelmix 2022-01-20 18:08:30 +01:00
Wim Taymans
cb077975bc alsa: remove TI 2902 rule, it seems to break things 2022-01-19 20:31:09 +01:00
Barnabás Pőcze
d2114c3f2e spa: audioconvert: fix allocation size calculation
Currently, the code allocates

  sizeof(header) * sizeof(item) * n_items

bytes instead of the more appropriate

  sizeof(header) + sizeof(item) * n_items

Fix that by simply changing the first multiplication to addition, and
furthermore, use a flexible array member instead of a zero-sized array.

Found by clang-tidy.
2022-01-19 02:01:07 +01:00
Wim Taymans
6ece5d810c loop: invoke immediately when loop is not running
Or else we might never get our callback called or worse, block forever,
waiting for the response.
2022-01-18 20:03:01 +01:00
Wim Taymans
18607ee5e3 resample: implement resample disable
Implement the option to completely disable the resampler.
2022-01-18 18:05:36 +01:00
Wim Taymans
3e73f05af4 audioconvert: expose resampler properties
Expose the resampler PropInfo and Props and params as well. Mostly
useful for updating the resample quality at runtime.
2022-01-18 17:43:44 +01:00
Wim Taymans
5010125452 alsa: make internal latency configurable with params 2022-01-18 11:46:08 +01:00
Wim Taymans
5ebbe09371 pw-cli: move json to pod code to SPA 2022-01-18 10:38:11 +01:00
Pauli Virtanen
67dcc0d291 bluez5: don't create device if adapter is missing
BlueZ may be missing adapter information for devices in some cases.
Ignore devices without specified adapter.
2022-01-17 18:54:10 +00:00
Wim Taymans
dec7f7a608 merger: also reconfigure when monitor changes
So that monitor ports are added/removed.
2022-01-17 16:28:06 +01:00
Wim Taymans
d8c867b515 alsa: improve rate selection
Make sure we don't select an invalid rate when the default is set or
when the card is already opened in some unsupported rate.

See #1975
2022-01-17 14:56:45 +01:00
Barnabás Pőcze
ec465966bc treewide: meson.build: simplify get_variable() calls
Since 01c6fd0a88 the
minimum required meson version is 0.59.0, and since
meson 0.58.0, `get_variable()` on a dependency object
accepts a positional argument. The "type" of variable
(internal, pkgconfig, etc.) in that case does not need
to be specified explicitly.
2022-01-17 08:28:53 +00:00
Barnabás Pőcze
e34cbcb92c spa: tests: meson.build: specify check argument for run_command()
The include tests are not critical, hence there is
no need to halt the build if, for some reason, `find` fails.

See https://github.com/mesonbuild/meson/issues/9300
2022-01-17 08:28:53 +00:00
Barnabás Pőcze
02e76bad8e spa: tests: meson.build: specify configuration inline
Do not construct a `cfg_data` object, instead, simply pass
a dictionary to `configure_file()`.
2022-01-17 08:28:53 +00:00