Enlightenment CVS committal
Author : tsauerbeck
Project : misc
Module : eplayer
Dir : misc/eplayer/src/output/alsa
Modified Files:
alsa.c
Log Message:
Added error handling code to the ALSA plugin to make pause/resume work
===================================================================
RCS file: /cvsroot/enlightenment/misc/eplayer/src/output/alsa/alsa.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -3 -r1.1 -r1.2
--- alsa.c 22 Oct 2003 18:50:06 -0000 1.1
+++ alsa.c 22 Oct 2003 20:35:25 -0000 1.2
@@ -77,11 +77,39 @@
}
int alsa_play(unsigned char *data, int len) {
- int frames = len / frame_size;
+ int frames = len / frame_size, written;
assert(pcm);
- return (snd_pcm_writei(pcm, data, frames) > 0);
+ /* there's still data to write */
+ while (frames > 0) {
+ if ((written = snd_pcm_writei(pcm, data, frames)) > 0) {
+ /* success: play the next frame */
+ frames -= written;
+ data += written * frame_size;
+
+ continue;
+ }
+
+ /* error handling */
+ if (written == -EAGAIN)
+ continue;
+ else if (written == -EPIPE)
+ snd_pcm_prepare(pcm);
+ else if (written == -ESTRPIPE) {
+ /* wait until the suspend flag is released */
+ while ((written = snd_pcm_resume(pcm)) == -EAGAIN)
+ sleep(1);
+
+ if (written < 0) {
+ /* can't wake up device, reset it */
+ snd_pcm_prepare(pcm);
+ return 0;
+ }
+ }
+ }
+
+ return 1;
}
int alsa_volume_get(int *left, int *right) {
-------------------------------------------------------
This SF.net email is sponsored by OSDN developer relations
Here's your chance to show off your extensive product knowledge
We want to know what you know. Tell us and you have a chance to win $100
http://www.zoomerang.com/survey.zgi?HRPT1X3RYQNC5V4MLNSV3E54
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs