[gst-devel] gstalsa poll error patch

Leif Johnson leif at ambient.2y.net
Thu Jan 9 07:18:05 CET 2003


Hi folks -

I tried out alsaplayer and discovered that ALSA really does
work, so I wanted to get the CVS GStreamer alsasink working.
(On my system, with current CVS, when I do "gst-launch
sinesrc ! alsasink" I get a bunch of "poll reports errors"
messages. Is anyone else seeing this ?)

Anyway, I got the source for JACK and browsed through it,
and made a couple of changes in gstalsa.c ; a patch is
included. I really don't know anything much about ALSA, just
wanted to try to get the sink working. If this patch works
or has major errors, could you let me know ? Thanks !

leif

--
Leif Morgan Johnson . http://ambient.2y.net/leif/
IAESTE trainee      . http://www.iaeste.org/
Salomon Automation  . http://www.salomon.at/
-------------- next part --------------
Index: gstalsa.c
===================================================================
RCS file: /cvsroot/gstreamer/gst-plugins/ext/alsa/gstalsa.c,v
retrieving revision 1.22
diff -u -u -r1.22 gstalsa.c
--- gstalsa.c	18 Sep 2002 19:02:13 -0000	1.22
+++ gstalsa.c	9 Jan 2003 15:07:15 -0000
@@ -818,6 +818,8 @@
     }
     
     do {
+        xrun_detected = FALSE;
+        
         if (poll (&pfd, 1, 1000) < 0) {
             if (errno == EINTR) {
                 /* this happens mostly when run
@@ -831,8 +833,7 @@
         }
         
         if (pfd.revents & POLLERR) {
-            g_warning("alsa: poll reports error.");
-            return;
+            xrun_detected = TRUE;
         }
         
         if (pfd.revents == 0) {
@@ -843,15 +844,12 @@
             continue;
         }
         
-        xrun_detected = FALSE;
-        
         this->avail = snd_pcm_avail_update (this->handle);
         DEBUG ("snd_pcm_avail_update() = %d", (int)this->avail);
         
         if (this->avail < 0) {
             if (this->avail == -EPIPE) {
-                gst_alsa_xrun_recovery (this);
-                this->avail = 0;
+                xrun_detected = TRUE;
             } else {
                 g_warning("unknown ALSA avail_update return value (%d)",
                           (int)this->avail);
@@ -859,6 +857,11 @@
             }
         }
         
+        if (xrun_detected) {
+            gst_alsa_xrun_recovery (this);
+            this->avail = 0;
+        }
+
         /* round down to nearest period_frames avail */
         this->avail -= this->avail % this->period_frames;
 


More information about the gstreamer-devel mailing list