[pulseaudio-commits] r1941 - in /branches/lennart/src/modules: alsa-util.c module-alsa-sink.c module-alsa-source.c
svnmailer-noreply at 0pointer.de
svnmailer-noreply at 0pointer.de
Wed Oct 17 09:54:46 PDT 2007
Author: lennart
Date: Wed Oct 17 18:54:46 2007
New Revision: 1941
URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=1941&root=pulseaudio&view=rev
Log:
Properly handle if ALSA sends us an POLLERR event, this should allow us to survive a system suspend cycle better
Modified:
branches/lennart/src/modules/alsa-util.c
branches/lennart/src/modules/module-alsa-sink.c
branches/lennart/src/modules/module-alsa-source.c
Modified: branches/lennart/src/modules/alsa-util.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/modules/alsa-util.c?rev=1941&root=pulseaudio&r1=1940&r2=1941&view=diff
==============================================================================
--- branches/lennart/src/modules/alsa-util.c (original)
+++ branches/lennart/src/modules/alsa-util.c Wed Oct 17 18:54:46 2007
@@ -56,7 +56,7 @@
};
static void io_cb(pa_mainloop_api*a, pa_io_event* e, PA_GCC_UNUSED int fd, pa_io_event_flags_t events, void *userdata) {
-
+
struct pa_alsa_fdlist *fdl = userdata;
int err, i;
unsigned short revents;
@@ -139,7 +139,7 @@
if (fdl->ios) {
for (i = 0; i < fdl->num_fds; i++)
a->io_free(fdl->ios[i]);
-
+
if (num_fds != fdl->num_fds) {
pa_xfree(fdl->ios);
fdl->ios = NULL;
@@ -290,7 +290,7 @@
pa_assert(period_size);
snd_pcm_hw_params_alloca(&hwparams);
-
+
buffer_size = *periods * *period_size;
if ((ret = snd_pcm_hw_params_any(pcm_handle, hwparams)) < 0 ||
@@ -302,11 +302,11 @@
if ((ret = snd_pcm_hw_params_set_access(pcm_handle, hwparams, SND_PCM_ACCESS_RW_INTERLEAVED)) < 0)
goto finish;
- } else if ((ret = snd_pcm_hw_params_set_access(pcm_handle, hwparams, SND_PCM_ACCESS_RW_INTERLEAVED)) < 0)
+ } else if ((ret = snd_pcm_hw_params_set_access(pcm_handle, hwparams, SND_PCM_ACCESS_RW_INTERLEAVED)) < 0)
goto finish;
else if (*use_mmap)
*use_mmap = 0;
-
+
if ((ret = set_format(pcm_handle, hwparams, &f)) < 0)
goto finish;
@@ -363,7 +363,7 @@
int pa_alsa_set_sw_params(snd_pcm_t *pcm) {
snd_pcm_sw_params_t *swparams;
int err;
-
+
pa_assert(pcm);
snd_pcm_sw_params_alloca(&swparams);
@@ -382,7 +382,7 @@
pa_log_warn("Unable to set start threshold: %s\n", snd_strerror(err));
return err;
}
-
+
if ((err = snd_pcm_sw_params(pcm, swparams)) < 0) {
pa_log_warn("Unable to set sw params: %s\n", snd_strerror(err));
return err;
@@ -418,7 +418,7 @@
snd_mixer_elem_t *pa_alsa_find_elem(snd_mixer_t *mixer, const char *name, const char *fallback) {
snd_mixer_elem_t *elem;
snd_mixer_selem_id_t *sid = NULL;
-
+
snd_mixer_selem_id_alloca(&sid);
pa_assert(mixer);
Modified: branches/lennart/src/modules/module-alsa-sink.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/modules/module-alsa-sink.c?rev=1941&root=pulseaudio&r1=1940&r2=1941&view=diff
==============================================================================
--- branches/lennart/src/modules/module-alsa-sink.c (original)
+++ branches/lennart/src/modules/module-alsa-sink.c Wed Oct 17 18:54:46 2007
@@ -654,6 +654,7 @@
}
if (revents & (POLLERR|POLLNVAL|POLLHUP)) {
+
if (revents & POLLERR)
pa_log_warn("Got POLLERR from ALSA");
if (revents & POLLNVAL)
@@ -661,7 +662,34 @@
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;
+ }
}
}
}
Modified: branches/lennart/src/modules/module-alsa-source.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/modules/module-alsa-source.c?rev=1941&root=pulseaudio&r1=1940&r2=1941&view=diff
==============================================================================
--- branches/lennart/src/modules/module-alsa-source.c (original)
+++ branches/lennart/src/modules/module-alsa-source.c Wed Oct 17 18:54:46 2007
@@ -636,6 +636,7 @@
}
if (revents & (POLLERR|POLLNVAL|POLLHUP)) {
+
if (revents & POLLERR)
pa_log_warn("Got POLLERR from ALSA");
if (revents & POLLNVAL)
@@ -643,7 +644,34 @@
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;
+ }
}
}
}
More information about the pulseaudio-commits
mailing list