aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2010-01-06 22:50:30 -0800
committerChris Robinson <[email protected]>2010-01-06 22:50:30 -0800
commitc90616b963ed321d8e3e0cfb5a57c80c6637d58a (patch)
tree9084292d612ffac10f29d29152152319dcd9cbad
parent0ceaa01c3de75c946ff2e7591e7f69b28ec00409 (diff)
Use snd_pcm_recover to recover from certain device errors
-rw-r--r--Alc/alsa.c21
1 files changed, 6 insertions, 15 deletions
diff --git a/Alc/alsa.c b/Alc/alsa.c
index cc7bef27..b9bb6259 100644
--- a/Alc/alsa.c
+++ b/Alc/alsa.c
@@ -92,6 +92,7 @@ MAKE_FUNC(snd_pcm_mmap_commit);
MAKE_FUNC(snd_pcm_readi);
MAKE_FUNC(snd_pcm_writei);
MAKE_FUNC(snd_pcm_drain);
+MAKE_FUNC(snd_pcm_recover);
MAKE_FUNC(snd_pcm_info_malloc);
MAKE_FUNC(snd_pcm_info_free);
MAKE_FUNC(snd_pcm_info_set_device);
@@ -185,6 +186,7 @@ LOAD_FUNC(snd_pcm_mmap_commit);
LOAD_FUNC(snd_pcm_readi);
LOAD_FUNC(snd_pcm_writei);
LOAD_FUNC(snd_pcm_drain);
+LOAD_FUNC(snd_pcm_recover);
LOAD_FUNC(snd_pcm_info_malloc);
LOAD_FUNC(snd_pcm_info_free);
@@ -223,22 +225,11 @@ void alsa_unload(void)
static int xrun_recovery(snd_pcm_t *handle, int err)
{
- if (err == -EPIPE)
- { /* under-run */
- err = psnd_pcm_prepare(handle);
- if (err < 0)
- AL_PRINT("prepare failed: %s\n", psnd_strerror(err));
- }
- else if (err == -ESTRPIPE)
+ if(err == -EINTR || err == -EPIPE || err == -ESTRPIPE)
{
- while ((err = psnd_pcm_resume(handle)) == -EAGAIN)
- Sleep(1); /* wait until the suspend flag is released */
- if (err < 0)
- {
- err = psnd_pcm_prepare(handle);
- if (err < 0)
- AL_PRINT("prepare failed: %s\n", psnd_strerror(err));
- }
+ err = psnd_pcm_recover(handle, err, 1);
+ if(err < 0)
+ AL_PRINT("recover failed: %s\n", psnd_strerror(err));
}
return err;
}