From c1446758c76a8319382aad3b56df09c45d51bba4 Mon Sep 17 00:00:00 2001 From: Ricardo Biehl Pasquali Date: Tue, 18 Dec 2018 23:13:05 -0200 Subject: pcm: Call HWSYNC ioctl when status is mmaped When hardware pointer update is requested and status structure is mmaped, call HWSYNC ioctl. Signed-off-by: Ricardo Biehl Pasquali --- src/pcm.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src/pcm.c') diff --git a/src/pcm.c b/src/pcm.c index 8ef5a48..4bc86aa 100644 --- a/src/pcm.c +++ b/src/pcm.c @@ -516,14 +516,23 @@ unsigned int pcm_frames_to_bytes(const struct pcm *pcm, unsigned int frames) static int pcm_sync_ptr(struct pcm *pcm, int flags) { - if (pcm->sync_ptr) { + if (pcm->sync_ptr == NULL) { + /* status and control are mmaped */ + + if (flags & SNDRV_PCM_SYNC_PTR_HWSYNC) { + if (ioctl(pcm->fd, SNDRV_PCM_IOCTL_HWSYNC) == -1) { + oops(pcm, errno, "failed to sync hardware pointer"); + return -1; + } + } + } else { pcm->sync_ptr->flags = flags; if (ioctl(pcm->fd, SNDRV_PCM_IOCTL_SYNC_PTR, pcm->sync_ptr) < 0) { oops(pcm, errno, "failed to sync mmap ptr"); return -1; } - return 0; } + return 0; } -- cgit v1.2.3