Commit graph

3248 commits

Author SHA1 Message Date
Wim Taymans
365ebcda9b spa: ensure macro args are evaluated only once
In ROUND_UP and ROUND_DOWN
Make some better versions of the ROUND_DOWN_N and ROUND_UP_N
macros.

Fixes #2724
2022-09-30 16:24:26 +02:00
Wim Taymans
a145c42ec4 audioconvert: make separate noise functions
So that we can reuse optimized versions in unoptimized noise
functions.
Do allocation a little different so that we can align everything
from the start.
2022-09-29 21:36:06 +02:00
Wim Taymans
14028c67cd audioconvert: some optimizations 2022-09-29 21:36:06 +02:00
Wim Taymans
07fd063a0d pod: fix alignment check
Use the platform specific alignment for the spa_pod instead of 8.

Fixes things on 32 bits.
2022-09-29 17:06:54 +02:00
Wim Taymans
41fd8144f0 tests: relax test a little 2022-09-29 15:25:02 +02:00
Wim Taymans
e97a0a67d8 tests: use spa_assert_se for tests
Or otherwise they are compiled away
2022-09-29 15:05:16 +02:00
Wim Taymans
497c695d6f channelmix: optimize some more nXm cases
Loop though coefficients, when all are 0, clear the destination.
When only one coefficient is used, simply copy with volume.
Otherwise run the complete convolution.
2022-09-29 13:21:23 +02:00
Wim Taymans
a30b335beb channelmix: leave volume unchanged for unknown channel volumes
When we get an unknown number of channels, don't do anything, like it
used to be.
2022-09-29 12:44:42 +02:00
Wim Taymans
8a4091f578 tests: add unit test for n_m matrix 2022-09-29 12:36:49 +02:00
Wim Taymans
25cf4d0a31 channelmix: use volume/mute when no channel volumes
When setting a volume without channel volumes, use the volume/mute
instead of doing nothing.
2022-09-29 12:35:52 +02:00
Wim Taymans
b7928799e5 channelmix: fix normalization
Don't count the sum for unused matrix coefficients. When doing pairing,
we set the mask to ~0 and so we would otherwise count too much.

Apply normalization to the active matrix coefficients, not whatever the
loop variables end up being at the end of the loops.
2022-09-29 12:29:36 +02:00
Wim Taymans
3b507e062c channelmix: improve debug 2022-09-29 12:26:28 +02:00
Wim Taymans
c743f4936a audioconvert: use calculated random value
Use the calculated random value instead of making a new one.
2022-09-29 09:27:28 +02:00
Wim Taymans
637bc6f7c4 channelmix: add optimised NxM channelmix functions 2022-09-28 17:50:59 +02:00
Wim Taymans
10f1d545a7 audioconvert: handle NULL params 2022-09-28 12:14:52 +02:00
Demi Marie Obenour
1e848fc299 SPA POD parser: fix several integer overflows
This fixes several integer overflow problems in the POD parser, as well
as fixing a returns-twice warning from GCC and integer truncation
problems in SPA_FLAG_CLEAR and SPA_ROUND_DOWN_N.  The integer overflows
can result in a tiny POD being treated as a huge one, causing
out-of-bounds reads.
2022-09-27 10:21:17 +00:00
Wim Taymans
0e4df09e53 audioconvert: add peaks test 2022-09-27 12:14:43 +02:00
Wim Taymans
a579fc49ba audioconvert: move peaks functions to separate file
Make a peaks finder helper and use it in the peaks resampler.
2022-09-27 11:25:02 +02:00
Wim Taymans
2d858e0ba2 spa: a Flush command does not stop processing
A flush command is not supposed to stop playback but just clear the
current state. Normally, to avoid complications, an application will
Pause, Flush and optionally Start to do things smoothly without
interfering with the process loop, but things should not crash if that's
not the case.

Fixes #2726
2022-09-26 11:10:02 +02:00
Ataberk Özen
10ac448b59 alsa-mixer: add support for Asus Xonar SE 2022-09-25 12:52:14 +03:00
Demi Marie Obenour
fea248d450 SPA POD parser: Fix bug when parsing choice types
spa_pod_parser_can_collect and spa_pod_parser_getv were inconsistent
with each other.  When parsing crafted POD, this could cause a type
confusion or stack overflow.
2022-09-24 15:52:53 +00:00
Pauli Virtanen
2e3347e850 bluez5: use HFP HF as default, not HSP HS
E.g. iphones don't support HSP, only HFP, so change the default to use
HFP HF instead of HSP.  HFP is now old, and most devices should support
it now.
2022-09-24 13:26:50 +03:00
Barnabás Pőcze
0a48165cff spa: bluez: backend-native: accept "=" for +VGS and +VGM
HFP 1.8 states in 4.35.1:

  Due to the small inconsistency between the GSM standard [2]) and the current
  Headset specification ([3]), the HF shall also accept the “=” symbol,
  in place of “:”, as a valid separator for this unsolicited result code.

iOS seems to use "=", so accept that as well.

See #2463
2022-09-24 02:47:58 +02:00
Barnabás Pőcze
0ee4fea03d spa: bluez: backend-native: fix HF/HS to AG message terminator
Both HFP and HSP require an AT command from HF/HS to AG to
be terminated by CR, not LF. (HFP 1.8, 4.34.1; HSP 1.2, 4.8.1)

See #2463

Fixes: 0b2d3730b6 ("bluez5: Add HFP HF support")
2022-09-24 02:45:41 +02:00
Barnabás Pőcze
2fb63f71c3 spa: bluez: backend-native: use sscanf() for parsing AT commands 2022-09-24 02:22:29 +02:00
Barnabás Pőcze
c24594a8ac spa: bluez: backend-native: fix type and add error checking 2022-09-24 02:22:19 +02:00
Barnabás Pőcze
8881030904 spa: bluez: backend-native: use strsep() instead of strtok()
`strsep()` is simpler to use than `strtok()` or `strtok_r()`
while being thread-safe and reentrant.

Although it is an extension, it is available in both glibc and musl.
2022-09-24 02:22:16 +02:00
Demi Marie Obenour
c1920163d5 Fix calls to sendmsg()
Align cmsg buffers properly and use MSG_NOSIGNAL.
2022-09-23 16:33:36 +00:00
Demi Marie Obenour
90c955c223 Replace more macros with accessor functions 2022-09-23 11:39:33 -04:00
Demi Marie Obenour
671a7102ff Fix some badly-behaved macros
Some macros evaluated their arguments more than once when it was not
needed, or were missing parentheses.
2022-09-23 11:39:33 -04:00
Demi Marie Obenour
bb4f274ae0 Make all fopen() calls use O_CLOEXEC
by adding "e" to the mode strings.
2022-09-23 15:19:01 +00:00
Wim Taymans
7c93c29cfd add some more debug 2022-09-23 16:48:40 +02:00
Wim Taymans
e8aef6b4bd audioconvert: only Suspend should trigger negotiate
A Suspend should clear all the negotiated state and start a new
negotiation in Start. Use a flag to control this.

This avoids recalculation of state for each pause/play state change.

See #2701
2022-09-23 15:32:36 +02:00
Wim Taymans
9119e8a26e improve debug 2022-09-23 15:14:50 +02:00
Wim Taymans
ad8fa41678 audioadapter: warn when scheduling a stopped node
Log a warning when we try to schedule a stopped node.

See #2701
2022-09-23 11:30:42 +02:00
Wim Taymans
71a918fae1 acp-tool: handle ctrl-D to exit
Fixes #2700
2022-09-21 17:32:13 +02:00
Jonas Holmberg
dacbeca77e alsa-pcm: Change resync warning logic
Log follower resync messages with info level until there has been a
successful read or write to get rid of the initial warning when starting
a stream.
2022-09-21 16:42:37 +02:00
Wim Taymans
ef39576150 alsa: rate limit some warnings 2022-09-21 15:52:24 +02:00
Wim Taymans
9632145c9a log: make some more macros
Make a macro to log at a certain level with func,line,file added.
Use the new macros to reduce some redundant arguments.
2022-09-21 15:50:41 +02:00
Wim Taymans
7bf84fa5e2 pod: only call the overflow callback when still needed
When we are already past the size of the buffer, don't bother calling
the overflow callback anymore, the buffer is already corrupted.

Otherwise it would be possible to have the overflow callback fail the
first time around, some data will be skipped, and then the next
overflow callback would succeed, giving the impression that all is
fine.

Add a unit test for this.
2022-09-20 16:59:25 +02:00
Wim Taymans
31f9e18edb audioconvert: add resample.prefill option
Add a resampler option to prefill the resampler with 0. This then
results in the resampler always outputing and consuming the same
amount of data instead of a short buffer in the beginning.
2022-09-19 12:35:49 +02:00
Wim Taymans
aca85b49ea audioconvert: set stride on output buffers 2022-09-19 12:01:24 +02:00
Frédéric Danis
75ae86bf13 bluez5: backend-native: Only send one error message
When rfcomm_hfp_ag() returns false, an "ERROR" reply is sent.
When testing if the SLC is configured, 2 "ERROR" replies are sent, which
should not be done.
2022-09-16 12:32:12 +02:00
Pauli Virtanen
8de03f5c29 bluez5: support and use old api.bluez5.a2dp.* factory names for A2DP
For backward compatibility with old Wireplumber releases, support the
old api.bluez5.a2dp.sink/source names, and use them in object events
instead of the media.sink/source names.
2022-09-15 23:04:37 +03:00
Pauli Virtanen
101287159e bluez5: fix media-sink for A2DP
It's always Audio/Sink for A2DP, never stream.
2022-09-15 19:46:25 +03:00
Pauli Virtanen
13eb00fd44 bluez5: fix error in search/replace for a2dp->media
The A2DP factory source<->sink was erroneously swapped in
commit 00d51c3d31 ("bluez5: Rename codec API from *a2dp* to *media*")
2022-09-15 19:39:26 +03:00
Barnabás Pőcze
83a510cba3 spa: libcamera: fix hook adding logic
Previously, if "add_listener" was called on the monitor device, then it
did not necessarily emit events about all devices because it called
`enum_devices()` which does not emit events about already existing
devices. So the very first listener would get all existing devices,
but subsequent ones would not get events about the existence of devices
that have already been seen by the monitor. Fix that by simply emitting
events about all existing devices if the current listener is not the first.
2022-09-15 11:17:47 +00:00
Barnabás Pőcze
74b66d939a spa: libcamera: do not try to acquire CameraManager if there is already one 2022-09-15 11:17:47 +00:00
Barnabás Pőcze
0f6c5a04c7 spa: libcamera: fix CameraManager event handling
libcamera's CameraManager runs the event handlers on its own thread,
thus synchronization is needed to ensure correct functionality.
Implement that by collecting hotplug events into a mutex protected queue
and signalling the main loop where they can be processed and the
"object_info" event can be safely emitted.
2022-09-15 11:17:47 +00:00
Barnabás Pőcze
f9796fc024 spa: libcamera: remove unnecessary typedef 2022-09-15 11:17:47 +00:00