diff options
author | Jaroslav Kysela <perex@perex.cz> | 2023-05-02 10:34:41 +0200 |
---|---|---|
committer | Jaroslav Kysela <perex@perex.cz> | 2023-05-03 15:58:56 +0200 |
commit | 264d6c43ee382bf4d6b1cf35c3920a8793c575e2 (patch) | |
tree | c09afcb8c385a65524a3864f2bd5c1f967914c78 /src/pcm/pcm.c | |
parent | 90e25887d24661a0bdc169b7b14525a97a4645c1 (diff) | |
download | alsa-lib-264d6c43ee382bf4d6b1cf35c3920a8793c575e2.tar.gz |
pcm: hw: introduce SNDRV_PCM_HW_PARAMS_DRAIN_SILENCE
The application may not require to touch the playback
sample stream for the drain operation at all. In this case,
the application is responsible to setup a silencing mechanism
for the playback or another graceful stop (like using the
rewind operation).
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Diffstat (limited to 'src/pcm/pcm.c')
-rw-r--r-- | src/pcm/pcm.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/pcm/pcm.c b/src/pcm/pcm.c index d387da3d..997a8a6a 100644 --- a/src/pcm/pcm.c +++ b/src/pcm/pcm.c @@ -4959,6 +4959,43 @@ int snd_pcm_hw_params_get_period_wakeup(snd_pcm_t *pcm, snd_pcm_hw_params_t *par } /** + * \brief Restrict a configuration space to fill the end of playback stream with silence when drain() is invoked + * \param pcm PCM handle + * \param params Configuration space + * \param val 0 = disabled, 1 = enabled (default) fill the end of the playback stream with silence when drain() is invoked + * \return Zero on success, otherwise a negative error code. + * + * When disabled, the application should handle the end of stream gracefully + * (fill the silent samples to align to the period size plus some extra + * samples for hardware / driver without perfect drain). Note that the rewind + * may be used for this purpose or the sw_params silencing mechanism. + */ +int snd_pcm_hw_params_set_drain_silence(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val) +{ + assert(pcm && params); + if (val) + params->flags &= ~SND_PCM_HW_PARAMS_NO_DRAIN_SILENCE; + else + params->flags |= SND_PCM_HW_PARAMS_NO_DRAIN_SILENCE; + params->rmask = ~0; + return snd_pcm_hw_refine(pcm, params); +} + +/** + * \brief Extract drain with the filling of silence samples from a configuration space + * \param pcm PCM handle + * \param params Configuration space + * \param val 0 = disabled, 1 = enabled + * \return 0 otherwise a negative error code + */ +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; + return 0; +} + +/** * \brief Extract period time from a configuration space * \param params Configuration space * \param val Returned approximate period duration in us |