diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/pcm.c | 24 |
1 files changed, 14 insertions, 10 deletions
@@ -623,6 +623,16 @@ static int pcm_sync_ptr(struct pcm *pcm, int flags) return 0; } +int pcm_state(struct pcm *pcm) +{ + // Update the state only. Do not sync HW sync. + int err = pcm_sync_ptr(pcm, SNDRV_PCM_SYNC_PTR_APPL | SNDRV_PCM_SYNC_PTR_AVAIL_MIN); + if (err < 0) + return err; + + return pcm->mmap_status->state; +} + static int pcm_hw_mmap_status(struct pcm *pcm) { if (pcm->sync_ptr) @@ -1196,6 +1206,10 @@ int pcm_prepare(struct pcm *pcm) */ int pcm_start(struct pcm *pcm) { + if (pcm_state(pcm) == PCM_STATE_SETUP && pcm_prepare(pcm) != 0) { + return -1; + } + /* set appl_ptr and avail_min in kernel */ if (pcm_sync_ptr(pcm, 0) < 0) return -1; @@ -1409,16 +1423,6 @@ again: return 0; } -int pcm_state(struct pcm *pcm) -{ - // Update the state only. Do not sync HW sync. - int err = pcm_sync_ptr(pcm, SNDRV_PCM_SYNC_PTR_APPL | SNDRV_PCM_SYNC_PTR_AVAIL_MIN); - if (err < 0) - return err; - - return pcm->mmap_status->state; -} - /** Waits for frames to be available for read or write operations. * @param pcm A PCM handle. * @param timeout The maximum amount of time to wait for, in terms of milliseconds. |