alsa: improve force_rate handling

Replace force_rate with force_quantum. We use force_rate when we need
to play an IEC958 or a DSD format but it does not make sense to just
force the rate without also forcing the duration.

This is also what happens when doing IRQ based scheduling, we then force
both the duration and rate of the graph so we can reuse this logic.

Also when forcing a quantum, take into account the suggested duration
and rate of the graph and scale that with the currently configured rate
for the period size. This gives a quantum that will match the requested
rate better. This is important for the DSD, where rate are very high and
we want the period size to be something reasonable relative to the
selected graph rate.

For batch devices (and when using a timer) we also configure a period
size that is half the duration of the quantum, to make sure we get some
headroom. We however need to force the full duration as the quantum, so
keep track of this scaling and apply when calculating the duration.
This commit is contained in:
Wim Taymans 2025-09-25 12:29:05 +02:00
parent 65e49b38d1
commit f8389cbdb7
2 changed files with 25 additions and 18 deletions

View file

@ -169,6 +169,7 @@ struct state {
uint32_t delay;
uint32_t read_size;
uint32_t max_read;
uint32_t duration;
uint64_t port_info_all;
struct spa_port_info port_info;
@ -232,7 +233,7 @@ struct state {
unsigned int dsd_lsb:1;
unsigned int linked:1;
unsigned int is_batch:1;
unsigned int force_rate:1;
unsigned int force_quantum:1;
uint64_t iec958_codecs;