[pulseaudio-commits] r1489 - /branches/lennart/src/modules/module-pipe-sink.c

svnmailer-noreply at 0pointer.de svnmailer-noreply at 0pointer.de
Sat Jun 23 13:03:32 PDT 2007


Author: lennart
Date: Sat Jun 23 22:03:30 2007
New Revision: 1489

URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=3D1489&root=3Dpulseaudio&vi=
ew=3Drev
Log:
don't handle underrun special

Modified:
    branches/lennart/src/modules/module-pipe-sink.c

Modified: branches/lennart/src/modules/module-pipe-sink.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/modules/mo=
dule-pipe-sink.c?rev=3D1489&root=3Dpulseaudio&r1=3D1488&r2=3D1489&view=3Ddi=
ff
=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
--- branches/lennart/src/modules/module-pipe-sink.c (original)
+++ branches/lennart/src/modules/module-pipe-sink.c Sat Jun 23 22:03:30 2007
@@ -115,15 +115,12 @@
     =

     struct userdata *u =3D userdata;
     struct pollfd pollfd[POLLFD_MAX];
-    int underrun =3D 0;
     int write_type =3D 0;
 =

     pa_assert(u);
 =

     pa_log_debug("Thread starting up");
 =

-    pa_memchunk_reset(&u->memchunk);
-    =

     memset(&pollfd, 0, sizeof(pollfd));
     =

     pollfd[POLLFD_ASYNCQ].fd =3D pa_asyncmsgq_get_fd(u->asyncmsgq);
@@ -153,56 +150,53 @@
 =

         /* Render some data and write it to the fifo */
 =

-        if (u->sink->thread_info.state =3D=3D PA_SINK_RUNNING && (pollfd[P=
OLLFD_FIFO].revents || underrun)) {
+        if (u->sink->thread_info.state =3D=3D PA_SINK_RUNNING && pollfd[PO=
LLFD_FIFO].revents) {
+            ssize_t l;
+            void *p;
 =

             if (u->memchunk.length <=3D 0)
                 pa_sink_render(u->sink, PIPE_BUF, &u->memchunk);
 =

-            underrun =3D u->memchunk.length <=3D 0;
-
-            if (!underrun) {
-                ssize_t l;
-                void *p;
-
-                p =3D pa_memblock_acquire(u->memchunk.memblock);
-                l =3D pa_write(u->fd, (uint8_t*) p + u->memchunk.index, u-=
>memchunk.length, &write_type);
-                pa_memblock_release(u->memchunk.memblock);
-
-                pa_assert(l !=3D 0);
-                =

-                if (l < 0) {
-
-                    if (errno =3D=3D EINTR)
-                        continue;
-                    else if (errno !=3D EAGAIN) {
-                        pa_log("Failed to write data to FIFO: %s", pa_cstr=
error(errno));
-                        goto fail;
-                    }
-                    =

-                } else {
-
-                    u->memchunk.index +=3D l;
-                    u->memchunk.length -=3D l;
-
-                    if (u->memchunk.length <=3D 0) {
-                        pa_memblock_unref(u->memchunk.memblock);
-                        pa_memchunk_reset(&u->memchunk);
-                    }
-
-                    pollfd[POLLFD_FIFO].revents =3D 0;
+            pa_assert(u->memchunk.length > 0);
+
+            p =3D pa_memblock_acquire(u->memchunk.memblock);
+            l =3D pa_write(u->fd, (uint8_t*) p + u->memchunk.index, u->mem=
chunk.length, &write_type);
+            pa_memblock_release(u->memchunk.memblock);
+
+            pa_assert(l !=3D 0);
+
+            if (l < 0) {
+
+                if (errno =3D=3D EINTR)
                     continue;
+                else if (errno !=3D EAGAIN) {
+                    pa_log("Failed to write data to FIFO: %s", pa_cstrerro=
r(errno));
+                    goto fail;
                 }
+
+            } else {
+
+                u->memchunk.index +=3D l;
+                u->memchunk.length -=3D l;
+
+                if (u->memchunk.length <=3D 0) {
+                    pa_memblock_unref(u->memchunk.memblock);
+                    pa_memchunk_reset(&u->memchunk);
+                }
+
+                pollfd[POLLFD_FIFO].revents =3D 0;
+                continue;
             }
         }
 =

-        pollfd[POLLFD_FIFO].events =3D (u->sink->thread_info.state =3D=3D =
PA_SINK_RUNNING && !underrun) ? POLLOUT : 0;
+        pollfd[POLLFD_FIFO].events =3D u->sink->thread_info.state =3D=3D P=
A_SINK_RUNNING ? POLLOUT : 0;
 =

         /* Hmm, nothing to do. Let's sleep */
 =

         if (pa_asyncmsgq_before_poll(u->asyncmsgq) < 0)
             continue;
 =

-/*         pa_log("polling for %u (underrun=3D%i)", pollfd[POLLFD_FIFO].ev=
ents, underrun);  */
+/*         pa_log("polling for %u", pollfd[POLLFD_FIFO].events);  */
         r =3D poll(pollfd, POLLFD_MAX, -1);
 /*         pa_log("polling got %u", r > 0 ? pollfd[POLLFD_FIFO].revents : =
0);  */
 =

@@ -260,6 +254,7 @@
     u->core =3D c;
     u->module =3D m;
     m->userdata =3D u;
+    pa_memchunk_reset(&u->memchunk);
 =

     pa_assert_se(u->asyncmsgq =3D pa_asyncmsgq_new(0));
     =





More information about the pulseaudio-commits mailing list