mirror of
https://github.com/openharmony/third_party_tinyalsa.git
synced 2026-07-21 03:05:31 -04:00
Merge pull request #131 from pasqualirb/master
pcm: Allow to wait if capture is not running
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user