Commit graph

2160 commits

Author SHA1 Message Date
Wim Taymans
9855e2b303 alsa: tweak capture follower
If the follower does not have enough data to capture, skip a cycle
instead of trying to capture and get an XRUN.

Tweak some limits a little.
2022-02-11 18:07:44 +01:00
Barnabás Pőcze
2c71282f16 spa: bluez: remove unused function
The `add_dict` function has not been used since
9785d99821. Remove it.
2022-02-10 23:20:47 +01:00
Julian Bouzas
e34d9d209a alsa: try to resume after suspend before recovering
Fixes no audio after suspending with some audio drivers.

See #2001
2022-02-10 16:57:58 -05:00
Wim Taymans
f636603844 alsa: pass current_time around in get_status()
Pass the current time around in various functions.
Make a higher precission htimestamp based get_delay() function. Seems to
work fine for playback but not for capturee.
2022-02-10 15:31:29 +01:00
Luis Correia
3cba294b65 Update texas-instruments-pcm2902.conf, add info about Behringer U-Phoria UM2 2022-02-09 20:58:20 +00:00
Wim Taymans
14d252ec9d alsa: try to resync on commit error
When we get a commit error, try to resync our pointers. This fixes a
problem of endless commit errors after a quantum change because it never
manages to resync properly.
2022-02-08 18:31:42 +01:00
Barnabás Pőcze
bf886ba209 support: also protect against recursive invocations
Add an extra private field to the source to store the pollevent of
the current iteration. This changes ABI but it seems an embedded source
is not used outside of our own plugins and the unit test doesn't test
this ABI case.

Whenever a source is removed, we can set the data field of the
pollevent to NULL so that it won't be handled in any iteration anymore.

Avoid dispatching the same event multiple times when doing recursive
iterations.

Add some more unit tests for this.

Fixes #2114
2022-02-08 17:21:10 +01:00
Alexandre BIQUE
0b637c3291 support: loop_enter/leave hardening
This commit adds a counter for loop_enter/leave and checks:

 - consecutive enter are used on the same thread
 - leave is used on the same thread as enter
 - at destruction, the enter_count must be 0
2022-02-08 12:02:50 +01:00
Wim Taymans
c346ee5e90 support: close log file when we opened it 2022-02-08 11:30:39 +01:00
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
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
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
44b18b86cd Fix build on FreeBSD by defining bswap_64. 2022-01-26 14:37:19 +03: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
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
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
Wim Taymans
c8d4cef2d2 alsa: remove unused properties and hardcoded values 2022-01-12 17:51:49 +01:00