static void ALSA_MMap_Submit (soundcardinfo_t *sc, int start, int end) { int state; int count = end - start; const snd_pcm_channel_area_t *areas; snd_pcm_uframes_t nframes; snd_pcm_uframes_t offset; nframes = count / sc->sn.numchannels; psnd_pcm_avail_update (sc->handle); psnd_pcm_mmap_begin (sc->handle, &areas, &offset, &nframes); state = psnd_pcm_state (sc->handle); switch (state) { case SND_PCM_STATE_PREPARED: psnd_pcm_mmap_commit (sc->handle, offset, nframes); psnd_pcm_start (sc->handle); break; case SND_PCM_STATE_RUNNING: psnd_pcm_mmap_commit (sc->handle, offset, nframes); break; default: break; } }
static int verify_state(snd_pcm_t *handle) { snd_pcm_state_t state = psnd_pcm_state(handle); if(state == SND_PCM_STATE_DISCONNECTED) return -ENODEV; if(state == SND_PCM_STATE_XRUN) { int err = xrun_recovery(handle, -EPIPE); if(err < 0) return err; } else if(state == SND_PCM_STATE_SUSPENDED) { int err = xrun_recovery(handle, -ESTRPIPE); if(err < 0) return err; } return state; }