Commit graph

2109 commits

Author SHA1 Message Date
Wim Taymans
1637013401 audioconvert: allocate empty space dynamically
Based on the max buffer size so that we don't need to preallocate and
can addapt to larger buffer sizes.
2022-01-12 17:25:59 +01:00
Wim Taymans
50ce9a794f alsa: relax the max latency requiremen
Our max latency is based on the buffer_size / 2, one part is playing and
another part is filling.
2022-01-12 17:20:42 +01:00
Wim Taymans
c40f2ac245 splitter: small cleanups 2022-01-12 12:48:46 +01:00
Wim Taymans
3739b634ec resample: remove empty buffer
We don't need the empty preallocated buffer, just zero the input buffer
and use that one.
2022-01-12 12:33:12 +01:00
Wim Taymans
8844c15d4d audiomixer: remove the empty buffer
We don't need the preallocated empty buffer. When we need to produce
samples, simply write to the output buffer.
2022-01-12 11:59:36 +01:00
Wim Taymans
140c8d0cd9 bluez5: handle missing device and adapter in quirks
When the device or adapter is NULL, skip the quirk checks instead of
crashing.

Fixes https://gitlab.freedesktop.org/pipewire/wireplumber/-/issues/155
2022-01-11 21:33:35 +01:00
Wim Taymans
3666c4810e audioconvert: ignore latency param on monitor ports
Ignore latency params on the monitor ports of merger. They interfere
with the latency reporting set by the adapter.
The adapter will set the latency param from the follower on port 0 in
the converter, so pass this on to the merger as the latency and ignore
all other updates.

Fixes a case where the latency of a sink would become 0 when a monitor
port was recorded from.
2022-01-11 17:52:41 +01:00
Wim Taymans
b7279a1728 channelmix: dont make FC from synthesized FC
When we have stereo and need to make FC, don't try to upmix the
stereo into FC again.
Fix unit test now that we create FC channels.
2022-01-11 17:25:38 +01:00
Wim Taymans
39716cdd44 alsa: limit batch period size to default
We take half of the current quantum as the period size for batch
devices. Limit this to the default quantum to ensure we don't end up
with too much headroom.
2022-01-11 16:33:19 +01:00
Wim Taymans
59042251ee channelmix: also keep FC channel
When the target has FC, make it from FL and FR in all cases.
2022-01-11 14:47:17 +01:00
Wim Taymans
c9efae4334 channelmix: do LFE upmix when lfe_cutoff is set
Require only the lfe_cutoff be set when generating LFE.
This way you can only generate LFE without having to enable upmix
for all other channels.
2022-01-11 12:44:36 +01:00
Wim Taymans
0ad318f61c channelmix: enable normalization by default
It is probably a better default to avoid clipping when downmixing.
2022-01-11 10:40:42 +01:00
Wim Taymans
7b1c5cd6dd audioconvert: add f64 support
Fixes #1990
2022-01-10 13:14:23 +01:00
Wim Taymans
9f5caa6358 audioconvert: add f64 conversion
See #1990
2022-01-10 13:04:31 +01:00
Pauli Virtanen
f92b0eee56 bluez5: implement basic CIND/CIEV support in backend-native
Set HFP call indicator based on whether transport is acquired or not.
2022-01-09 19:41:17 +02:00
Wim Taymans
113ab31613 resample: limit input and output offsets
Clamp the offsets to the max input and output sizes or we might
end up with invalid len and crash.

See #1994
2022-01-09 16:56:42 +01:00
Nazar Mokrynskyi
dc4cf163ef Remove separate profile set for Behringer UMC22 that is covered by Texas Instruments PCM2902 profile set 2022-01-09 15:37:44 +00:00
Pauli Virtanen
e4f7b2285b bluez5: bump device profile timeout
Double device profile timeout to 6sec.

In some cases, BlueZ can take more than the previous 3sec to connect all
profiles. It's better to wait for a bit longer, so that devices have all
profiles visible already when they first appear.

This works around issues in Wireplumber profile selection logic.
2022-01-09 11:05:42 +00:00
Pauli Virtanen
b92a378a29 bluez5: mark connected when all source/sink profiles connected
Don't require all device profiles to be connected before marking the
device as connected before profile timeout. Show device already when all
A2DP/HSP/HFP profiles for sink/source direction have connected.

There are devices that in principle can have both sink/source profiles
present, but cannot operate both directions at the same time.  In case
profiles come online later, the only effect is that the device profiles
will get an update after the device is published.
2022-01-09 11:05:42 +00:00
Pauli Virtanen
d33779cd11 alsa/acp: make pa_ato* functions behave as PA ones
The pulseaudio pa_ato* functions set errno and return -1, when the
number cannot be parsed.

Some parts of parsing the profile files (e.g. parse_eld_device) rely on
these functions returning errors when the input is not a number.
2022-01-08 16:26:07 +02:00
Wim Taymans
126d380e85 spa-resample: don't add simd_cargs, they are not needed 2022-01-07 13:28:43 +01:00
Wim Taymans
63f6cbc27a spa-resample: add option to set CPU flags
To force SIMD implementations
2022-01-07 13:25:19 +01:00
Pauli Virtanen
38c8a19d9e bluez5: use save flag in profile
Add SPA_PARAM_PROFILE_save to current profile information, and handle it
properly in set_param and when setting profile.
2022-01-06 16:45:57 +02:00
Wim Taymans
af11fb4804 audioconvert: avoid infinite loop
When the follower has no param to enumerate we would keep on enumerating
the params of the converter forever. Fix this by setting the next value
to something that would then stop the iteration.

Also increase the amount of bits for the follower because it might need
them.
2022-01-05 17:05:17 +01:00
Pauli Virtanen
9b43388cee bluez5: retry codec switch with timeout on BlueZ failure
Try to call SetConfiguration after timeout when BlueZ reports a failure
for it.
2022-01-04 22:14:10 +02:00
Pauli Virtanen
cc43b2f601 bluez5: rate limit BlueZ SetConfiguration calls
A2DP profile may disappear if several SetConfiguration events occur too
rapidly. Rate limit these calls when switching codecs.

This resolves failures if e.g. the session manager attempts to set the
profile immediately after the device is created, which previously might
cause a failure.
2022-01-04 22:14:10 +02:00
Wim Taymans
611591d0fc json: add spa_json_parse_stringn()
It also checks the destination size.
2022-01-04 12:37:00 +01:00
Wim Taymans
c46113faa3 json: spa_json_get_string() writes up to len chars or fail 2022-01-04 10:42:32 +01:00
Wim Taymans
68b31d37d9 json: check spa_json_get_string() return value correctly
It is only successful when > 0.
2022-01-04 10:15:35 +01:00
Wim Taymans
b63a6a1b66 acp: sync with pulseaudio 2022-01-03 17:21:28 +01:00
Pauli Virtanen
effa0ca124 bluez5: adjust codec profile priority ordering
Higher priority for A2DP over HFP/HSP.  Prefer mSBC over CVSD for HFP,
and put A2DP codecs in the order we tell BlueZ to use.

Ensures that picking highest-priority profile gives sensible results
(e.g. does not pick HFP unless input route is required, and prefers A2DP
duplex codecs over HFP).
2022-01-03 15:23:55 +00:00
Pauli Virtanen
878e630527 bluez5: prefer aptx-ll over faststream 2022-01-03 15:23:55 +00:00
Pauli Virtanen
55ce3d48c9 bluez5: bump up HFP codec switch timeouts
It appears some headsets (eg. Air 1 Plus) can take some tens of seconds
before replying with AT+BCS switch to CVSD.
2022-01-03 15:22:37 +00:00
Wim Taymans
03f069c35b alsa: handle extra propinfo in all cases
When we don't have iec codecs, increment the result.index to iterate
the remaining properties.
2022-01-03 16:16:16 +01:00
Wim Taymans
67dc97fa43 alsa: add audio.allowed-rates param
Add a construct and runtime param to limit the amount of allowed
samplerates used by the node.

Fixes #1932
2022-01-03 16:03:23 +01:00
Wim Taymans
35cbe4e939 buffers: make alignment optional
Make the alignment parameter optional when negotiating buffers.
Default to a 16 bytes alignment and adjust for the max cpu
alignment.
Remove the useless align buffer parameter in plugins, we always
set it to 16 anyway.
2022-01-03 12:32:26 +01:00
Wim Taymans
30982775d9 support: use defines for alignment 2022-01-03 11:14:15 +01:00
Wim Taymans
6740290410 bluez5: free player path 2022-01-03 10:41:00 +01:00
Wim Taymans
21d07dba26 alsa: add TI PCM2902 mapping
Fixes #1136
2022-01-03 09:47:34 +01:00
Wim Taymans
2ed62f53d9 spa: allocate ports dynamically
So that we don't need to allocate large memory blocks that are mostly
unused.

See #1840
2022-01-01 17:41:27 +01:00
Sanchayan Maity
81fac5b896 bluez5: Set profile priority in SPA attributes 2021-12-30 18:15:32 +05:30
Barnabás Pőcze
26eb66fb5b treewide: meson.build: get SPA_PLUGIN_DIR from dependency
Instead of hard-coding the path relative to the project root,
retrieve the correct path from `spa_dep`.
2021-12-28 18:39:17 +01:00
Barnabás Pőcze
8ed46a283f treewide: meson.build: use project_{build,source}_root()
Use `meson.project_{build,source}_root()` instead of
`meson.{build,source}_root()` because those functions
do not work as expected when used inside a subproject,
and they have been deprecated in meson 0.56.0.
2021-12-28 18:37:18 +01:00
Barnabás Pőcze
2b110af366 treewide: meson.build: use dependency variable for SPA
Use `spa_dep` everywhere instead of `spa_inc`,
and remove `spa_inc` altogether.
2021-12-28 18:34:06 +01:00
Wim Taymans
62660c1e87 audioconvert: make buffers larger
See #1781
2021-12-21 18:35:53 +01:00
Barnabás Pőcze
b04b52ecf8 spa: alsa: do not look up the card again when releasing
Currently, `release_card()` uses `find_card()` to find the card
by the index stored in the state object. However, `find_card()`
increments the reference count of the object, therefore
`release_card()` will drop the reference that it has just
created by calling `find_card()` and not the "calling scope's"
reference. This prevents the card objects from being
freed when the SPA handle is cleared.

Fix it by having `release_card()` take a pointer to the card
and not its index.
2021-12-20 19:50:57 +01:00
Barnabás Pőcze
ee0963b68e spa: alsa: change index type
The `card` structure uses `uint32_t` for its index member,
on the other hand, the `state` structure uses `int`. No code
depends on it being `int`, therefore change it to `uint32_t`
for consistency.
2021-12-20 19:50:57 +01:00
Wim Taymans
f8cdc05720 alsa: allow multi-rate by default
We don't enable multiple rates by default and kernel 5.16 will fix
most issues so allow multiple rates per card.

See #1916
2021-12-18 08:33:34 +01:00
Wim Taymans
b476d6b503 alsa: add api.alsa.period-num param
To configure the amount of periods. By default we use as many as
possible but it is now possible to force a value.

See #1473
2021-12-17 16:09:52 +01:00
Wim Taymans
8630b8846c alsa: use position duration as period size
Use half of the configured quantum as the period size in batch mode.
This gives lower latency for USB devices depending on the quantum.
2021-12-17 16:08:08 +01:00