mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-10-29 05:40:25 -04:00
pcm: hw: add a helper function to request hwsync without side-effects
SNDRV_PCM_IOCTL_SYNC_PTR command for ioctl(2) with SNDRV_PCM_SYNC_PTR_HWSYNC flag has an effect to update hw_ptr. This is an alternative of SNDRV_PCM_IOCTL_HWSYNC but caller can get current status simultaneously. This commit adds a helper function just to issue hwsync. To avoid side-effect to change appl_ptr and avail_min, this commit uses SNDRV_PCM_SYNC_PTR_APPL and SNDRV_PCM_SYNC_PTR_AVAIL_MIN flags. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
parent
78f3165a9e
commit
8a3df40bce
1 changed files with 17 additions and 2 deletions
|
|
@ -151,6 +151,21 @@ static int sync_ptr(snd_pcm_hw_t *hw, unsigned int flags)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int request_hwsync(snd_pcm_hw_t *hw)
|
||||
{
|
||||
if (!hw->mmap_status_fallbacked)
|
||||
return 0;
|
||||
|
||||
/*
|
||||
* Query both of control/status data to avoid unexpected change of
|
||||
* control data in kernel space.
|
||||
*/
|
||||
return sync_ptr1(hw,
|
||||
SNDRV_PCM_SYNC_PTR_HWSYNC |
|
||||
SNDRV_PCM_SYNC_PTR_APPL |
|
||||
SNDRV_PCM_SYNC_PTR_AVAIL_MIN);
|
||||
}
|
||||
|
||||
static int query_status_and_control_data(snd_pcm_hw_t *hw)
|
||||
{
|
||||
if (!hw->mmap_control_fallbacked)
|
||||
|
|
@ -593,8 +608,8 @@ static int snd_pcm_hw_hwsync(snd_pcm_t *pcm)
|
|||
snd_pcm_hw_t *hw = pcm->private_data;
|
||||
int fd = hw->fd, err;
|
||||
if (SNDRV_PROTOCOL_VERSION(2, 0, 3) <= hw->version) {
|
||||
if (hw->sync_ptr) {
|
||||
err = sync_ptr1(hw, SNDRV_PCM_SYNC_PTR_HWSYNC);
|
||||
if (hw->mmap_status_fallbacked) {
|
||||
err = request_hwsync(hw);
|
||||
if (err < 0)
|
||||
return err;
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue