]> code.delx.au - pulseaudio/blobdiff - src/pulsecore/asyncq.c
Merge commit 'elmarco/dbus'
[pulseaudio] / src / pulsecore / asyncq.c
index 03e9f0dfb04a075ddc9b134f2a0a7ad271e61fc3..67f661fe8eb0557dab3f1e4bfe70ad9085879327 100644 (file)
@@ -71,7 +71,7 @@ PA_STATIC_FLIST_DECLARE(localq, 0, pa_xfree);
 
 #define PA_ASYNCQ_CELLS(x) ((pa_atomic_ptr_t*) ((uint8_t*) (x) + PA_ALIGN(sizeof(struct pa_asyncq))))
 
-static int reduce(pa_asyncq *l, int value) {
+static unsigned reduce(pa_asyncq *l, unsigned value) {
     return value & (unsigned) (l->size - 1);
 }
 
@@ -132,7 +132,7 @@ void pa_asyncq_free(pa_asyncq *l, pa_free_cb_t free_cb) {
 }
 
 static int push(pa_asyncq*l, void *p, pa_bool_t wait) {
-    int idx;
+    unsigned idx;
     pa_atomic_ptr_t *cells;
 
     pa_assert(l);
@@ -163,14 +163,14 @@ static int push(pa_asyncq*l, void *p, pa_bool_t wait) {
     return 0;
 }
 
-static pa_bool_t flush_postq(pa_asyncq *l) {
+static pa_bool_t flush_postq(pa_asyncq *l, pa_bool_t wait) {
     struct localq *q;
 
     pa_assert(l);
 
     while ((q = l->last_localq)) {
 
-        if (push(l, q->data, FALSE) < 0)
+        if (push(l, q->data, wait) < 0)
             return FALSE;
 
         l->last_localq = q->prev;
@@ -187,7 +187,7 @@ static pa_bool_t flush_postq(pa_asyncq *l) {
 int pa_asyncq_push(pa_asyncq*l, void *p, pa_bool_t wait) {
     pa_assert(l);
 
-    if (!flush_postq(l))
+    if (!flush_postq(l, wait))
         return -1;
 
     return push(l, p, wait);
@@ -199,13 +199,15 @@ void pa_asyncq_post(pa_asyncq*l, void *p) {
     pa_assert(l);
     pa_assert(p);
 
-    if (pa_asyncq_push(l, p, FALSE) >= 0)
-        return;
+    if (flush_postq(l, FALSE))
+        if (pa_asyncq_push(l, p, FALSE) >= 0)
+            return;
 
     /* OK, we couldn't push anything in the queue. So let's queue it
      * locally and push it later */
 
-    pa_log("q overrun, queuing locally");
+    if (pa_log_ratelimit())
+        pa_log_warn("q overrun, queuing locally");
 
     if (!(q = pa_flist_pop(PA_STATIC_FLIST_GET(localq))))
         q = pa_xnew(struct localq, 1);
@@ -220,7 +222,7 @@ void pa_asyncq_post(pa_asyncq*l, void *p) {
 }
 
 void* pa_asyncq_pop(pa_asyncq*l, pa_bool_t wait) {
-    int idx;
+    unsigned idx;
     void *ret;
     pa_atomic_ptr_t *cells;
 
@@ -263,7 +265,7 @@ int pa_asyncq_read_fd(pa_asyncq *q) {
 }
 
 int pa_asyncq_read_before_poll(pa_asyncq *l) {
-    int idx;
+    unsigned idx;
     pa_atomic_ptr_t *cells;
 
     pa_assert(l);
@@ -280,8 +282,6 @@ int pa_asyncq_read_before_poll(pa_asyncq *l) {
         if (pa_fdsem_before_poll(l->write_fdsem) >= 0)
             return 0;
     }
-
-    return 0;
 }
 
 void pa_asyncq_read_after_poll(pa_asyncq *l) {
@@ -301,7 +301,7 @@ void pa_asyncq_write_before_poll(pa_asyncq *l) {
 
     for (;;) {
 
-        if (flush_postq(l))
+        if (flush_postq(l, FALSE))
             break;
 
         if (pa_fdsem_before_poll(l->read_fdsem) >= 0) {