]> code.delx.au - pulseaudio/blobdiff - src/pulsecore/core-subscribe.c
remap: Change remapping function argument type from void to int16_t / float as approp...
[pulseaudio] / src / pulsecore / core-subscribe.c
index 288d10785f71980dc83b2864366c82f5837903cc..134761ddef2d102bb2acb6791f84804eed0835dc 100644 (file)
@@ -1,5 +1,3 @@
-/* $Id$ */
-
 /***
   This file is part of PulseAudio.
 
@@ -7,7 +5,7 @@
 
   PulseAudio is free software; you can redistribute it and/or modify
   it under the terms of the GNU Lesser General Public License as published
-  by the Free Software Foundation; either version 2 of the License,
+  by the Free Software Foundation; either version 2.1 of the License,
   or (at your option) any later version.
 
   PulseAudio is distributed in the hope that it will be useful, but
 #endif
 
 #include <stdio.h>
-#include <assert.h>
 
 #include <pulse/xmalloc.h>
 
-#include <pulsecore/queue.h>
 #include <pulsecore/log.h>
+#include <pulsecore/macro.h>
 
 #include "core-subscribe.h"
 
@@ -44,7 +41,7 @@
 
 struct pa_subscription {
     pa_core *core;
-    int dead;
+    bool dead;
 
     pa_subscription_cb_t callback;
     void *userdata;
@@ -68,13 +65,13 @@ static void sched_event(pa_core *c);
 pa_subscription* pa_subscription_new(pa_core *c, pa_subscription_mask_t m, pa_subscription_cb_t callback, void *userdata) {
     pa_subscription *s;
 
-    assert(c);
-    assert(m);
-    assert(callback);
+    pa_assert(c);
+    pa_assert(m);
+    pa_assert(callback);
 
     s = pa_xnew(pa_subscription, 1);
     s->core = c;
-    s->dead = 0;
+    s->dead = false;
     s->callback = callback;
     s->userdata = userdata;
     s->mask = m;
@@ -85,24 +82,24 @@ pa_subscription* pa_subscription_new(pa_core *c, pa_subscription_mask_t m, pa_su
 
 /* Free a subscription object, effectively marking it for deletion */
 void pa_subscription_free(pa_subscription*s) {
-    assert(s);
-    assert(!s->dead);
+    pa_assert(s);
+    pa_assert(!s->dead);
 
-    s->dead = 1;
+    s->dead = true;
     sched_event(s->core);
 }
 
 static void free_subscription(pa_subscription *s) {
-    assert(s);
-    assert(s->core);
+    pa_assert(s);
+    pa_assert(s->core);
 
     PA_LLIST_REMOVE(pa_subscription, s->core->subscriptions, s);
     pa_xfree(s);
 }
 
 static void free_event(pa_subscription_event *s) {
-    assert(s);
-    assert(s->core);
+    pa_assert(s);
+    pa_assert(s->core);
 
     if (!s->next)
         s->core->subscription_event_last = s->prev;
@@ -113,7 +110,7 @@ static void free_event(pa_subscription_event *s) {
 
 /* Free all subscription objects */
 void pa_subscription_free_all(pa_core *c) {
-    assert(c);
+    pa_assert(c);
 
     while (c->subscriptions)
         free_subscription(c->subscriptions);
@@ -147,7 +144,7 @@ static void dump_event(const char * prefix, pa_subscription_event*e) {
         [PA_SUBSCRIPTION_EVENT_REMOVE] = "REMOVE"
     };
 
-    pa_log("%s event (%s|%s|%u)",
+    pa_log_debug("%s event (%s|%s|%u)",
            prefix,
            fac_table[e->type & PA_SUBSCRIPTION_EVENT_FACILITY_MASK],
            type_table[e->type & PA_SUBSCRIPTION_EVENT_TYPE_MASK],
@@ -155,14 +152,14 @@ static void dump_event(const char * prefix, pa_subscription_event*e) {
 }
 #endif
 
-/* Deferred callback for dispatching subscirption events */
+/* Deferred callback for dispatching subscription events */
 static void defer_cb(pa_mainloop_api *m, pa_defer_event *de, void *userdata) {
     pa_core *c = userdata;
     pa_subscription *s;
 
-    assert(c->mainloop == m);
-    assert(c);
-    assert(c->subscription_defer_event == de);
+    pa_assert(c->mainloop == m);
+    pa_assert(c);
+    pa_assert(c->subscription_defer_event == de);
 
     c->mainloop->defer_enable(c->subscription_defer_event, 0);
 
@@ -196,11 +193,11 @@ static void defer_cb(pa_mainloop_api *m, pa_defer_event *de, void *userdata) {
 
 /* Schedule an mainloop event so that a pending subscription event is dispatched */
 static void sched_event(pa_core *c) {
-    assert(c);
+    pa_assert(c);
 
     if (!c->subscription_defer_event) {
         c->subscription_defer_event = c->mainloop->defer_new(c->mainloop, defer_cb, c);
-        assert(c->subscription_defer_event);
+        pa_assert(c->subscription_defer_event);
     }
 
     c->mainloop->defer_enable(c->subscription_defer_event, 1);
@@ -209,9 +206,9 @@ static void sched_event(pa_core *c) {
 /* Append a new subscription event to the subscription event queue and schedule a main loop event */
 void pa_subscription_post(pa_core *c, pa_subscription_event_type_t t, uint32_t idx) {
     pa_subscription_event *e;
-    assert(c);
+    pa_assert(c);
 
-    /* No need for queuing subscriptions of noone is listening */
+    /* No need for queuing subscriptions of no one is listening */
     if (!c->subscriptions)
         return;
 
@@ -236,7 +233,7 @@ void pa_subscription_post(pa_core *c, pa_subscription_event_type_t t, uint32_t i
                  * entry in the queue. */
 
                 free_event(i);
-                pa_log_debug("dropped redundant event.");
+                pa_log_debug("Dropped redundant event due to remove event.");
                 continue;
             }
 
@@ -244,7 +241,7 @@ void pa_subscription_post(pa_core *c, pa_subscription_event_type_t t, uint32_t i
                 /* This object has changed. If a "new" or "change" event for
                  * this object is still in the queue we can exit. */
 
-                pa_log_debug("dropped redundant event.");
+                pa_log_debug("Dropped redundant event due to change event.");
                 return;
             }
         }