* [PATCH] ALSA: uapi: pcm: control the filling of the silence samples for drain
@ 2023-05-02 11:55 Jaroslav Kysela
2023-05-02 14:05 ` Takashi Iwai
2023-05-08 13:24 ` Takashi Iwai
0 siblings, 2 replies; 3+ messages in thread
From: Jaroslav Kysela @ 2023-05-02 11:55 UTC (permalink / raw)
To: ALSA development; +Cc: Takashi Iwai
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 drain ioctl.
Actually, the configurable silencing is going to be implemented in the user
space [1], but drivers (hardware) may not require this operation. Those flags
do the bidirectional setup for this operation:
1) driver may notify the presence of the perfect drain
2) user space may not require the filling of the silence samples to inhibit clicks
If we decide to move this operation to the kernel space in future, the
SNDRV_PCM_INFO_PERFECT_DRAIN flag may handle this situation without
double "silence" processing (user + kernel space).
The ALSA API should be universal, so forcing the behaviour (modifying of
the ring buffer with any samples) for the drain operation is not ideal.
[1] https://lore.kernel.org/alsa-devel/20230502115010.986325-1-perex@perex.cz/
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
---
include/uapi/sound/asound.h | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/include/uapi/sound/asound.h b/include/uapi/sound/asound.h
index 0aa955aa8246..e4b0f95694c5 100644
--- a/include/uapi/sound/asound.h
+++ b/include/uapi/sound/asound.h
@@ -274,6 +274,7 @@ typedef int __bitwise snd_pcm_subformat_t;
#define SNDRV_PCM_INFO_DOUBLE 0x00000004 /* Double buffering needed for PCM start/stop */
#define SNDRV_PCM_INFO_BATCH 0x00000010 /* double buffering */
#define SNDRV_PCM_INFO_SYNC_APPLPTR 0x00000020 /* need the explicit sync of appl_ptr update */
+#define SNDRV_PCM_INFO_PERFECT_DRAIN 0x00000040 /* silencing at the end of stream is not required */
#define SNDRV_PCM_INFO_INTERLEAVED 0x00000100 /* channels are interleaved */
#define SNDRV_PCM_INFO_NONINTERLEAVED 0x00000200 /* channels are not interleaved */
#define SNDRV_PCM_INFO_COMPLEX 0x00000400 /* complex frame organization (mmap only) */
@@ -383,6 +384,9 @@ typedef int snd_pcm_hw_param_t;
#define SNDRV_PCM_HW_PARAMS_NORESAMPLE (1<<0) /* avoid rate resampling */
#define SNDRV_PCM_HW_PARAMS_EXPORT_BUFFER (1<<1) /* export buffer */
#define SNDRV_PCM_HW_PARAMS_NO_PERIOD_WAKEUP (1<<2) /* disable period wakeups */
+#define SNDRV_PCM_HW_PARAMS_NO_DRAIN_SILENCE (1<<3) /* supress drain with the filling
+ * of the silence samples
+ */
struct snd_interval {
unsigned int min, max;
--
2.39.2
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] ALSA: uapi: pcm: control the filling of the silence samples for drain
2023-05-02 11:55 [PATCH] ALSA: uapi: pcm: control the filling of the silence samples for drain Jaroslav Kysela
@ 2023-05-02 14:05 ` Takashi Iwai
2023-05-08 13:24 ` Takashi Iwai
1 sibling, 0 replies; 3+ messages in thread
From: Takashi Iwai @ 2023-05-02 14:05 UTC (permalink / raw)
To: Jaroslav Kysela; +Cc: ALSA development
On Tue, 02 May 2023 13:55:36 +0200,
Jaroslav Kysela wrote:
>
> 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 drain ioctl.
> Actually, the configurable silencing is going to be implemented in the user
> space [1], but drivers (hardware) may not require this operation. Those flags
> do the bidirectional setup for this operation:
>
> 1) driver may notify the presence of the perfect drain
> 2) user space may not require the filling of the silence samples to inhibit clicks
>
> If we decide to move this operation to the kernel space in future, the
> SNDRV_PCM_INFO_PERFECT_DRAIN flag may handle this situation without
> double "silence" processing (user + kernel space).
>
> The ALSA API should be universal, so forcing the behaviour (modifying of
> the ring buffer with any samples) for the drain operation is not ideal.
>
> [1] https://lore.kernel.org/alsa-devel/20230502115010.986325-1-perex@perex.cz/
>
> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Looks good to me.
Will apply once after 6.5 devel branch is opened.
thanks,
Takashi
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ALSA: uapi: pcm: control the filling of the silence samples for drain
2023-05-02 11:55 [PATCH] ALSA: uapi: pcm: control the filling of the silence samples for drain Jaroslav Kysela
2023-05-02 14:05 ` Takashi Iwai
@ 2023-05-08 13:24 ` Takashi Iwai
1 sibling, 0 replies; 3+ messages in thread
From: Takashi Iwai @ 2023-05-08 13:24 UTC (permalink / raw)
To: Jaroslav Kysela; +Cc: ALSA development
On Tue, 02 May 2023 13:55:36 +0200,
Jaroslav Kysela wrote:
>
> 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 drain ioctl.
> Actually, the configurable silencing is going to be implemented in the user
> space [1], but drivers (hardware) may not require this operation. Those flags
> do the bidirectional setup for this operation:
>
> 1) driver may notify the presence of the perfect drain
> 2) user space may not require the filling of the silence samples to inhibit clicks
>
> If we decide to move this operation to the kernel space in future, the
> SNDRV_PCM_INFO_PERFECT_DRAIN flag may handle this situation without
> double "silence" processing (user + kernel space).
>
> The ALSA API should be universal, so forcing the behaviour (modifying of
> the ring buffer with any samples) for the drain operation is not ideal.
>
> [1] https://lore.kernel.org/alsa-devel/20230502115010.986325-1-perex@perex.cz/
>
> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Now applied to for-next branch (with a typo fix in the comment).
thanks,
Takashi
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-05-08 13:25 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-02 11:55 [PATCH] ALSA: uapi: pcm: control the filling of the silence samples for drain Jaroslav Kysela
2023-05-02 14:05 ` Takashi Iwai
2023-05-08 13:24 ` Takashi Iwai
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox