diff options
author | Taylor Holberton <tay10r@protonmail.com> | 2019-07-07 21:15:08 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-07 21:15:08 -0400 |
commit | 1923b9b0fd7116ba235a812ef00fd6c7c9ed363d (patch) | |
tree | 5eba4bcf2621f74e8d200fc69382ac184d3483f8 /src | |
parent | 9ec09d5124bc1d1c081d8c910ace663e1f398649 (diff) | |
parent | c6c0d788a835277b190d267fa4d6b338e4bba30e (diff) |
Merge pull request #131 from pasqualirb/master
pcm: Allow to wait if capture is not running
Diffstat (limited to 'src')
-rw-r--r-- | src/pcm.c | 21 |
1 files changed, 10 insertions, 11 deletions
@@ -1282,17 +1282,16 @@ int pcm_mmap_transfer(struct pcm *pcm, void *buffer, unsigned int frames) return -1; state = pcm->mmap_status->state; - /* start capture if frames >= threshold */ - if (!is_playback && state == PCM_STATE_PREPARED) { - if (frames >= pcm->config.start_threshold) { - err = ioctl(pcm->fd, SNDRV_PCM_IOCTL_START); - if (err == -1) - return -1; - /* state = PCM_STATE_RUNNING */ - } else { - /* nothing to do */ - return 0; - } + /* + * If frames < start_threshold, wait indefinitely. + * Another thread may start capture + */ + if (!is_playback && state == PCM_STATE_PREPARED && + frames >= pcm->config.start_threshold) { + err = ioctl(pcm->fd, SNDRV_PCM_IOCTL_START); + if (err == -1) + return -1; + /* state = PCM_STATE_RUNNING */ } avail = pcm_mmap_avail(pcm); |