mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-11-03 09:01:52 -05:00
support for period wakeup disabling
Add API to disable period wakeups. Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@intel.com> Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
This commit is contained in:
parent
70dded6aba
commit
7c99bd24bc
4 changed files with 79 additions and 1 deletions
|
|
@ -726,8 +726,11 @@ int snd_pcm_nonblock(snd_pcm_t *pcm, int nonblock)
|
|||
return err;
|
||||
if (nonblock)
|
||||
pcm->mode |= SND_PCM_NONBLOCK;
|
||||
else
|
||||
else {
|
||||
if (pcm->hw_flags & SND_PCM_HW_PARAMS_NO_PERIOD_WAKEUP)
|
||||
return -EINVAL;
|
||||
pcm->mode &= ~SND_PCM_NONBLOCK;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -3080,6 +3083,23 @@ int snd_pcm_hw_params_can_sync_start(const snd_pcm_hw_params_t *params)
|
|||
return !!(params->info & SNDRV_PCM_INFO_SYNC_START);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Check if hardware can disable period wakeups
|
||||
* \param params Configuration space
|
||||
* \return Boolean value
|
||||
* \retval 0 Hardware cannot disable period wakeups
|
||||
* \retval 1 Hardware can disable period wakeups
|
||||
*/
|
||||
int snd_pcm_hw_params_can_disable_period_wakeup(const snd_pcm_hw_params_t *params)
|
||||
{
|
||||
assert(params);
|
||||
if (CHECK_SANITY(params->info == ~0U)) {
|
||||
SNDMSG("invalid PCM info field");
|
||||
return 0; /* FIXME: should be a negative error? */
|
||||
}
|
||||
return !!(params->info & SNDRV_PCM_INFO_NO_PERIOD_WAKEUP);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Get rate exact info from a configuration space
|
||||
* \param params Configuration space
|
||||
|
|
@ -4199,6 +4219,56 @@ int snd_pcm_hw_params_get_export_buffer(snd_pcm_t *pcm, snd_pcm_hw_params_t *par
|
|||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Restrict a configuration space to settings without period wakeups
|
||||
* \param pcm PCM handle
|
||||
* \param params Configuration space
|
||||
* \param val 0 = disable, 1 = enable (default) period wakeup
|
||||
* \return Zero on success, otherwise a negative error code.
|
||||
*
|
||||
* This function must be called only on devices where non-blocking mode is
|
||||
* enabled.
|
||||
*
|
||||
* To check whether the hardware does support disabling period wakeups, call
|
||||
* #snd_pcm_hw_params_can_disable_period_wakeup(). If the hardware does not
|
||||
* support this mode, standard period wakeups will be generated.
|
||||
*
|
||||
* Even with disabled period wakeups, the period size/time/count parameters
|
||||
* are valid; it is suggested to use #snd_pcm_hw_params_set_period_size_last().
|
||||
*
|
||||
* When period wakeups are disabled, the application must not use any functions
|
||||
* that could block on this device. The use of poll should be limited to error
|
||||
* cases. The application needs to use an external event or a timer to
|
||||
* check the state of the ring buffer and refill it apropriately.
|
||||
*/
|
||||
int snd_pcm_hw_params_set_period_wakeup(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val)
|
||||
{
|
||||
assert(pcm && params);
|
||||
|
||||
if (!val) {
|
||||
if (!(pcm->mode & SND_PCM_NONBLOCK))
|
||||
return -EINVAL;
|
||||
params->flags |= SND_PCM_HW_PARAMS_NO_PERIOD_WAKEUP;
|
||||
} else
|
||||
params->flags &= ~SND_PCM_HW_PARAMS_NO_PERIOD_WAKEUP;
|
||||
|
||||
return snd_pcm_hw_refine(pcm, params);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Extract period wakeup flag from a configuration space
|
||||
* \param pcm PCM handle
|
||||
* \param params Configuration space
|
||||
* \param val 0 = disabled, 1 = enabled period wakeups
|
||||
* \return Zero on success, otherwise a negative error code.
|
||||
*/
|
||||
int snd_pcm_hw_params_get_period_wakeup(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_PERIOD_WAKEUP ? 0 : 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Extract period time from a configuration space
|
||||
* \param params Configuration space
|
||||
|
|
|
|||
|
|
@ -91,9 +91,12 @@ typedef enum sndrv_pcm_hw_param snd_pcm_hw_param_t;
|
|||
#define SND_PCM_INFO_JOINT_DUPLEX SNDRV_PCM_INFO_JOINT_DUPLEX
|
||||
/** device can do a kind of synchronized start */
|
||||
#define SND_PCM_INFO_SYNC_START SNDRV_PCM_INFO_SYNC_START
|
||||
/** device can disable period wakeups */
|
||||
#define SND_PCM_INFO_NO_PERIOD_WAKEUP SNDRV_PCM_INFO_NO_PERIOD_WAKEUP
|
||||
|
||||
#define SND_PCM_HW_PARAMS_NORESAMPLE SNDRV_PCM_HW_PARAMS_NORESAMPLE
|
||||
#define SND_PCM_HW_PARAMS_EXPORT_BUFFER SNDRV_PCM_HW_PARAMS_EXPORT_BUFFER
|
||||
#define SND_PCM_HW_PARAMS_NO_PERIOD_WAKEUP SNDRV_PCM_HW_PARAMS_NO_PERIOD_WAKEUP
|
||||
|
||||
#define SND_PCM_INFO_MONOTONIC 0x80000000
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue