[pulseaudio-commits] r1433 - in /trunk/src/modules: module-alsa-sink.c module-alsa-source.c
svnmailer-noreply at 0pointer.de
svnmailer-noreply at 0pointer.de
Fri Mar 2 01:20:58 PST 2007
Author: ossman
Date: Fri Mar 2 10:20:54 2007
New Revision: 1433
URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=3D1433&root=3Dpulseaudio&vi=
ew=3Drev
Log:
Handle suspended alsa devices. Based on patch by ranma. (closes #26)
Modified:
trunk/src/modules/module-alsa-sink.c
trunk/src/modules/module-alsa-source.c
Modified: trunk/src/modules/module-alsa-sink.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/modules/module-alsa-s=
ink.c?rev=3D1433&root=3Dpulseaudio&r1=3D1432&r2=3D1433&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/src/modules/module-alsa-sink.c (original)
+++ trunk/src/modules/module-alsa-sink.c Fri Mar 2 10:20:54 2007
@@ -141,6 +141,33 @@
return ret;
}
=
+static int suspend_recovery(struct userdata *u) {
+ int ret;
+ assert(u);
+
+ pa_log_info("*** ALSA-SUSPEND (playback) ***");
+
+ if ((ret =3D snd_pcm_resume(u->pcm_handle)) < 0) {
+ if (ret =3D=3D -EAGAIN)
+ return -1;
+
+ if (ret !=3D -ENOSYS)
+ pa_log("snd_pcm_resume() failed: %s", snd_strerror(-ret));
+ else {
+ if ((ret =3D snd_pcm_prepare(u->pcm_handle)) < 0)
+ pa_log("snd_pcm_prepare() failed: %s", snd_strerror(-ret));
+ }
+
+ if (ret < 0) {
+ clear_up(u);
+ pa_module_unload_request(u->module);
+ return -1;
+ }
+ }
+
+ return ret;
+}
+
static void do_write(struct userdata *u) {
assert(u);
=
@@ -176,6 +203,13 @@
continue;
}
=
+ if (frames =3D=3D -ESTRPIPE) {
+ if (suspend_recovery(u) < 0)
+ return;
+
+ continue;
+ }
+
pa_log("snd_pcm_writei() failed: %s", snd_strerror(-frames));
=
clear_up(u);
@@ -205,6 +239,10 @@
=
if (snd_pcm_state(u->pcm_handle) =3D=3D SND_PCM_STATE_XRUN)
if (xrun_recovery(u) < 0)
+ return;
+
+ if (snd_pcm_state(u->pcm_handle) =3D=3D SND_PCM_STATE_SUSPENDED)
+ if (suspend_recovery(u) < 0)
return;
=
do_write(u);
Modified: trunk/src/modules/module-alsa-source.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/modules/module-alsa-s=
ource.c?rev=3D1433&root=3Dpulseaudio&r1=3D1432&r2=3D1433&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/src/modules/module-alsa-source.c (original)
+++ trunk/src/modules/module-alsa-source.c Fri Mar 2 10:20:54 2007
@@ -143,6 +143,34 @@
return 0;
}
=
+
+static int suspend_recovery(struct userdata *u) {
+ int ret;
+ assert(u);
+
+ pa_log_info("*** ALSA-SUSPEND (capture) ***");
+
+ if ((ret =3D snd_pcm_resume(u->pcm_handle)) < 0) {
+ if (ret =3D=3D -EAGAIN)
+ return -1;
+
+ if (ret !=3D -ENOSYS)
+ pa_log("snd_pcm_resume() failed: %s", snd_strerror(-ret));
+ else {
+ if ((ret =3D snd_pcm_prepare(u->pcm_handle)) < 0)
+ pa_log("snd_pcm_prepare() failed: %s", snd_strerror(-ret));
+ }
+
+ if (ret < 0) {
+ clear_up(u);
+ pa_module_unload_request(u->module);
+ return -1;
+ }
+ }
+
+ return ret;
+}
+
static void do_read(struct userdata *u) {
assert(u);
=
@@ -175,6 +203,13 @@
continue;
}
=
+ if (frames =3D=3D -ESTRPIPE) {
+ if (suspend_recovery(u) < 0)
+ return;
+
+ continue;
+ }
+
pa_log("snd_pcm_readi() failed: %s", snd_strerror(-frames));
=
clear_up(u);
@@ -208,6 +243,10 @@
=
if (snd_pcm_state(u->pcm_handle) =3D=3D SND_PCM_STATE_XRUN)
if (xrun_recovery(u) < 0)
+ return;
+
+ if (snd_pcm_state(u->pcm_handle) =3D=3D SND_PCM_STATE_SUSPENDED)
+ if (suspend_recovery(u) < 0)
return;
=
do_read(u);
More information about the pulseaudio-commits
mailing list