diff options
author | Taylor Holberton <taylorcholberton@gmail.com> | 2018-07-20 18:13:30 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-20 18:13:30 -0700 |
commit | bfed9859c984b964a2f28dc745a8196b753c17a6 (patch) | |
tree | e6138e9700fb692dce5db42b6d5780923ab945e7 | |
parent | 67b9210d344c34e8d1aa0cfe638abce71c5221ca (diff) | |
parent | cf5f063f5cce1b21f42be67f3433c0c4db897ff6 (diff) |
Merge pull request #115 from mgaio/fix/pcm_link
Fix/pcm link
-rw-r--r-- | src/pcm.c | 13 |
1 files changed, 8 insertions, 5 deletions
@@ -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) @@ -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; |