From: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
To: Jaroslav Kysela <perex@perex.cz>
Cc: ALSA development <alsa-devel@alsa-project.org>
Subject: Re: [PATCH alsa-lib 4/4] pcm: hw: introduce SNDRV_PCM_HW_PARAMS_DRAIN_SILENCE
Date: Wed, 3 May 2023 13:26:29 +0200 [thread overview]
Message-ID: <ZFJE5SQQbVnRqRRk@ugly> (raw)
In-Reply-To: <20230502115010.986325-5-perex@perex.cz>
On Tue, May 02, 2023 at 01:50:10PM +0200, Jaroslav Kysela wrote:
>The application may not require to touch the sample stream
>for the drain operation at all. Handle this situation
>in alsa-lib.
>
i find this too vague.
This allows an application which uses an mmapped buffer to inform us
that it is handling the silence padding itself.
>Signed-off-by: Jaroslav Kysela <perex@perex.cz>
>---
> include/sound/uapi/asound.h | 3 +++
> src/pcm/pcm.c | 32 ++++++++++++++++++++++++++++++++
> src/pcm/pcm_hw.c | 3 ++-
> src/pcm/pcm_local.h | 1 +
> 4 files changed, 38 insertions(+), 1 deletion(-)
>
>diff --git a/include/sound/uapi/asound.h b/include/sound/uapi/asound.h
>index 0b8834f2..f970179e 100644
>--- a/include/sound/uapi/asound.h
>+++ b/include/sound/uapi/asound.h
>@@ -390,6 +390,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
>+ */
"suppress automatic silence fill when draining playback"
>--- a/src/pcm/pcm.c
>+++ b/src/pcm/pcm.c
>@@ -4958,6 +4958,38 @@ int snd_pcm_hw_params_get_period_wakeup(snd_pcm_t *pcm, snd_pcm_hw_params_t *par
> return 0;
> }
>
>+/**
>+ * \brief Restrict a configuration space to allow the drain with the
>filling of silence samples
>
there is no way i'd understand what this means. in fact, i'm having a
hard time even though i more or less know it already.
>+ * \param pcm PCM handle
>+ * \param params Configuration space
>+ * \param val 0 = disable, 1 = enable (default) drain with the filling of silence samples
>
"padding the playback buffer with silence when drain() is invoked"
>+ * \return 0 otherwise a negative error code
add description:
"When disabled, the application must ensure that enough samples are
silenced, as most hardware will read beyond the application pointer when
drain() is invoked."
>+/**
>+ * \brief Extract drain with the filling of silence samples from a configuration space
>
this is also kinda incomprehensible.
>+ * \param pcm PCM handle
>+ * \param params Configuration space
>+ * \param val 0 = disable, 1 = enable
>
as this returns the status quo, this should be disabled/enabled.
>+ * \return 0 otherwise a negative error code
>
there is no "otherwise" here.
>+ */
>+int snd_pcm_hw_params_get_drain_silence(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val)
>+{
>+ assert(pcm && params && val);
>+ *val = params->flags & SND_PCM_HW_PARAMS_NO_DRAIN_SILENCE ? 0 : 1;
>
i know i'm paranoid, but i'd put extra parens around the condition.
>+ return 0;
>+}
>+
>--- a/src/pcm/pcm_hw.c
>+++ b/src/pcm/pcm_hw.c
>@@ -399,7 +399,8 @@ static int snd_pcm_hw_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params)
>- hw->perfect_drain = !!(params->info & SND_PCM_INFO_PERFECT_DRAIN);
>+ hw->perfect_drain = !!(params->info & SND_PCM_INFO_PERFECT_DRAIN) ||
>+ !!(params->flags & SND_PCM_HW_PARAMS_NO_DRAIN_SILENCE);
>
pedantically, you can remove the double negations as this point.
regards
prev parent reply other threads:[~2023-05-03 11:27 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-02 11:50 [PATCH alsa-lib 0/4] pcm: hw: implement explicit silencing for snd_pcm_drain Jaroslav Kysela
2023-05-02 11:50 ` [PATCH alsa-lib 1/4] pcm: hw: setup explicit silencing for snd_pcm_drain by default Jaroslav Kysela
2023-05-03 11:20 ` Oswald Buddenhagen
2023-05-03 20:19 ` Oswald Buddenhagen
2023-05-03 20:31 ` Jaroslav Kysela
2023-05-05 18:56 ` Oswald Buddenhagen
2023-05-02 11:50 ` [PATCH alsa-lib 2/4] pcm: hw: add drain_silence configuration keyword Jaroslav Kysela
2023-05-03 11:24 ` Oswald Buddenhagen
2023-05-03 14:22 ` Jaroslav Kysela
2023-05-03 15:39 ` Oswald Buddenhagen
2023-05-02 11:50 ` [PATCH alsa-lib 3/4] pcm: hw: introduce SNDRV_PCM_INFO_PERFECT_DRAIN Jaroslav Kysela
2023-05-03 11:25 ` Oswald Buddenhagen
2023-05-04 8:18 ` Takashi Iwai
2023-05-04 8:31 ` Jaroslav Kysela
2023-05-04 12:50 ` Takashi Iwai
2023-05-02 11:50 ` [PATCH alsa-lib 4/4] pcm: hw: introduce SNDRV_PCM_HW_PARAMS_DRAIN_SILENCE Jaroslav Kysela
2023-05-03 11:26 ` Oswald Buddenhagen [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZFJE5SQQbVnRqRRk@ugly \
--to=oswald.buddenhagen@gmx.de \
--cc=alsa-devel@alsa-project.org \
--cc=perex@perex.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox