add 'wait' parameter to pa_rtpoll_run(), if zero pa_rtpoll_runn will only update...
authorLennart Poettering <lennart@poettering.net>
Tue, 11 Sep 2007 13:15:39 +0000 (13:15 +0000)
committerLennart Poettering <lennart@poettering.net>
Tue, 11 Sep 2007 13:15:39 +0000 (13:15 +0000)
git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/lennart@1803 fefdeb5f-60dc-0310-8127-8f9354f1896f

src/modules/module-alsa-sink.c
src/modules/module-alsa-source.c
src/modules/module-combine.c
src/modules/module-null-sink.c
src/modules/module-oss.c
src/modules/module-pipe-sink.c
src/modules/module-pipe-source.c
src/pulsecore/rtpoll.c
src/pulsecore/rtpoll.h
src/tests/rtpoll-test.c

index c75f195..bb7392d 100644 (file)
@@ -643,7 +643,7 @@ static void thread_func(void *userdata) {
             continue;
         
         /* Hmm, nothing to do. Let's sleep */
-        if (pa_rtpoll_run(u->rtpoll) < 0) {
+        if (pa_rtpoll_run(u->rtpoll, 1) < 0) {
             pa_log("poll() failed: %s", pa_cstrerror(errno));
             goto fail;
         }
index 365f6ab..fef7b01 100644 (file)
@@ -626,7 +626,7 @@ static void thread_func(void *userdata) {
             continue;
 
         /* Hmm, nothing to do. Let's sleep */
-        if (pa_rtpoll_run(u->rtpoll) < 0) {
+        if (pa_rtpoll_run(u->rtpoll, 1) < 0) {
             pa_log("poll() failed: %s", pa_cstrerror(errno));
             goto fail;
         }
index 3e56bc6..390b6e5 100644 (file)
@@ -268,7 +268,7 @@ static void thread_func(void *userdata) {
             continue;
 
         /* Hmm, nothing to do. Let's sleep */
-        if (pa_rtpoll_run(u->rtpoll) < 0) {
+        if (pa_rtpoll_run(u->rtpoll, 1) < 0) {
             pa_log("poll() failed: %s", pa_cstrerror(errno));
             goto fail;
         }
index 78d99ce..2fe541f 100644 (file)
@@ -158,7 +158,7 @@ static void thread_func(void *userdata) {
             continue;
 
         /* Hmm, nothing to do. Let's sleep */
-        if (pa_rtpoll_run(u->rtpoll) < 0) {
+        if (pa_rtpoll_run(u->rtpoll, 1) < 0) {
             pa_log("poll() failed: %s", pa_cstrerror(errno));
             goto fail;
         }
index 1e524fc..9273a39 100644 (file)
@@ -1031,7 +1031,7 @@ static void thread_func(void *userdata) {
         }
         
         /* Hmm, nothing to do. Let's sleep */
-        if (pa_rtpoll_run(u->rtpoll) < 0) {
+        if (pa_rtpoll_run(u->rtpoll, 1) < 0) {
             pa_log("poll() failed: %s", pa_cstrerror(errno));
             goto fail;
         }
index 55a4e0c..5cafaad 100644 (file)
@@ -185,7 +185,7 @@ static void thread_func(void *userdata) {
         /* Hmm, nothing to do. Let's sleep */
         pollfd->events = u->sink->thread_info.state == PA_SINK_RUNNING ? POLLOUT : 0;
 
-        if (pa_rtpoll_run(u->rtpoll) < 0) {
+        if (pa_rtpoll_run(u->rtpoll, 1) < 0) {
             pa_log("poll() failed: %s", pa_cstrerror(errno));
             goto fail;
         }
index 6dc9464..291010e 100644 (file)
@@ -164,7 +164,7 @@ static void thread_func(void *userdata) {
         /* Hmm, nothing to do. Let's sleep */
         pollfd->events = u->source->thread_info.state == PA_SOURCE_RUNNING ? POLLIN : 0;
 
-        if (pa_rtpoll_run(u->rtpoll) < 0) {
+        if (pa_rtpoll_run(u->rtpoll, 1) < 0) {
             pa_log("poll() failed: %s", pa_cstrerror(errno));
             goto fail;
         }
index e43ec61..be1c83c 100644 (file)
@@ -257,7 +257,7 @@ void pa_rtpoll_free(pa_rtpoll *p) {
     pa_xfree(p);
 }
 
-int pa_rtpoll_run(pa_rtpoll *p) {
+int pa_rtpoll_run(pa_rtpoll *p, int wait) {
     pa_rtpoll_item *i;
     int r = 0;
     int no_events = 0;
@@ -301,7 +301,10 @@ int pa_rtpoll_run(pa_rtpoll *p) {
         rtpoll_rebuild(p);
 
     /* Calculate timeout */
-    if (p->timer_enabled) {
+    if (!wait) {
+        timeout.tv_sec = 0;
+        timeout.tv_nsec = 0;
+    } else if (p->timer_enabled) {
         struct timespec now;
         pa_rtclock_get(&now);
 
index 7fe5cb3..f393f91 100644 (file)
@@ -58,7 +58,10 @@ void pa_rtpoll_free(pa_rtpoll *p);
 
 void pa_rtpoll_install(pa_rtpoll *p);
 
-int pa_rtpoll_run(pa_rtpoll *f);
+/* Sleep on the rtpoll until the time event, or any of the fd events
+ * is triggered. If "wait" is 0 we don't sleep but only update the
+ * struct pollfd. */
+int pa_rtpoll_run(pa_rtpoll *f, int wait);
 
 void pa_rtpoll_set_timer_absolute(pa_rtpoll *p, const struct timespec *ts);
 void pa_rtpoll_set_timer_periodic(pa_rtpoll *p, pa_usec_t usec);
index 2a90684..20913e7 100644 (file)
@@ -58,7 +58,7 @@ int main(int argc, char *argv[]) {
     pa_rtpoll_install(p);
     pa_rtpoll_set_timer_periodic(p, 10000000); /* 10 s */
 
-    pa_rtpoll_run(p);
+    pa_rtpoll_run(p, 1);
     
     pa_rtpoll_item_free(i);
     
@@ -70,7 +70,7 @@ int main(int argc, char *argv[]) {
     pollfd->fd = 0;
     pollfd->events = POLLIN;
     
-    pa_rtpoll_run(p);
+    pa_rtpoll_run(p, 1);
 
     pa_rtpoll_item_free(i);