Commit graph

49 commits

Author SHA1 Message Date
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
Wim Taymans
0648297fcb alsa: make it possible to configure the clock name
When nodes are synchronized to a common clock, the clock name can
be set to the same value on the alsa nodes and no resampling will
be done.
2021-12-10 11:04:38 +01:00
Wim Taymans
e31f9aa0f2 alsa: don't set id in PropInfo for params
The id is useless when dealing with props params, we need to use the
name of the property as the key. Also the id can clash with other ids
of other plugins.
2021-12-02 11:35:12 +01:00
Wim Taymans
d673158db1 alsa: expose all config options as params
Add PropInfo for all the params that we can configure at construct
time and also add them as PROP_params.

This way you can configure the headroom at runtime with this:

pw-cli s <id> Props '{ params = [ "api.alsa.headroom" 1024 ] }'
2021-11-30 17:43:07 +01:00
Wim Taymans
8995129e6c alsa: refactor property parsing
Move the common property parsing to the init function.
2021-11-23 12:27:36 +01:00
Wim Taymans
13923416e0 alsa: keep track of rate in card object
Expose the card object and always obtain one per pcm.

Keep the configured format in the card object.

Add a api.alsa.multi-rate property. When multi_rate is disabled,
only allow the last configured card rate on all PCMs.

This works around drivers that can't handle multiple samplerates
on their PCMs.

With this patch it should be mostly safe to configure multiple
sample rates in pipewire.conf

See #1547
2021-11-23 11:44:26 +01:00
Peter Hutterer
e9d869b46f spa: implement a log topic for alsa 2021-09-28 09:35:39 +02:00
Wim Taymans
349324b9a6 alsa: pass AES bits to S/PDIF devices
This is the right thing to do and might even fix output to some
devices.
2021-09-14 12:42:03 +02:00
Wim Taymans
99e6c77525 alsa: improve device name construction
Get the ucm prefix only once, when we open the UCM card and then
use it for all devices using the card.

Construct the device name right before we open it with the ucm prefix
and possibly the AES flags instead of messing with the property.
2021-09-02 12:35:58 +02:00
Wim Taymans
09ee977141 alsa: cache UCM config
ALSA has problems with creating more than 8 configs per card so cache
the config per card and reuse it.

Fixes problems with no devices after logging out and in again because
ALSA can't create UCM profiles anymore.

See #1553
2021-08-30 17:36:11 +02:00
Wim Taymans
2e6f80f808 alsa: only list IEC958 codecs when iec958 or hdmi device. 2021-08-23 11:58:29 +02:00
Wim Taymans
9dfe35b17c alsa: add enumeration of iec958 format
For hdmi and iec958 devices, enumerate the iec958 formats and
codecs. Initially only PCM is supported as a codec but with
a property or an init option, the list of codecs can be dynamically
configured.
2021-08-23 11:31:52 +02:00
Wim Taymans
6d196b1d11 alsa: use ProcessLatency param to get and set internal latency 2021-08-17 10:04:12 +02:00
Wim Taymans
4c09eb227f alsa: rename indexes into port and node params 2021-06-24 10:03:41 +02:00
Wim Taymans
8cf5927e95 alsa: keep track of input and output latency
track and report both input and output latency.
2021-06-24 09:59:48 +02:00
Wim Taymans
c726dd887c alsa: refactory _io_position checking
Move the code to check the position duration for changes to one
new method.
Also check for samplerate changes and adjust the resampler state
accordingly.
2021-06-17 11:11:44 +02:00
Wim Taymans
35e81fbfdc alsa: rework UCM open
Use _alibpref to check if a device needs a UCM local config. Mark
the device as such and use this to set the OPEN_UCM property on
the device.
Open the UCM for a card when the device has the property set. Use the
same logic for loading the UCM as the acp code.

See #1251
2021-06-02 17:25:21 +02:00
Wim Taymans
e3d3f04780 alsa: if we are passed a UCM device, make sure to open UCM
UCM devices can require local data from use_case_mgr_open() but since
we do that in a separate process, make sure we reopen the use case
manager in case we are passed a UCM device so that the config is
available.

See #1251
2021-06-02 13:23:08 +02:00
Wim Taymans
b9b89b92b2 spa: add some latency helpers
Add more fields to the latency object.
Add methods to create, parse and process latency info.
2021-05-27 15:26:09 +02:00
Wim Taymans
1cd6d7b01d spa: Implement latency reporting
Implement latency reporting in alsa
Implement latency reporting on audioconf by passing on the latency
from the follower to outside of the adapter.
2021-05-27 15:26:09 +02:00
Wim Taymans
39a2636c9b alsa: clean up port and node params 2021-05-21 11:08:52 +02:00
Wim Taymans
02decd9fba alsa: pause/resume when entering/exiting freewheel
When we start freewheeling, pause the device and resume when we
finish freewheel.
In freewheel mode, just discard samples in the sink and produce
silence in the source.
2021-05-07 11:51:22 +02:00
Wim Taymans
80ce2c94ac alsa: add start-delay parameters to sink
The start-delay adds extra silence to the buffer before starting the
playback. The idea is to have more time to adapt to the device
startup and set the timer more accurately.

See #983, #431
2021-03-29 13:20:14 +02:00
Wim Taymans
fc9a6d6b1e spa: spa_json_get_string does not return the length
The returned string is null terminated.
2021-03-18 18:57:26 +01:00
Wim Taymans
8e590df92f spa: improve info parsing
Make info parsing a bit easier to read by assigning the key and
value to temporary variables.
Improve the parsing of channelmap using json parser to make it
support more cases.
Add a unit test for channelmap parsing options.
2021-03-18 18:40:56 +01:00
Wim Taymans
8981e11c53 alsa: various improvements
Remove some magic constants that are not needed anymore with the
headroom.
Clamp the error to some reasonable value so that we don't adjust the
rate too much but still apply all of the correction calculated by the
dll.
Remove the bandwidth adjustment.
Also update the matching and resample fields when we reassign the
node to a new driver. This could cause the new follower to not activate
the adaptive resampler and get out of sync.
2021-03-03 15:40:10 +01:00
Wim Taymans
73896bfa83 alsa: rework batch handling a bit
By default, use a 512 period for batch and use 512 headroom
Add a property to disable special batch handling.
2021-01-21 17:14:51 +01:00
Wim Taymans
482f96a644 alsa: add option to disable mmap access mode 2021-01-15 15:44:22 +01:00
Wim Taymans
7347b5ef05 alsa: add api.alsa.headroom setting
Can be used to tweak the extra distance kept between the hardware
and software pointers when reading and writing.

See #289
2021-01-14 17:10:05 +01:00
Wim Taymans
18b5199d44 alsa: add read/write access mode
Add support for read/write access mode when mmap is not available.

See #526
2021-01-05 17:48:09 +01:00
Wim Taymans
87292432b7 alsa: add option to configure period-size
api.alsa.period-size can be set to something else than 1024 with
this config option.
2021-01-05 12:44:10 +01:00
Wim Taymans
4b076549f7 alsa: allow override of channel map 2020-12-28 14:24:59 +01:00
Wim Taymans
d71259a02c alsa: handle batch devices
For batch devices that are not usb devices, lower the period and
add an extra period of heardoom to avoid xruns.

See !330
2020-12-11 17:38:27 +01:00
Wim Taymans
7768a87a0b alsa: make it possible to fix format 2020-12-09 20:33:57 +01:00
Wim Taymans
4e7be858e4 node: Add ParamBegin/End
Use these commands to mark the begin and end of a series of Param
enumerations and configuration, like when doing format negotiation. The
idea is that the device can remain open while we do this.
Use this in adapter when negotiating a format.
2020-12-09 17:10:52 +01:00
Wim Taymans
d776a0917d alsa: refactor dll code 2020-12-09 12:09:40 +01:00
Wim Taymans
1bf6dead10 alsa: add option to force a samplerate 2020-09-16 15:14:26 +02:00
Wim Taymans
2b0b44edc0 alsa: add option do use chmap from alsa, disable by default
This should be more in line with what PulseAudio does and so lead
to less surprises.

See #289
2020-09-14 20:19:44 +02:00
Wim Taymans
8f3771a56c alsa-pcm: also follow resampler insize when resampling
Use the input size of the resampler as the amount of samples to
read when we are resampling.
2020-07-27 15:57:27 +02:00
Wim Taymans
8168dfdbc1 alsa-pcm: allow setting number of channels
Allow passing the number of channels when creating a device to
restrict the negotiated channels.
2020-07-01 12:54:27 +02:00
Wim Taymans
f65d71dd5b alsa: support planar formats 2020-07-01 11:43:25 +02:00
Wim Taymans
441fdb2333 alsa: fix buffer recycle
We only set the OUT flag when we put the buffer on an io area and
might need to recycle later.
Before placing the output buffer into the io area, recycle any
buffer that might be left in there.
Only emit the ready callback when we have some data queued.
2020-03-19 13:12:49 +01:00
Wim Taymans
a528189d26 slave -> follower
We use master/follower terminology everywhere.
2020-02-21 10:47:32 +01:00
Wim Taymans
9ffec214b8 fix includes 2019-10-25 15:01:02 +02:00
Wim Taymans
af73585948 Increase max buffer size 2019-10-24 15:26:59 +02:00
Wim Taymans
2fa97daa24 add some constants for max samples 2019-10-24 12:35:00 +02:00
Wim Taymans
5383782336 alsa: Disable rate matching for the same card
Add a clock name to the clock, remove the old api/clock_id. This makes
it easier to add descriptive names

Place the alsa card number in the clock name.

Check the clock name of the master clock and if it matches our own
clock, disable rate matching.
2019-10-23 16:04:03 +02:00
Wim Taymans
f5b9862a89 alsa: tweak xrun recovery
Don't try to resync right after a xrun.
Init the dll after reslaving.
2019-10-18 22:53:02 +02:00
Wim Taymans
db341a6450 improve properties on node and port
Rename some alsa filenames.
2019-09-23 20:51:34 +02:00
Renamed from spa/plugins/alsa/alsa-utils.h (Browse further)