mirror of
https://github.com/openharmony/third_party_tinyalsa.git
synced 2026-07-19 23:33:30 -04:00
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>
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user