Commit graph

3399 commits

Author SHA1 Message Date
Wim Taymans
b2c24f3435 audioconvert: fix unaligned writes
Avoid some optimizations that cause unaligned writes.

See #3572
2023-10-15 20:52:54 +02:00
Wim Taymans
bdd577c360 Revert "audioconvert: fix unaligned address"
This reverts commit ae3798abaa.
2023-10-15 20:49:31 +02:00
Wim Taymans
ae3798abaa audioconvert: fix unaligned address
See #3572
2023-10-15 20:40:30 +02:00
Wim Taymans
f3942fca29 audioconvert: fix unaligned writes
Use 16 bits writes for 16 bits samples or else we might be doing
unlaigned writes.

See #3572
2023-10-15 19:10:45 +02:00
Pauli Virtanen
44a166c288 bluez5: use bigger fallback SCO mtu if kernel doesn't tell us
Use bigger fallback maximum MTU, when kernel fails to tell us, which
shouldn't happen but apparently can. We choose the packet size based on
incoming data, so these values aren't usually needed so we can just bump
them.

Also report errors as necessary.
2023-10-15 16:31:17 +00:00
Pauli Virtanen
960ca82552 spa: deduplicate test-helper.h 2023-10-15 16:20:17 +00:00
Hector Martin
fd969dab28 alsa: Ignore PCM devices with udev env ACP_IGNORE
When checking that a card has all of its PCM devices available, ignore
any specific device with the ACP_IGNORE udev environment variable. This
mirrors how we ignore whole cards, but specifically allows non-PipeWire
software to own specific PCM devices.

Note that this does not actually stop PipeWire from using those
subdevices right now, we assume UCM configs take care of that. This
should probably be implemented later to ensure PipeWire always stays
away from them, but for now this fixes the issue where it refuses to
probe the entire card.

Fixes: #3570

Signed-off-by: Hector Martin <marcan@marcan.st>
2023-10-14 14:14:10 +09:00
Wim Taymans
c94d5d9d34 audioconvert: improve allocation
Don't try to allocate each time port buffers are set but only once
before we start procesing.

Also allocate enough temp buffers are there are ports. This saves us
quite a bit of memory in the normal case.
2023-10-13 18:05:42 +02:00
Wim Taymans
11320cf203 tweak number of buffers
In most cases we can use just 1 buffer.

The alsa-pcm-source needs at least 2 buffers so increment the min
limit.
2023-10-13 14:00:29 +02:00
Wim Taymans
9163c419df audioadapter: alloc at least 2 buffers when async
When the follower is async, alloc at least 2 buffers.
2023-10-13 13:59:34 +02:00
Hector Martin
89e9da8cc0 alsa: Do not attempt to prepare linked PCMs
All linked PCMs prepare together. If we prepare the secondaries, that
action clobbers the write pointer of every PCM every time, which then
causes playback to fail to start due to lack of data.

Signed-off-by: Hector Martin <marcan@marcan.st>
2023-10-12 21:38:55 +09:00
Sebastian Jaeckel
be69f029ac node-driver: use interface name to get PHC index of PTP clock
The user may not know which is the active PHC index of a bonded
interface. We can now specify the interface name instead of a device
as the clock.interface property and query the interface about the
active PHC index.
2023-10-12 17:32:50 +00:00
Sebastian Jaeckel
f7fa7df3ee node-driver: warn if the specified clock can't be opened 2023-10-12 17:32:50 +00:00
Wim Taymans
e940361c94 alsa: don't check early wakeup when PCM stopped
When the PCM is stopped, don't check for early wakeup because if we
are early, we will never be on time in the next iteration either because the
PCM is stopped and doesn't advance.

Also don't try to align when stopped.

See #3565
2023-10-12 15:28:53 +02:00
Wim Taymans
0ca1acb3d5 alsa: don't resync capture when linked
We should be aligned correctly.
2023-10-12 15:28:21 +02:00
Wim Taymans
080c40d938 alsa: handle errors from get status
And skip a cycle.
2023-10-12 15:17:48 +02:00
Wim Taymans
162f90ac3a alsa-seq: set priority.driver to 1
So that nodes are moved to it as a fallback when nothing else is
running.

Fixes #3562
2023-10-12 11:57:14 +02:00
Wim Taymans
a8636b04cb alsa: always read/write follower samples
Ignore errors such as -EAGAIN, just write what we have.

See #3565
2023-10-12 11:40:50 +02:00
Wim Taymans
7a0b400c18 spa: use dynamic builder where we can
With the spa_auto support this becomes feasable and avoids problems when
the pod size is unknown and ends up larger than our stack buffer.
2023-10-11 18:04:17 +02:00
Wim Taymans
a9659d9dce alsa: add Tag set and enum support
So that we can see the tags on the sinks and sources.
2023-10-11 15:56:52 +02:00
Wim Taymans
7554bdea97 alsa: clean up some latency param handling 2023-10-11 15:55:57 +02:00
Wim Taymans
77651e130e alsa: add extra checks
Check if the device is opened when doing _prepare or _start. When it was
a follower but failed to open, we might otherwise crash.

Fixes #3554
2023-10-11 11:39:45 +02:00
Wim Taymans
2278dd1460 acp: only disable tsched when linking
Disable timer based scheduling only if we are going to link the devices
together.

See #3556
2023-10-09 12:28:46 +02:00
Wim Taymans
945be16617 acp: only join and link when 1 capture and 1 playback
Only schedule nodes together when there is just 1 capture and 1 playback
device. Devices might be mutually exclusive or require special setup
that would break otherwise.

See #3556
2023-10-09 10:35:30 +02:00
Wim Taymans
063805ccb4 acp: fix compilation 2023-10-09 10:15:10 +02:00
Wim Taymans
896fea62c2 alsa: add api.alsa.auto-link option
Add an option to automatically use snd_pcm_link when the follower clock
is matching the driver. Only set this to true in pro-audio and when
nodes are scheduled together.

See #3556
2023-10-09 10:13:43 +02:00
Barnabás Pőcze
8256a2d5a6 spa: remove unnecessary indirection for some spa_log_topics
This results in shorter machine code since it removes one
pointer load and a NULL check.
2023-10-06 13:08:24 +00:00
Barnabás Pőcze
d2b5b53c08 spa: bluez: fix SBC encoder/decoder leak
`sbc_finish()` wasn't called on the msbc en/decoder of
sco-sink and sco-source. Fix that.
2023-10-06 13:07:16 +00:00
Barnabás Pőcze
96a280497d spa: support: log: always set spa_log_topic::has_custom_level
Always set `spa_log_topic::has_custom_level` so that things work
out as expected even if it is reinitialized or similar.
2023-10-06 11:57:56 +00:00
Wim Taymans
2c5cdb57e5 Revert "node-driver: ensure position doesn't jump"
This reverts commit 8249fa3cbf.

See #3544
2023-10-05 15:22:30 +02:00
Pauli Virtanen
e71cf62b69 bluez5: adapt to further BAP API changes in BlueZ
BlueZ master BAP API is changing, so match our code to that.
2023-10-04 18:36:34 +03:00
Wim Taymans
14114a7386 audioconvert: warn -> debug 2023-10-03 20:39:40 +02:00
Wim Taymans
48e11c6fe0 audioconvert: handle realloc errors
The original pointer is untouched when realloc fails and returns NULL so
make sure we free the previous values.
2023-10-03 20:38:11 +02:00
Wim Taymans
428f766d11 audioadapter: always pass Start when passthrough
When we are operating in passthrough, let the Start command pass through
to the follower in all cases. Only do the negotiate/buffers when not in
passthrough.

This fixes a case where the buffers are cleared on the alsa node and it
Pauses but then never resumes in a Start because the node is already
started. The real problem is probably somewhere else (in PipeWire) but
for now this will improve things in passthrough.
2023-10-02 15:41:56 +02:00
Wim Taymans
96c12c2988 alsa: do playback sync even when alsa is paused
We only start the ALSA pcm after we get our first buffer.

We still need to do the sync through (and get the number of prefilled
samples) to make sure we set our new timeout and don't keep on waking
up quickly while the graph fetches the first buffer.
2023-10-02 15:38:52 +02:00
Pauli Virtanen
bfcbeccec2 bluez5: adapt to changes in BlueZ BAP API
BlueZ master branch now puts various QoS fields into a separate dict, in
properties and method input and return values.

Adjust our code to match that.
2023-09-30 18:13:30 +00:00
Wim Taymans
ee6e7021f0 loop: rate limit xrun messages
When the reader thread locks up for some reason, avoid excessive
logs about the invoke queue being filled.

See #3532
2023-09-30 09:29:20 +02:00
Wim Taymans
c4944dad17 audioconvert: silence some debug info 2023-09-27 11:44:31 +02:00
Samuel Thibault
f9559d2e83 node-driver: Cope with missing CLOCK_BOOTTIME 2023-09-24 15:11:52 +00:00
Pauli Virtanen
a9cc3f2813 bluez5: deprioritize audio-gateway if remote is HFP HF + A2DP sink
If remote supports both HFP HF and AG, both may get connected, which
occurs with Pipewire<->Pipewire connection.  In this case, Pipewire on
both sides may pick the audio-gateway profile.

To avoid both sides being audio-gateway, if remote is both A2DP sink and
HF, use lower priority for the audio-gateway profile.  Generally, BlueZ
won't connect both A2DP Source and Sink between same devices at the same
time, so we use that to determine which side should be the receiver.
2023-09-24 15:45:33 +03:00
Pauli Virtanen
5f7afe588c bluez5: backend-native: fix codec handling with simultaneous HF & AG
It may occur that we have RFCOMM connected as both HF and AG.  The codec
switching and support checks should in this case always use the remote
HF RFCOMM.

Fix by finding the RFCOMM with the correct profile, remote as HF.
2023-09-24 15:45:33 +03:00
Wim Taymans
099e2cf27a alsa: silence an error after resync 2023-09-22 11:23:51 +02:00
Wim Taymans
8249fa3cbf node-driver: ensure position doesn't jump
Make sure that the position only advances in the running state.

When we are not following a clock we can simply increment the position
with the duration every time we run.

If we are following a clock. Take the elapsed time of the clock into
account when aligning to the position.

Fixes #3189
2023-09-21 09:52:53 +02:00
Arun Raghavan
e2f343e844 audiomixer: Correctly initialise data_loop
This got missed when it was added in commit
69d431acd4. Causes a crash when linking
passthrough ports.
2023-09-20 21:46:24 -04:00
Wim Taymans
03840a2a9a alsa: fix recover logic
We can't call spa_alsa functions from the data thread. Iterate ourselves
over the linked devices that we all need to recover as a group.
2023-09-20 15:38:41 +02:00
Wim Taymans
a56ed47c5e alsa: set the driver rate in the clock io
Rename some variables to make it clear that we are dealing with the rate
and duration of the driver.
Set the driver rate in the clock instead of the target_rate, which we
might have rejected.
2023-09-20 11:32:34 +02:00
Wim Taymans
20db9e2d70 alsa: link driver and follower
When we are using the same clock (!matching) try to link the two PCM
devices together. This starts and stops the devices at the same time and
gives better latency.
2023-09-19 13:04:43 +02:00
Wim Taymans
ee1bb2362d alsa: sync followers from the driver
Keep track or the follower state and do the sync from the driver
wakeup.

This improves sync between devices because the sync no longer
depends on when the node was woken up in the graph and scheduled. We
would have been able to handle this difference by using the htimestamp
but that doesn't seen to work reliably on some hardware.

This is also essential for the interrupt based scheduling.
2023-09-18 14:53:15 +02:00
Wim Taymans
c51f6ccbd7 alsa: rework the state sync code
Make one function to sync the state with the realtime thread.
2023-09-18 14:46:56 +02:00
Wim Taymans
86f1d14b72 alsa: keep states in global list 2023-09-18 09:40:52 +02:00