Commit graph

3674 commits

Author SHA1 Message Date
Wim Taymans
83d2e85f49 parser: add extra check to make coverity happy
Fixes !1473
2023-04-20 12:32:07 +02:00
Pauli Virtanen
11df633b9b bluez5: media-source: transport not started is not an error
Transport not being started should not be considered IO error in
produce_buffer.
2023-04-18 23:30:22 +03:00
Pauli Virtanen
b619616c2a bluez5: media-sink: don't fail A2DP duplex sink if remote idles
Don't emit node error for A2DP duplex sink channel, or when BAP server.
These can occur under normal conditions (remote side suspends
transport), and are not errors.
2023-04-18 22:29:48 +03:00
Wim Taymans
b59766c3d1 v4l2: add support fot G_CTRL
Get the current values of the controls and add those to the Props.

Emit a Props param changed event when we update properties.
2023-04-18 16:27:55 +02:00
Wim Taymans
3b3146e852 examples: fix type of getopt_long return value 2023-04-18 09:48:19 +02:00
Wim Taymans
f0003b702c logger: add special stdout and stderr filenames
Add special stdout and stderr filenames to redirect the log to those
targets with setlinebuf.
2023-04-18 09:37:39 +02:00
Wim Taymans
312af1103e support: don't set linebuf on stderr
Don't set linebuf on our stderr fallback file.

Fixes #3164
2023-04-17 21:22:26 +02:00
Wim Taymans
bf1b3bb157 audioconvert: handle recursive Props set_param
When the node receives a set_param Props, it calls the follower
set_param implementation. If that one calls set_param again on the
adapter, discards the original set_param.

This makes it possible for the follower to intercept the Props param and
set a modified version on the converter. This can be used to intercept
volume changes.
2023-04-17 16:12:35 +02:00
Wim Taymans
e8c5c1bb97 alsa: hopefully fix compilation on ubuntu CI 2023-04-17 10:05:54 +02:00
Pauli Virtanen
9d7d3599db bluez5: output silence if no data for some ISO sinks
When a sink contributing to an ISO CIG does not have data, output
silence for it, as long as at least one sink in the CIG is running.
Only if writes to sockets fail, pause all streams to reset
synchronization.

This way we write exactly the same number of packets for each CIS at the
same time, which probably is the best tested configuration in BT
adapters and devices. We also don't then have to pause output if some
sinks are not running or miss their timing, as we generate silence on
the fly.

When using iso-io, have it initialize the codec instance, and have
media-sink uses that instance, so that silence and actual audio are
encoded with the same codec.
2023-04-14 22:29:03 +03:00
Pauli Virtanen
2d1b02b5a2 bluez5: wait for all pending transports in CIG before marking active
Mark transports in CIG active only after all acquires are completed, so
that all iso-io are present before sinks are started.
2023-04-14 22:29:01 +03:00
Wim Taymans
bd42e54c21 alsa: also define area_addr when version check missing 2023-04-14 19:59:18 +02:00
Wim Taymans
aa971187d7 alsa: include version.h to get the version macros 2023-04-14 19:49:44 +02:00
Wim Taymans
381283ad81 alsa: handle old alsa version
Out Ubuntu CI seems to have an older alsa version that doesn't have
snd_pcm_channel_area_addr so include it here.
2023-04-14 19:25:51 +02:00
Pauli Virtanen
a8770d501c bluez5: fix glib signal disconnect
Disconnect glib signal in the right way, silencing a glib warning.
2023-04-14 20:06:57 +03:00
Wim Taymans
ea7781d7d0 alsa: fix area pointers
We should use the first and step fields to get to the first byte in the
area.

See #3069
2023-04-14 17:52:26 +02:00
Wim Taymans
916f1cdfbf Revert "alsa-mixer: allow to re-attach the mixer control element"
This reverts commit b554fc20e9.
2023-04-14 16:32:18 +02:00
Wim Taymans
0b83dd61fc aec-webrtc: support beamforming 2023-04-13 15:52:30 +02:00
Wim Taymans
a66d5b90f9 Revert "alsa: UCM conflicting devices changes"
If needs some more work

This reverts commit aae770f18b.
This reverts commit 2216956e05.
This reverts commit 1d3c4501ef.
This reverts commit c7ca024607.
This reverts commit 8e4a5f5d5e.
This reverts commit 8b20675ad1.
This reverts commit ebe6f8b51a.
This reverts commit 4b97da1277.
This reverts commit 7c46a656c7.
This reverts commit 96ed03e1fc.
This reverts commit 43770c533c.
This reverts commit ccb2fce054.
This reverts commit 93d0ddc8b3.
This reverts commit 815e8c8fa0.
This reverts commit 97b99a0f7c.
This reverts commit 7e4d87402b.
This reverts commit 168b3ee22c.
This reverts commit 5128cdba31.
This reverts commit 31cde774c5.
This reverts commit b02c8ba153.
This reverts commit 68ac72d098.
This reverts commit 96cfc9bc1a.
This reverts commit e2d642a20b.
This reverts commit 80fc80c343.
This reverts commit 3a68905c7c.
This reverts commit 7e64680a65.
This reverts commit 8d1e38a281.
This reverts commit 591188195c.
This reverts commit 973fe0cb79.
This reverts commit 4d08c9ad60.
This reverts commit 3dce92e580.
This reverts commit 6b5e232c5c.
This reverts commit b1286c62c9.
2023-04-12 13:05:08 +02:00
Pauli Virtanen
bb5d01068e bluez5: iso-io: larger idle time
Use larger idle time, so that it's bigger than transport latency, in
case that helps to reset synchronization on controller/device side.
2023-04-12 10:12:00 +00:00
Pauli Virtanen
facef4a6c6 bluez5: lc3: use high-reliability QoS defaults
Use the "high-reliability" values for QoS parameters instead of the
low-latency ones. Under some condition BlueZ does not pass on the
endpoint QoS values to us, in which case we may end up selecting bad
latency.
2023-04-12 10:12:00 +00:00
Pauli Virtanen
645822b30b bluez5: refresh device set leader when current one disconnects 2023-04-12 10:12:00 +00:00
Pauli Virtanen
5b55118e7f bluez5: media-sink: fix reference time vs. resampling delay
Determine correctly if we are resampling, and have the associated delay.

Add off-by-one sample adjustment to the resampling delay, which seems to
correctly align the resampled audio with non-resampled.
2023-04-12 10:12:00 +00:00
Wim Taymans
45b2983439 aec: add new init2 method to initialize with different formats
The WebRTC echo canceler can support different rates and channels for
the record, out and playback streams.

Add a new method to pass this config to the echo-canceler.
2023-04-11 16:54:11 +02:00
Pauli Virtanen
5d1782760c bluez5: media-sink: resync ISO streams on playback start
Resynchronize ISO streams on playback (re)start, so the stream positions
are aligned immediately.  This is better than relying on rate matching
to correct any offsets.
2023-04-10 14:50:42 +00:00
Wim Taymans
261fb64849 alsa: separate max_error and max_resync
Use a separate variable to hold the maximum amount of drift we allow
between driver and follower. Ensure this value is smaller than the max_error
and period size so that we have at most 1 period of drift.
2023-04-10 16:28:55 +02:00
Wim Taymans
30657abf28 alsa: also set period size when using IRQ mode
Use the graph duration as the period size even when we are not using
a batch device.
2023-04-10 16:07:24 +02:00
Wim Taymans
d59e1094cd alsa: fix capture timings and drift
Don't reschedule a timeout when we have less samples available than the
target but only reschedule when we have less that the required amount we
need to read. This ensures that we hover around the target level and the
timeouts/rate matching adapts correctly. Previously we would only rate
match if the have at least the target amount of samples, which would
then always result in a possitive rate adjustment and cause drift.

For capture, make sure that there is at least 32 samples of headroom
when we are not using IRQ mode to handle jitter in the timer wakeup.

For capture of batch devices this results in (for a 1024 quantum) a
target buffer fill level of 1024 + 512, and we will read if there are at
least 1024 samples available.

For non-batch devices we aim for a target buffer fill level of 1024 + 32
and read if there are at least 1024 samples available.
2023-04-10 15:02:29 +02:00
Wim Taymans
501a80b247 alsa: fix rate match when using IRQ
When using the IRQ, we are woken up based on processed samples so
compare expected and current clock times to rate match the clock.

Fixes #3144
2023-04-10 13:18:25 +02:00
Pauli Virtanen
882f9ad2b3 bluez5: emit BAP device set nodes as needed
Emit BAP device set nodes, which the session manager can use to combine
the sinks/sources of a device set to a single sink/source.

Emit the actual sinks/sources with media.class=.../Internal to hide them
from pipewire-pulse.

Add separate device set routes to the set leader device.  Other routes
of the set members will be marked as unavailable when the set is active.

Accordingly, return failure for attempts to set these unavailable
routes, so that volumes etc. of the "internal" nodes are only controlled
via the device set route.
2023-04-10 07:00:44 +00:00
Pauli Virtanen
1a44754f8d bluez5: wait for devices in the same set before emitting nodes
Emit nodes only after all devices in the same set are ready, or until
add timeout elapses.
2023-04-10 07:00:44 +00:00
Pauli Virtanen
d642569394 bluez5: parse device set information via dbus
Parse device set information from DBus, and link devices to each other
according to it.  Add signal for notifying about device set changes.
2023-04-10 07:00:44 +00:00
Pauli Virtanen
eca13ec230 bluez5: iso-io: get BAP interval from dbus, not getsockopt
For ISO server sockets, the QOS struct from getsockopt contains values
with different meaning from ISO client socket. Get the values via DBus
instead, which is right in both cases.
2023-04-10 07:00:44 +00:00
Pauli Virtanen
ae76789f24 bluez5: iso-io: ensure streams are initially marked idle
Mark streams idle when they are being stopped/started, so that the
pause-to-sync logic always triggers when they are added.
2023-04-10 07:00:44 +00:00
Pauli Virtanen
6e94487057 bluez5: set BAP channel location from transport if unset
If BAP codec configuration is mono channel with unspecified location,
set the channel position from transport location.

This in principle should be set in SelectProperties, but currently BlueZ
doesn't tell us that yet there, so we hack it up later on.
2023-04-10 07:00:44 +00:00
Pauli Virtanen
8f840e703b bluez5: lc3: number of blocks is not the number of channels
The number of channels is determined by Audio_Channel_Allocation.
One frame block contains all channels. (BAP v1.0.1 Sec. 4.2)

Fix the handling of frame blocks and counting of numbers of channels. We
support and configure only one frame block per packet.

Consider omitted Audio_Channel_Allocation to indicate MONO stream (see
BAP v1.0.1 Sec 4.3.2).
2023-04-10 07:00:44 +00:00
Pauli Virtanen
e4cd99f76f bluez5: add some debug for media-sink 2023-04-10 07:00:44 +00:00
Forest
252620a18d alsa-profiles: SB Audigy: stereo mixer paths
This is a follow-up to d5390c7, where we switched to the 'PCM' mixer controls
on Sound Blaster Audigy devices, since the ones we used before only work in the
stereo-to-all-speakers mirroring mode.

It turns out we do use that mode after all, but only in a couple of profiles.
Since returning those profiles to the default mixer path yields uneven volume
steps similar to #2934, we instead add a new mixer path just for that mode.
2023-04-09 12:20:26 -07:00
Forest
1e77a7cc51 alsa-profiles: SB Audigy: rename path config file
This makes the file name consistent with the other device-specific ones.
2023-04-09 12:14:39 -07:00
Forest
6939c1e4ee alsa-profiles: SB Audigy: remove absent elements
Some of the elements/keys that were copied from analog-output.conf are not
implemented by the Audigy driver, so we don't need to reference them.
2023-04-09 12:14:29 -07:00
Pauli Virtanen
772ff3365b bluez5: backend-native: add two missing OK HFP replies
We should reply OK to both AT+BIEV and AT+IPHONEACCEV.
2023-04-08 11:05:06 +00:00
Forest
d5390c7199 alsa-profiles: use SB Audigy PCM mixer controls
Creative Labs Sound Blaster Audigy cards (snd_emu10k1 driver) expose
mixer controls named 'PCM Front', 'PCM Rear', etc. in addition to the
more common 'Front', 'Rear', etc.  The latter seem to be intended for
a stereo-to-all-speakers mirroring mode that we do not use, and have
no effect when we adjust them.
https://docs.kernel.org/sound/cards/audigy-mixer.html

We therefore define a custom mixer path for Audigy devices, using the
PCM mixer controls.

This has been tested on an Audigy 5/Rx.  Based on a brief look at the
ALSA driver, I think all Audigy devices (vendor 0x1102, device 0x0004
or 0x0008) have the same PCM controls, making this change probably safe
for our existing Audigy udev rules.

Relevant kernel files:
sound/pci/emu10k1/emu10k1_main.c
sound/pci/emu10k1/emufx.c
include/sound/emu10k1.h

Fixes #2934
2023-04-07 21:15:38 +00:00
Sourav Das
8cf9986774 spa:bluez5: fix compilation
on lower bluez version, BT_ISO_QOS macro is not available
    So, need to check it also fixes the compilation.
2023-04-06 09:19:47 +00:00
Wim Taymans
463e723a1e test: add more lossless tests
Also test that S16->F32->S32 and U16->F32->U32 are lossless.
2023-04-06 10:00:17 +02:00
Wim Taymans
edf2062830 fix compilation 2023-04-05 19:53:33 +02:00
Wim Taymans
6dcf0027d8 audioconvert: implement mix/resample_disabled
Fail when resampling or channelmixing is required but disabled.
2023-04-05 19:51:16 +02:00
Ashok Sidipotu
805a1c61d9 adapter-control: avoid the divide by zero while generating sequence. 2023-04-05 16:33:09 +05:30
Ashok Sidipotu
7dbad54ae5 audioconvert: donot return errors in the volume ramp setparams
Also avoid the divide by zero while generating sequence.
2023-04-05 16:27:48 +05:30
Wim Taymans
74831aa967 support: add support for checking loop context
Add check for running the the loop context and thread.

Add checks in filter and stream to avoid doing things when not run from
the context main-loop because this can crash things when doing IPC from
concurrent threads.
2023-04-04 16:19:41 +02:00
Wim Taymans
f2be2923e6 thread: use pthread_equal to compare thread ids 2023-04-04 12:43:25 +02:00