[xiph-cvs] cvs commit: ao/src/plugins/alsa ao_alsa.c

Stan Seibert volsung at xiph.org
Fri Nov 9 12:06:10 PST 2001



volsung     01/11/09 12:06:09

  Modified:    src/plugins/alsa ao_alsa.c
  Log:
  Patch from R.L. Horn <eastcheap at yahoo.com> so that the ALSA 0.5 plugin will
  finish writing to the audio device when it is interrupted by a signal.

Revision  Changes    Path
1.7       +11 -3     ao/src/plugins/alsa/ao_alsa.c

Index: ao_alsa.c
===================================================================
RCS file: /usr/local/cvsroot/ao/src/plugins/alsa/ao_alsa.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- ao_alsa.c	2001/08/04 02:56:16	1.6
+++ ao_alsa.c	2001/11/09 20:06:09	1.7
@@ -51,7 +51,6 @@
         3
 };
 
-
 typedef struct ao_alsa_internal
 {
         snd_pcm_t *pcm_handle;
@@ -145,7 +144,7 @@
         else
                 return 0;
 
-	// Finish filling in the parameter structure
+	/* Finish filling in the parameter structure */
         param.format.rate = format->rate;
 
         param.start_mode = SND_PCM_START_FULL;
@@ -193,9 +192,18 @@
         snd_pcm_channel_status_t status;
         snd_pcm_t *pcm_handle = s->pcm_handle;
         int len = s->buf_end;
+	ssize_t written, snd_pcm_write_ret;
 
         s->buf_end = 0;
-	snd_pcm_write(pcm_handle, s->buf, len);
+
+	snd_pcm_write_ret = written = 0;
+	while ((snd_pcm_write_ret >= 0) && (written < len)) {
+		while ((snd_pcm_write_ret = snd_pcm_write(pcm_handle, s->buf, len)) == -EINTR)
+			;
+		if (snd_pcm_write_ret > 0)
+			written += snd_pcm_write_ret;
+	}
+
         memset(&status, 0, sizeof(status));
         if (snd_pcm_channel_status(pcm_handle, &status) < 0) {
                 fprintf(stderr, "ALSA: could not get channel status\n");

--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the commits mailing list