diff options
author | Miguel Gaio <mgaio35@gmail.com> | 2018-07-17 13:30:24 +0200 |
---|---|---|
committer | Miguel Gaio <mgaio35@gmail.com> | 2018-07-17 13:39:53 +0200 |
commit | cf5f063f5cce1b21f42be67f3433c0c4db897ff6 (patch) | |
tree | e6138e9700fb692dce5db42b6d5780923ab945e7 /src | |
parent | c9f97daf129f4466351c82c85d377d96a1ab9a6f (diff) |
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 <mgaio35@gmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/pcm.c | 11 |
1 files changed, 7 insertions, 4 deletions
@@ -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; |