aboutsummaryrefslogtreecommitdiffstats
path: root/Alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2012-02-27 04:31:03 -0800
committerChris Robinson <[email protected]>2012-02-27 04:31:03 -0800
commit4b88168edbbc60aeb28ee6d217d8ecacfdc649aa (patch)
tree249fa54ae9e4f6fcea24c5dd7fbc82fe4f76ae4d /Alc
parentf29fbdf088f8174b079758defc752cadd2f039ab (diff)
Use a switch to handle the ALSA PCM state
Diffstat (limited to 'Alc')
-rw-r--r--Alc/backends/alsa.c32
1 files changed, 22 insertions, 10 deletions
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;