From 4b88168edbbc60aeb28ee6d217d8ecacfdc649aa Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Mon, 27 Feb 2012 04:31:03 -0800 Subject: Use a switch to handle the ALSA PCM state --- Alc/backends/alsa.c | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) (limited to 'Alc/backends/alsa.c') diff --git a/Alc/backends/alsa.c b/Alc/backends/alsa.c index 916d5882..150ebc72 100644 --- a/Alc/backends/alsa.c +++ b/Alc/backends/alsa.c @@ -397,17 +397,29 @@ static DevMap *probe_devices(snd_pcm_stream_t stream, ALuint *count) static int verify_state(snd_pcm_t *handle) { snd_pcm_state_t state = snd_pcm_state(handle); - if(state == SND_PCM_STATE_DISCONNECTED) - return -ENODEV; - if(state == SND_PCM_STATE_XRUN) - { - int err = snd_pcm_recover(handle, -EPIPE, 1); - if(err < 0) return err; - } - else if(state == SND_PCM_STATE_SUSPENDED) + int err; + + switch(state) { - int err = snd_pcm_recover(handle, -ESTRPIPE, 1); - if(err < 0) return err; + case SND_PCM_STATE_OPEN: + case SND_PCM_STATE_SETUP: + case SND_PCM_STATE_PREPARED: + case SND_PCM_STATE_RUNNING: + case SND_PCM_STATE_DRAINING: + case SND_PCM_STATE_PAUSED: + /* All Okay */ + break; + + case SND_PCM_STATE_XRUN: + if((err=snd_pcm_recover(handle, -EPIPE, 1)) < 0) + return err; + break; + case SND_PCM_STATE_SUSPENDED: + if((err=snd_pcm_recover(handle, -ESTRPIPE, 1)) < 0) + return err; + break; + case SND_PCM_STATE_DISCONNECTED: + return -ENODEV; } return state; -- cgit v1.2.3