mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-17 06:59:56 -05:00
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:
parent
2385efef61
commit
190081782c
3 changed files with 66 additions and 10 deletions
|
|
@ -654,6 +654,7 @@ static void thread_func(void *userdata) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (revents & (POLLERR|POLLNVAL|POLLHUP)) {
|
if (revents & (POLLERR|POLLNVAL|POLLHUP)) {
|
||||||
|
|
||||||
if (revents & POLLERR)
|
if (revents & POLLERR)
|
||||||
pa_log_warn("Got POLLERR from ALSA");
|
pa_log_warn("Got POLLERR from ALSA");
|
||||||
if (revents & POLLNVAL)
|
if (revents & POLLNVAL)
|
||||||
|
|
@ -661,8 +662,35 @@ static void thread_func(void *userdata) {
|
||||||
if (revents & POLLHUP)
|
if (revents & POLLHUP)
|
||||||
pa_log_warn("Got POLLHUP from ALSA");
|
pa_log_warn("Got POLLHUP from ALSA");
|
||||||
|
|
||||||
|
/* 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;
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -636,6 +636,7 @@ static void thread_func(void *userdata) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (revents & (POLLERR|POLLNVAL|POLLHUP)) {
|
if (revents & (POLLERR|POLLNVAL|POLLHUP)) {
|
||||||
|
|
||||||
if (revents & POLLERR)
|
if (revents & POLLERR)
|
||||||
pa_log_warn("Got POLLERR from ALSA");
|
pa_log_warn("Got POLLERR from ALSA");
|
||||||
if (revents & POLLNVAL)
|
if (revents & POLLNVAL)
|
||||||
|
|
@ -643,8 +644,35 @@ static void thread_func(void *userdata) {
|
||||||
if (revents & POLLHUP)
|
if (revents & POLLHUP)
|
||||||
pa_log_warn("Got POLLHUP from ALSA");
|
pa_log_warn("Got POLLHUP from ALSA");
|
||||||
|
|
||||||
|
/* 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;
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue