Commit graph

3738 commits

Author SHA1 Message Date
Wim Taymans
3dab0091bb alsa: warn when the htimestamp seems wrong
The htimestamp should be close to the current_time, if it is further
away that the threshold, something is wrong.
2023-06-29 15:56:43 +02:00
Wim Taymans
b32715ba41 alsa: try to recover when mmap_begin fails
In case the get_avail call did not catch the device error, handle the
error and try to recover in the mmap_begin call instead.

See #3315
2023-06-27 13:25:47 +02:00
Guido Günther
88bb0bd7cc alsa: Allow to augment ucm port properties
Since UCM doesn't perform the path lookups of alsa-mixer all UCM devices
fall back to the card's properties for e.g. icons and hence usually show
the `audio-card` icon for all ports giving a confusing UI to users as
all ports show the same icon.

As ucm names are pretty standard augment some common port names with
icons.
2023-06-26 19:39:31 +00:00
Niklāvs Koļesņikovs
15ddbfd037 spa/plugins/bluez5/meson: removed some unneeded redefines
As far as I can tell, the code in question was not doing anything there
and was also breaking the new code elsewhere, so it was put on the
chopping block. Don't mind the squirming tentacles.

Signed-off-by: Niklāvs Koļesņikovs <89q1r14hd@relay.firefox.com>
2023-06-26 15:21:49 +00:00
Dorinda Bassey
98ac13a03e cleanup unused variables
added cleanup of unused variables to resolve build warnings in pipewire-rs

Signed-off-by: Dorinda Bassey <dbassey@redhat.com>
2023-06-26 10:51:09 +00:00
Wim Taymans
0156d63109 audioconvert: don't negottiate rate when resample is disabled
This will leave the negotiated rate 0 when parsed and instructs the
stream to follow the graph rate.
2023-06-26 11:23:29 +02:00
Carlos Rafael Giani
d20fc2a8ec alsa-compress-offload-sink: Fix format renegotation
The have_format flag was not being properly processed, leading to
incorrect behavior when the format param was enumerated.
2023-06-24 16:54:15 +02:00
Arun Raghavan
de2d7a583b alsa: Actually write out pitch elem value during initial reset
Without this, we were assuming our inital rate of 1.0 was also what was
applied to the feedback endpoint, but that was not actually true.
2023-06-23 16:45:36 +00:00
Michael Olbrich
e808875d60 alsa: improve audio output to multiple devices
There are currently several issues when multiple alsa devices are
involved.

For alsa devices that are followers, all data is written via
impl_node_process(). Currently spa_alsa_write() is only called if a new
buffer was queued.
It can happen that all buffers are in the ready list (queued by previous
calls but not yet written because there was no free space in the kernel
ring buffer). In this case writing stalls indefinitely.
To fix this, also call spa_alsa_write() if no new buffer is queued but
there are still buffers in the ready list.

If the ready list of the primary device is not empty then only this
device is handled because spa_alsa_write() is called directly. The other
devices make no progress during this interval.
The clock drift calculation works by comparing the alsa delay with the
expected delay since the last wakeup. This only work if the alsa
ringbuffer was filled completly. If the ready list contains a partial
buffer then the ringbuffer is not filled and the timing calculation
during the next wakeup is incorrect.

To fix all this, remove the special case for the non-empty ready list
and just call spa_node_call_ready() every time.
2023-06-22 09:28:44 +00:00
Wim Taymans
774af1487a Revert "audioadapter: renegotiate when EnumFormat changes"
This reverts commit b292e52740.

It is probably not a good idea to renegotiate right away, we should at
least wait until the node is started again.
2023-06-22 10:01:02 +02:00
Wim Taymans
b292e52740 audioadapter: renegotiate when EnumFormat changes
Start renegotiation when EnumFormat changes.
2023-06-21 16:29:45 +02:00
Dmitry Sharshakov
f257c3407d node-driver: allow specifying both PHC and ID 2023-06-20 06:51:30 +00:00
Wim Taymans
f2ba4caaf0 alsa: silence ctl probe errors
ALSA seems to emit some errors to stderr when the ctl can not be opened.
Silence those errors, we handle and log the result ourselves.
2023-06-19 17:20:57 +02:00
Wim Taymans
1589506c7c alsa: ratelimit impossible timeout messages 2023-06-19 16:58:29 +02:00
Arun Raghavan
abb300750f alsa: Implement playback/capture rate control for USB gadgets
If we detect Playback/Capture Pitch 1000000, we can adjust those values
to update the feedback endpoint for the host. On the capture side, this
will instruct the host to adjust the rate at which data is being sent.
On the playback side, this will adjust the amount of data the USB gadget
driver sends out in each USB tick.
2023-06-17 08:56:41 +00:00
Wim Taymans
d04e430f23 audioconvert: add channelmix.mix/max-volume param
And clamp the volume values between these two. This can be used lock the
voluem to value or do some volume limit.
2023-06-15 11:06:52 +02:00
Wim Taymans
05ea4520e6 audioconvert: improve debug 2023-06-14 16:57:13 +02:00
Wim Taymans
29989835f9 resample: improve debug 2023-06-14 11:19:50 +02:00
Wim Taymans
98acb0d62d mixer: add some more debug 2023-06-08 16:35:08 +02:00
Wim Taymans
6b6f3432fe alsa: htimestamp needs an operation to sync with hw
So use snd_pcm_avail
2023-06-05 17:15:30 +02:00
Wim Taymans
29e6544bae alsa: enable htimestamp mode
Use snd_pcm_htimestamp to get both the available space and the timestamp
when this was calculated. We can then use this to get a better estimate
of the delay in the device against the graph start and get a more
reliable delay between capture and playback.
2023-06-05 16:49:58 +02:00
Wim Taymans
90e2f4a139 alsa: fix impossible timeouts
Use the avail and read_size to calculate the next timeout, not delay and
target, which could give a negative value and impossible timeout.
2023-06-05 16:49:02 +02:00
Wim Taymans
61ce16b19f alsa: decouple delay from avail
Use separate values for the number of available samples in the
ringbuffer and the delay in the device.

When using htimestamp we can use the tstamp to get a more accurate delay
value against the graph start time.
2023-06-05 16:33:12 +02:00
Pauli Virtanen
7aae8c45ec bluez5: do not delay transport release if it is not active
Transport release should not be delayed if it is not active, since the
fd cannot be used any more, and the transport needs to be reacquired to
get a working fd.

Fixes reacquiring transports if the remote side causes them to become
inactive.
2023-05-26 07:17:51 +00:00
Wim Taymans
09f480ccb3 audioconvert: fix monitor port latency
The monitor port latency is the reverse direction of the input ports.
2023-05-25 20:05:54 +02:00
Dmitry Sharshakov
797bd4f6b3 bluez5: media-sink: include codec into media.name 2023-05-21 10:18:06 +00:00
Dmitry Sharshakov
7e5c6631a5 Audio Pro A26: disable hw-volume feature, because volume was being reset to 100% on each reconnect 2023-05-20 09:26:30 +00:00
Wim Taymans
e3d9d9c9fa audioadapter: warn !started and scheduled only once
One warning is enough.
2023-05-19 18:40:11 +02:00
Pauli Virtanen
1d23d21ffe bluez5: check if we have any codecs before trying to register
Don't try to register A2DP / BAP with BlueZ if we don't have any codecs
for that.
2023-05-18 14:36:16 +03:00
Wim Taymans
ae9262409f audioconvert: suggest to inline some functions 2023-05-18 10:21:47 +02:00
Wim Taymans
736e9cc94c null-audio-sink: make it possible to override node.driver
See #3220
2023-05-15 21:25:28 +02:00
Wim Taymans
5d5576f4a8 spa: make latency struct to compare const 2023-05-11 18:28:03 +02:00
Wim Taymans
e3cfd73b9e audioconvert: use target_rate/quantum when starting
When the node is starting and negotiating, use the target_rate and
quantum because that is what is going to be used in the next cycle.
2023-05-09 15:53:36 +02:00
Dmitry Sharshakov
249cf9bfbe chore: fix warnings shown by Clang 16
These might have existed earlier, but fixing anyway
2023-05-09 08:31:56 +00:00
Wim Taymans
318d82e14f alsa: avoid division by 0
After we se the format, we negotiate the buffer size and period size.
When this fails, the period_size can be 0. Handle this case without
causing a floating point exception.
2023-05-08 16:49:33 +02:00
Wim Taymans
727775201f spa: make node callbacks fast 2023-05-06 00:47:39 +02:00
Wim Taymans
efea7ad060 hooks: add and use _fast callback function
Add a _fast callback function that skips the version and method check.
We can use this in places where performance is critical when we do the
check out of the critical loops.

Make all system methods _fast calls. We expect them to exist and have
the right version. If we add new versions we can make them slow.
2023-05-06 00:27:12 +02:00
Wim Taymans
9967c35bbe audioconvert: exit early to ask more data
We don't need to peek all the output buffers before deciding that we
need more data. Just check if we have input, if not ask more data.
2023-05-05 21:34:53 +02:00
Wim Taymans
4b5b94303e loop: clear rmask after dispatching all sources
To make the unit tests work again.
2023-05-05 18:36:50 +02:00
Wim Taymans
fbf17cf980 loop: add optimized non-cancellable iterate
Only use the more heavy cancellable loop when the loop.cancel property
was set. Makes pipewire go from 5% to 3% in high frequency wakeups.
2023-05-05 17:41:37 +02:00
Wim Taymans
67c38490a5 move some trace to trace_fp 2023-05-05 17:41:13 +02:00
Pauli Virtanen
6e17962ad0 impl-port/audioconvert: add PORT_IGNORE_LATENCY
Add port.ignore-latency prop, which if true causes peer ports to ignore
the latency of the given port.

This is useful for ports that are not intended to affect latency
calculations of other ports, such as ports in monitor streams.
2023-05-03 18:01:00 +00:00
Barnabás Pőcze
2dd3a00bb5 spa: bluez: modemmanager: fix DBusMessage leaks
A DBusMessage needs to be unref-ed after sending it regardless
whether or not it was successfully sent. So do that in
`mm_dbus_connection_send_with_reply()` so that the callers
do not need to deal with that.
2023-05-03 11:27:25 +00:00
Barnabás Pőcze
4591cfcd37 spa: bluez: modemmanager: do not log message sender as warning 2023-05-03 11:27:25 +00:00
Barnabás Pőcze
54b0886c78 spa: bluez: backend-native: use correct pointer
The yolo pointer strikes again. Pass the correc pointer to `mm_unregister()`.
2023-05-03 11:27:25 +00:00
Barnabás Pőcze
ff62eb59e2 spa: bluez: modemmanager: remove unused member 2023-05-03 11:27:25 +00:00
Barnabás Pőcze
06030ddf76 spa: bluez: backend-hsphfpd: fix dbus type
Use `DBUS_TYPE_STRING` for a string and not `DBUS_TYPE_BOOLEAN`.
2023-05-03 11:27:25 +00:00
Barnabás Pőcze
abe9615fec spa: bluez: backend-hsphfpd: use dbus_bool_t for DBUS_TYPE_BOOLEAN 2023-05-03 11:27:25 +00:00
Barnabás Pőcze
36bfd5263f spa: bluez: do not check if service is running
It is inherently racy, and we have a better way to ensure that
we won't autostart the service:

  dbus_message_set_auto_start()

So use that.

This commit also adds a missing call to `dbus_pending_call_unref()`
and indirectly fixes a type mismatch (`dbus_bool_t` vs. `bool`)
that was present in `is_dbus_service_running()`.
2023-05-03 11:27:25 +00:00
Barnabás Pőcze
4d5f3620af spa: bluez: initalize DBusError object
The DBusError passed to `dbus_set_error_from_message()` must
be initialized, otherwise libdbus aborts:

  dbus[129473]: arguments to dbus_set_error_from_message() were incorrect,
                assertion "(error) == NULL || !dbus_error_is_set ((error))"
                failed in file dbus-message.c line 4043.
  This is normally a bug in some application using the D-Bus library.
2023-05-03 11:27:25 +00:00