This is a complete API solution for the filling of the silence samples for the drain operation. The default bahaviour is to aligns the valid samples to one period with extra silence samples for next 1/10th of second.
Introduce SNDRV_PCM_INFO_PERFECT_DRAIN and SNDRV_PCM_HW_PARAMS_NO_DRAIN_SILENCE flags to fully control the filling of the silence samples in the snd_pcm_drain call. Those flags do the bidirectional setup for this operation, so the silencing may be implemented eventually in the kernel space when there's a demand in future. Also, some applications may not require to silence the samples beyond the tail of the ring buffer at all.
There is also a new pcm_hw plugin configuration field allowing the overwrite of the default (auto) behaviour.
Related: https://lore.kernel.org/alsa-devel/20230420113324.877164-2-oswald.buddenhage... Related: https://lore.kernel.org/alsa-devel/20230405201219.2197789-2-oswald.buddenhag...
Jaroslav Kysela (4): pcm: hw: setup explicit silencing for snd_pcm_drain by default pcm: hw: add drain_silence configuration keyword pcm: hw: introduce SNDRV_PCM_INFO_PERFECT_DRAIN pcm: hw: introduce SNDRV_PCM_HW_PARAMS_DRAIN_SILENCE
include/pcm.h | 1 + include/sound/uapi/asound.h | 4 ++ src/pcm/pcm.c | 88 +++++++++++++++++++++++++++++++------ src/pcm/pcm_hw.c | 74 ++++++++++++++++++++++++++++++- src/pcm/pcm_local.h | 7 +++ 5 files changed, 160 insertions(+), 14 deletions(-)