Properly handle if ALSA sends us an POLLERR event, this should allow us to survive a system suspend cycle better

git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/lennart@1941 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
Lennart Poettering 2007-10-17 16:54:46 +00:00
parent 2385efef61
commit 190081782c
3 changed files with 66 additions and 10 deletions

View file

@ -654,6 +654,7 @@ static void thread_func(void *userdata) {
}
if (revents & (POLLERR|POLLNVAL|POLLHUP)) {
if (revents & POLLERR)
pa_log_warn("Got POLLERR from ALSA");
if (revents & POLLNVAL)
@ -661,7 +662,34 @@ static void thread_func(void *userdata) {
if (revents & POLLHUP)
pa_log_warn("Got POLLHUP from ALSA");
goto fail;
/* Try to recover from this error */
switch (snd_pcm_state(u->pcm_handle)) {
case SND_PCM_STATE_XRUN:
if ((err = snd_pcm_recover(u->pcm_handle, -EPIPE, 1)) != 0) {
pa_log_warn("Could not recover from POLLERR|POLLNVAL|POLLHUP and XRUN: %s", snd_strerror(err));
goto fail;
}
break;
case SND_PCM_STATE_SUSPENDED:
if ((err = snd_pcm_recover(u->pcm_handle, -ESTRPIPE, 1)) != 0) {
pa_log_warn("Could not recover from POLLERR|POLLNVAL|POLLHUP and SUSPENDED: %s", snd_strerror(err));
goto fail;
}
break;
default:
snd_pcm_drop(u->pcm_handle);
if ((err = snd_pcm_prepare(u->pcm_handle)) < 0) {
pa_log_warn("Could not recover from POLLERR|POLLNVAL|POLLHUP with snd_pcm_prepare(): %s", snd_strerror(err));
goto fail;
}
break;
}
}
}
}

View file

@ -636,6 +636,7 @@ static void thread_func(void *userdata) {
}
if (revents & (POLLERR|POLLNVAL|POLLHUP)) {
if (revents & POLLERR)
pa_log_warn("Got POLLERR from ALSA");
if (revents & POLLNVAL)
@ -643,7 +644,34 @@ static void thread_func(void *userdata) {
if (revents & POLLHUP)
pa_log_warn("Got POLLHUP from ALSA");
goto fail;
/* Try to recover from this error */
switch (snd_pcm_state(u->pcm_handle)) {
case SND_PCM_STATE_XRUN:
if ((err = snd_pcm_recover(u->pcm_handle, -EPIPE, 1)) != 0) {
pa_log_warn("Could not recover from POLLERR|POLLNVAL|POLLHUP and XRUN: %s", snd_strerror(err));
goto fail;
}
break;
case SND_PCM_STATE_SUSPENDED:
if ((err = snd_pcm_recover(u->pcm_handle, -ESTRPIPE, 1)) != 0) {
pa_log_warn("Could not recover from POLLERR|POLLNVAL|POLLHUP and SUSPENDED: %s", snd_strerror(err));
goto fail;
}
break;
default:
snd_pcm_drop(u->pcm_handle);
if ((err = snd_pcm_prepare(u->pcm_handle)) < 0) {
pa_log_warn("Could not recover from POLLERR|POLLNVAL|POLLHUP with snd_pcm_prepare(): %s", snd_strerror(err));
goto fail;
}
break;
}
}
}
}