Commit graph

3318 commits

Author SHA1 Message Date
Wim Taymans 0397d7b2be alsa-udev: avoid meth with void pointers 2022-10-06 19:34:09 +02:00
Demi Marie Obenour 8e43c41ac1 Add more parentheses
This was missed in the earlier MR.
2022-10-06 12:12:35 -04:00
Demi Marie Obenour e8f3450a58 Fix various compiler warnings
These caused build failures with -Werror.
2022-10-06 12:12:35 -04:00
Frédéric Danis fd508d395b bluez5: backend-native: Add a property to select the modem to use
By default no modem is allowed.
Property "bluez5.hfphsp-backend-native-modem" can be 'none', 'any' or the
modem device string has found in 'Device' property of
org.freedesktop.ModemManager1.Modem interface, e.g. for PinePhone
"/sys/devices/platform/soc/1c1b000.usb/usb2/2-1".
2022-10-05 19:31:50 +00:00
Frédéric Danis c4addb102b bluez5: backend-native: Only use first modem found
Some device may have multiple modems, we should only used one, the first
found and manage changes only for this one.
2022-10-05 19:31:50 +00:00
Frédéric Danis 47700a2214 bluez5: backend-native: Add battery level indicator support
This connect to the UPower service and update the +CIND battchg indicator
2022-10-05 19:31:50 +00:00
Frédéric Danis a37aeac273 bluez5: backend-native: Add AT+VTS support
This allows to send a DTMF key on an active call.
2022-10-05 19:31:50 +00:00
Frédéric Danis 7c05574072 bluez5: backend-native: Add AT+CNUM support
This only support the first subscriber number.
2022-10-05 19:31:50 +00:00
Frédéric Danis 3566b0739b bluez5: backend-native: Add ATDdd...dd; support
This allows to dial a number.

Memory dialing (ATD>nnn...;) is not supported as it requests access to
the contact application.
2022-10-05 19:31:50 +00:00
Frédéric Danis 20572a1789 bluez5: backend-native: Add AT+CLCC support
This allows the HFP HF to retrieve the list of calls with their index,
state and remote number (if available).

This commit shared the list of calls between modemmanager.c and
backend-native.c, and switches call state storage from ModemManager
states to CLCC states
2022-10-05 19:31:50 +00:00
Frédéric Danis 55075915ec bluez5: backend-native: Add AT+CLIP support
This allows to send the caller number of an incoming call with the RING
event.
2022-10-05 19:31:50 +00:00
Frédéric Danis 4a89a13bda bluez5: backend-native: Support of ATA and AT+CHUP
Allow to answer, reject or terminate a call.

Answering or rejecting a call can only be done on an incoming call.
Terminating a call can only be done on active, dialing or alerting call.
2022-10-05 19:31:50 +00:00
Frédéric Danis e9b82252f7 bluez5: backend-native: Add AT+CMEE support
Returns extended error report instead of just "ERROR" messages when
extended report has been activated by AT+CMEE=1 command.
2022-10-05 19:31:50 +00:00
Frédéric Danis 43c4d95794 bluez5: backend-native: Link with ModemManager Call object
Update the +CIND call and callsetup indicators when Call object state
change.
2022-10-05 19:31:50 +00:00
Frédéric Danis 5b40ed62b4 bluez5: backend-native: Link with ModemManager Voice object
The Voice object lists the Call objects, which provides status of each call.

+CIND call indicator is set if at least one of the call is active.
+CIND callsetup indicator is set if one of the call is in ringing in or out
or dialing state.
2022-10-05 19:31:50 +00:00
Frédéric Danis 275d2bc603 bluez5: backend-native: Link with ModemManager Modem3GPP object
The Modem3GPP provides information about the network the modem is registered
to like the operator name and roaming status.
2022-10-05 19:31:50 +00:00
Frédéric Danis 13f0a0755e bluez5: backend-native: Link with ModemManager Modem object
The Modem object provides the own number (used by +CNUM), the network
service availability and signal strength (used for the +CIND).

+CIND indicators can be activated/deactivated using AT+BIA except for
call, callsetup and callheld indicators which should always reported.
All indicators are enabled on connection.
2022-10-05 19:31:50 +00:00
Frédéric Danis 28533cb615 bluez5: backend-native: Add a ModemManager dependency
Some Linux phones doesn't use oFono but ModemManager to control the modem.
2022-10-05 19:31:50 +00:00
Wim Taymans 9b6e504c19 clean up some more array iterations 2022-10-03 09:20:42 +02:00
Wim Taymans d22feab92a spa: add macro to simplify array iterations some more
uint32_t i;
	for (i = 0; i < SPA_N_ELEMENTS(some_array); i++)
		.. stuff with some_array[i].foo ...

   becomes:

	SPA_FOR_EACH_ELEMENT_VAR(some_array, p)
		.. stuff with p->foo ..
2022-09-30 16:24:26 +02:00
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
Barnabás Pőcze 02f2d6b48d spa: libcamera: remove unnecessary have_config member
An extra flag is not needed because the `config` pointer can be
checked to determine if a configuration has already been retrieved.
2022-09-15 11:17:47 +00:00
Barnabás Pőcze 9374c15c3d spa: libcamera: use std::optional intead of separate bool flag + value
`std::optional` conveniently encapsulates a value and a bool flag,
so use that instead of manually replicating it.
2022-09-15 11:17:47 +00:00
Barnabás Pőcze 13357fec20 spa: libcamera: manage libcamera::CameraManager via a shared_ptr
Using a shared_ptr removes the need for manually calling
`libcamera_manager_release()` to drop the reference as it is done
automatically whenever the shared_ptr is destroyed or reset.
2022-09-15 11:17:47 +00:00
Barnabás Pőcze 330686d3aa spa: libcamera: rework construction/destruction of libcamera source impl
Move some things into constructors and try not to depend on the
fact that the storage is zero initialized, try to initialize
everything properly.
2022-09-15 11:17:47 +00:00
Barnabás Pőcze 98193f7d67 spa: libcamera: remove two unused members from libcamera source
Neither `next_fmt`, nor `next_size` were actually used, remove them.
2022-09-15 11:17:47 +00:00
Barnabás Pőcze 222368e562 spa: libcamera: properly construct/destruct libcamera manager impl
Previously, the libcamera manager `impl` object was neither properly
constructed neither properly destructed. As a consequence, for example,
the shared pointers in the `devices` array weren't properly destructed,
although this has been somewhat mitigated by a previous change
that modifed `clear_devices()`.
2022-09-15 11:17:47 +00:00
Barnabás Pőcze cc229d4b05 spa: libcamera: properly construct/deconstruct libcamera device impl
Previously, the "impl" object was never properly constructed or
destructed, but it more or less worked out since the memory was initialized
to zero bytes and each member had trivial constructors. Except std::shared_ptr,
but an all zero storage happened to be equivalent to a default constructed
shared_ptr.

However, there was the still the problem that the shared_ptr was never
destructed, so it kept the referenced `Camera` object alive, which lead
to memory leaks.

An additional, somewhat unrelated change is that the "props" struct
is removed, and the device identifier is now stored in an `std::string`.
The reason is that `CameraManager::get()` already takes a const std::string reference,
so an std::string must be constructed in any case, so we might as well
take advantage of that and use `std::string` in the "impl" object as well.

Furthermore, wrap the `impl` struct in an anonymous namespace
to avoid name resolution problems.
2022-09-15 11:17:47 +00:00
Barnabás Pőcze f699fa698e spa: libcamera: remove main loop from manager
The libcamera manager does not actually use the event loop
that it acquires during initialization. Remove it.
2022-09-15 11:17:47 +00:00
Barnabás Pőcze 13208220d8 spa: libcamera: print camera id when it appears/disappears 2022-09-15 11:17:47 +00:00
Barnabás Pőcze 086de7dcac spa: libcamera: properly dispose of shared_ptr
Previously, in `remove_device()`, the last device would be copied into
the slot of the to-be-remove device. The problem with this is that it
left the shared_ptr untouched in the previously last slot, and hence
creating an extra reference. Fix this by moving instead of copying.

A similar problem is present in `clear_devices()` which also
did not properly dispose of the shared_ptrs. Fix that by
calling `reset()` on each device's camera pointer.
2022-09-15 11:17:47 +00:00
Barnabás Pőcze 442a0c54ea spa: libcamera: move shared_ptr to avoid copy 2022-09-15 11:17:47 +00:00
Barnabás Pőcze ba04a0f936 spa: libcamera: take raw pointer to avoid shared_ptr copy 2022-09-15 11:17:47 +00:00
Barnabás Pőcze 9370fbee3d spa: libcamera: indent with tabs instead of spaces 2022-09-15 11:17:47 +00:00
Frédéric Danis fdccc10bc7 bluez5: Use SelectProperties Endpoint property to detect device role
BlueZ adds the Endpoint property to the Properties dictionary of
SelectProperties.
This allows to know which remote Endpoint is an acceptor, and so which
local transport should be used as an initiator.
2022-09-15 11:17:20 +00:00
Frédéric Danis d4b639419a bluez5: Init BAP LC3 coder/decoder depending on direction
For LE Audio, sink and source have their own media transport endpoint.
Media sink or source only needs the coder or decoder respectively.
2022-09-15 11:17:20 +00:00
Frédéric Danis 28b4fbecfb bluez5: Manage BAP linked transports
Multiple transport from the same device may share the same stream (CIS)
and group (CIG) but for different direction, e.g. a speaker and a
microphone. In this case they are linked.
In this case:
- On acquire, if another transport has already been acquired, the new
  transport should not call Acquire or TryAcquire but re-use values from
  the previously acquired transport,
- on release, the closing of transport fd and call to Release should be
  done only for the last transport.
2022-09-15 11:17:20 +00:00
Frédéric Danis 81f70aa1ec bluez5: Allow media source connection for BAP 2022-09-15 11:17:20 +00:00
Frédéric Danis cd50188787 bluez5: Fix node creation depending on device role
We can't determine which remote endpoint or device the
SelectConfiguration() call is associated with. For LE Audio BAP, as this
method is called only for the Initiator we set the whole instance as a
Central/Initiator.
This flag is unset on BAP media endpoint removal.
2022-09-15 11:17:20 +00:00
Frédéric Danis e0c79959fc bluez5: Add stereo support to LE Audio LC3 codec 2022-09-15 11:17:20 +00:00
Frédéric Danis fd1b331353 bluez5: Fix sink timeout for BAP
Data should be written to the ISO Stream fd every 10ms or 7.5ms depending
on the configuration selected.
2022-09-15 11:17:20 +00:00
Frédéric Danis 071730ecab bluez5: Use delay from QoS for BAP 2022-09-15 11:17:20 +00:00
Frédéric Danis 39ef812ed5 bluez5: Complete BAP audio location mapping 2022-09-15 11:17:20 +00:00
Frédéric Danis f428b13d06 bluez5: Set BAP QoS depending on selected configuration
This move the QoS setup to be codec specific and fills it depending on the
selected codec configuration.
2022-09-15 11:17:20 +00:00
Frédéric Danis 284da66deb bluez5: Add BAP_SINK/SOURCE from PACS UUID to adapter profiles
BAP sink/source are characteristics of the PACS profile, but we're more
interested by those characteristics then the more generic profile.
2022-09-15 11:17:20 +00:00
Frédéric Danis 496dda1bcc bluez5: Check if BlueZ daemon support LE Audio
Legacy BlueZ 5 API doesn't support to register BAP codecs, which prevents
to register A2DP enhanced codecs.
2022-09-15 11:17:20 +00:00
Frédéric Danis b7ad1d1869 bluez5: Add SelectProperties DBus method support 2022-09-15 11:17:20 +00:00
Frédéric Danis 96acc5a79a bluez5: Add LE Audio BAP support to bluez5-device 2022-09-15 11:17:20 +00:00
Frédéric Danis 201fd7755d bluez5: Add LC3 codec support to LE Audio BAP
By default this codec is disabled as the BlueZ support for LE Audio is
still experimental.
2022-09-15 11:17:20 +00:00
Frédéric Danis fd0bcb1699 bluez5: Add LE Audio BAP support to media-codecs 2022-09-15 11:17:20 +00:00
Frédéric Danis 00d51c3d31 bluez5: Rename codec API from *a2dp* to *media*
The BlueZ Media1 interface will not only be used for A2DP but also for
LE Audio and code related can be shared.
2022-09-15 11:17:20 +00:00