Commit graph

3751 commits

Author SHA1 Message Date
Barnabás Pőcze 8c17a6626d treewide: mark some functions static
These were found by enabling the "missing-declarations" warning.
2023-07-03 19:40:31 +02:00
Barnabás Pőcze ab6ff1bcde spa: libcamera: use init list when calling generateConfiguration()
Pass an initializer list to `Camera::generateConfiguration()` instead
of constructing a vector and adding the single element "manually".
2023-07-03 19:40:31 +02:00
Barnabás Pőcze 6275269f09 spa: bluez: remove some unused variables 2023-07-03 19:40:31 +02:00
Barnabás Pőcze f6ea5421e6 spa: bluez: do not open-code asprintf() 2023-07-03 19:40:31 +02:00
Barnabás Pőcze 605404c781 spa: bluez: device_stop_timer(): remove redundant decl
Also move the declaration of `media_codec_switch_free()`
up to the beginning of the file, near the other decls.
2023-07-03 19:40:31 +02:00
Barnabás Pőcze 0ed8880489 spa: bluez: modemmanager: do not use old style declaration 2023-07-03 19:40:31 +02:00
Barnabás Pőcze abbdcf1854 spa: bluez: mark modemmanager stub functions static inline 2023-07-03 19:40:31 +02:00
Wim Taymans 927eb64177 alsa: use get_avail() recover logic
Always use get_avail() and then only fetch the hires timestamp when
enabled to enhance the delay reporting. This way we also recover from
errors from snd_pcm_avail() instead of ignoring them.

This should make the recover after mmap_begin obsolete but we'll leave
that just to be safe.
2023-07-03 17:08:08 +02:00
Pauli Virtanen ff5f6d908b bluez: allow buffers with maxsize < duration*frame_size
Buffer sizes smaller than one cycle are possible, so don't assert that.
Instead, just provide as much samples as fits to the buffer.

If we are driver when this happens, emit a warning (once).  Similarly to
ALSA, as driver we produce only one buffer at cycle start, and no new
buffers in process. If the whole cycle doesn't fit into the buffer,
recording probably will be broken and we want some debug when there will
be a bug report about that.
2023-07-03 13:56:20 +00:00
Wim Taymans c13696aca1 filter-chain: simplify biquads 2023-06-30 17:49:29 +02:00
Barnabás Pőcze 4a555ed6ff spa: bluez: backend-native: fix a memory leak
In `_transport_create()`, if `spa_bt_transport_create()` failed
then `pathfd` would be leaked.
2023-06-29 23:57:48 +02:00
Wim Taymans 2963e7fd4c alsa: disable htimestamp when it seems to error too much 2023-06-29 16:40:21 +02:00
Wim Taymans f76191c792 alsa: add option to disable htimestamps
Add api.alsa.htimestamp to disable the use of hires timestamps.
2023-06-29 16:23:39 +02:00
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