From c9f97daf129f4466351c82c85d377d96a1ab9a6f Mon Sep 17 00:00:00 2001 From: Miguel Gaio Date: Tue, 17 Jul 2018 10:05:54 +0200 Subject: Corrected pcm_sync_ptr() on dma mmap coherent architecture It is valid to get null sync_ptr on dma mmap coherent architecture. In this case pcm_sync_ptr() is a nop. Signed-off-by: Miguel Gaio --- src/pcm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pcm.c b/src/pcm.c index f665cb4..7ea58bd 100644 --- a/src/pcm.c +++ b/src/pcm.c @@ -511,7 +511,7 @@ static int pcm_sync_ptr(struct pcm *pcm, int flags) } return 0; } - return -1; + return 0; } static int pcm_hw_mmap_status(struct pcm *pcm) -- cgit v1.2.3 From cf5f063f5cce1b21f42be67f3433c0c4db897ff6 Mon Sep 17 00:00:00 2001 From: Miguel Gaio Date: Tue, 17 Jul 2018 13:30:24 +0200 Subject: Fixed pcm_start when pcm is linked to other pcm device When pcm device is linked to other pcm device, the start call may be triggered by other pcm device. Handle this condition by checing pcm state before start call. Signed-off-by: Miguel Gaio --- src/pcm.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/pcm.c b/src/pcm.c index 7ea58bd..f1d733f 100644 --- a/src/pcm.c +++ b/src/pcm.c @@ -1203,11 +1203,14 @@ int pcm_start(struct pcm *pcm) if (prepare_error) return prepare_error; - if (pcm->flags & PCM_MMAP) - pcm_sync_ptr(pcm, 0); + /* if pcm is linked, it may be already started by other pcm */ + /* check pcm state is not in running state */ + pcm_sync_ptr(pcm, 0); - if (ioctl(pcm->fd, SNDRV_PCM_IOCTL_START) < 0) - return oops(pcm, errno, "cannot start channel"); + if (pcm->mmap_status->state != PCM_STATE_RUNNING) { + if (ioctl(pcm->fd, SNDRV_PCM_IOCTL_START) < 0) + return oops(pcm, errno, "cannot start channel"); + } pcm->running = 1; return 0; -- cgit v1.2.3