]> code.delx.au - pulseaudio/commitdiff
ratelimit: fix log levels of log suppression messages
authorLennart Poettering <lennart@poettering.net>
Sat, 22 Jan 2011 00:08:36 +0000 (01:08 +0100)
committerColin Guthrie <cguthrie@mandriva.org>
Mon, 31 Jan 2011 11:36:24 +0000 (11:36 +0000)
When logging a suppression message do so on the same log level as the
suppressed messages.

Cherry picked by Colin Guthrie from ec5a7857127a1b3b9c5517c4a70a9b2c8aab35ca
with a couple of additional changes due to extra limiting in master
that was not present in stable-queue.

13 files changed:
src/modules/alsa/alsa-sink.c
src/modules/alsa/alsa-source.c
src/modules/module-udev-detect.c
src/pulsecore/asyncq.c
src/pulsecore/flist.c
src/pulsecore/log.c
src/pulsecore/log.h
src/pulsecore/memblock.c
src/pulsecore/protocol-native.c
src/pulsecore/pstream.c
src/pulsecore/ratelimit.c
src/pulsecore/ratelimit.h
src/pulsecore/sink.c

index f861904f6f82e76fd62bea36ab94c28e20873536..9ed4d4d9c6d75cfac3158611dc630c34178d8936 100644 (file)
@@ -440,7 +440,7 @@ static size_t check_left_to_play(struct userdata *u, size_t n_bytes, pa_bool_t o
 #endif
 
         if (!u->first && !u->after_rewind)
-            if (pa_log_ratelimit())
+            if (pa_log_ratelimit(PA_LOG_INFO))
                 pa_log_info("Underrun!");
     }
 
@@ -1511,7 +1511,7 @@ static void thread_func(void *userdata) {
                      * we have filled the buffer at least once
                      * completely.*/
 
-                    if (pa_log_ratelimit())
+                    if (pa_log_ratelimit(PA_LOG_DEBUG))
                         pa_log_debug("Cutting sleep time for the initial iterations by half.");
                     sleep_usec /= 2;
                 }
@@ -1575,7 +1575,7 @@ static void thread_func(void *userdata) {
 
                 u->first = TRUE;
                 u->since_start = 0;
-            } else if (revents && u->use_tsched && pa_log_ratelimit())
+            } else if (revents && u->use_tsched && pa_log_ratelimit(PA_LOG_DEBUG))
                 pa_log_debug("Wakeup from ALSA!");
 
         } else
index d2147498f566b4bc21d031848f7f704e42c8f548..45a7af391b72b0af3dd8347b75ee7d929a06794f 100644 (file)
@@ -428,7 +428,7 @@ static size_t check_left_to_record(struct userdata *u, size_t n_bytes, pa_bool_t
         PA_DEBUG_TRAP;
 #endif
 
-        if (pa_log_ratelimit())
+        if (pa_log_ratelimit(PA_LOG_INFO))
             pa_log_info("Overrun!");
     }
 
@@ -1323,7 +1323,7 @@ static void thread_func(void *userdata) {
                     goto fail;
 
                 u->first = TRUE;
-            } else if (revents && u->use_tsched && pa_log_ratelimit())
+            } else if (revents && u->use_tsched && pa_log_ratelimit(PA_LOG_DEBUG))
                 pa_log_debug("Wakeup from ALSA!");
 
         } else
index 2eecc25a3d4aa1c884ecdbb715825e6b39d4faae..1eaa84fd537d8d64eed11b8bd0efece27ac602dd 100644 (file)
@@ -324,7 +324,7 @@ static void verify_access(struct userdata *u, struct device *d) {
                  * during opening was canceled by a "try again"
                  * failure or a "fatal" failure. */
 
-                if (pa_ratelimit_test(&d->ratelimit)) {
+                if (pa_ratelimit_test(&d->ratelimit, PA_LOG_DEBUG)) {
                     pa_log_debug("Loading module-alsa-card with arguments '%s'", d->args);
                     m = pa_module_load(u->core, "module-alsa-card", d->args);
 
index 072ef02cc3a135e405200cc0c54d8bfa8b8f5a4a..e62d0c162e8028c820c9b8ffcebcc660b1494682 100644 (file)
@@ -206,7 +206,7 @@ void pa_asyncq_post(pa_asyncq*l, void *p) {
     /* OK, we couldn't push anything in the queue. So let's queue it
      * locally and push it later */
 
-    if (pa_log_ratelimit())
+    if (pa_log_ratelimit(PA_LOG_WARN))
         pa_log_warn("q overrun, queuing locally");
 
     if (!(q = pa_flist_pop(PA_STATIC_FLIST_GET(localq))))
index 23af5dd4cd8e41470004a30b3c1c444d44e3391e..e342a5795b21a4cf9bf61589c51befb0c2b06ecb 100644 (file)
@@ -124,7 +124,7 @@ int pa_flist_push(pa_flist *l, void *p) {
 
     elem = stack_pop(&l->empty);
     if (elem == NULL) {
-        if (pa_log_ratelimit())
+        if (pa_log_ratelimit(PA_LOG_DEBUG))
             pa_log_debug("%s flist is full (don't worry)", l->name);
         return -1;
     }
index 0c5a317c9f93cbc1c6ed84a9d029aa34b6969bd1..7ba41ee9c1c1267dab554c0997825a61b5b11a1c 100644 (file)
@@ -431,7 +431,7 @@ void pa_log_level(pa_log_level_t level, const char *format, ...) {
     va_end(ap);
 }
 
-pa_bool_t pa_log_ratelimit(void) {
+pa_bool_t pa_log_ratelimit(pa_log_level_t level) {
     /* Not more than 10 messages every 5s */
     static PA_DEFINE_RATELIMIT(ratelimit, 5 * PA_USEC_PER_SEC, 10);
 
@@ -440,5 +440,5 @@ pa_bool_t pa_log_ratelimit(void) {
     if (no_rate_limit)
         return TRUE;
 
-    return pa_ratelimit_test(&ratelimit);
+    return pa_ratelimit_test(&ratelimit, level);
 }
index 2f379f68864c0558de0055c9f3406fad84853fb1..1fd38d44427dc156780097730d237e697935b145 100644 (file)
@@ -135,6 +135,6 @@ LOG_FUNC(error, PA_LOG_ERROR)
 
 #define pa_log pa_log_error
 
-pa_bool_t pa_log_ratelimit(void);
+pa_bool_t pa_log_ratelimit(pa_log_level_t level);
 
 #endif
index f38b17c6a2d0afd5be8b372dc0381cce3f559c43..454900d104c7ebaa398cb1c305ca4b8c648a56f3 100644 (file)
@@ -258,7 +258,7 @@ static struct mempool_slot* mempool_allocate_slot(pa_mempool *p) {
             slot = (struct mempool_slot*) ((uint8_t*) p->memory.ptr + (p->block_size * (size_t) idx));
 
         if (!slot) {
-            if (pa_log_ratelimit())
+            if (pa_log_ratelimit(PA_LOG_DEBUG))
                 pa_log_debug("Pool full");
             pa_atomic_inc(&p->stat.n_pool_full);
             return NULL;
index 85245a93c5d5b5df986e8cb6f752e29261a2cfe4..3943e83ea6a5116064f31f0e4b4e8b89143641ef 100644 (file)
@@ -1385,7 +1385,7 @@ static int sink_input_process_msg(pa_msgobject *o, int code, void *userdata, int
 
             if (pa_memblockq_push_align(s->memblockq, chunk) < 0) {
 
-                if (pa_log_ratelimit())
+                if (pa_log_ratelimit(PA_LOG_WARN))
                     pa_log_warn("Failed to push data into queue");
                 pa_asyncmsgq_post(pa_thread_mq_get()->outq, PA_MSGOBJECT(s), PLAYBACK_STREAM_MESSAGE_OVERFLOW, NULL, 0, NULL, NULL);
                 pa_memblockq_seek(s->memblockq, (int64_t) chunk->length, PA_SEEK_RELATIVE, TRUE);
index 1d4ac1778c19b6f963fd292e2d72db3baebd2100..3e0bfa3beb58da9b6277f0d1867a93615296b418 100644 (file)
@@ -832,7 +832,7 @@ static int do_read(pa_pstream *p) {
                                           ntohl(p->read.shm_info[PA_PSTREAM_SHM_INDEX]),
                                           ntohl(p->read.shm_info[PA_PSTREAM_SHM_LENGTH])))) {
 
-                    if (pa_log_ratelimit())
+                    if (pa_log_ratelimit(PA_LOG_DEBUG))
                         pa_log_debug("Failed to import memory block.");
                 }
 
index 844dd77d0c02500bed745e8c64ff15c9df3ac38f..a274d2cc17605fbca3c889a02f1657d104b5c3a4 100644 (file)
@@ -35,7 +35,7 @@ static pa_static_mutex mutex = PA_STATIC_MUTEX_INIT;
 /* Modelled after Linux' lib/ratelimit.c by Dave Young
  * <hidave.darkstar@gmail.com>, which is licensed GPLv2. */
 
-pa_bool_t pa_ratelimit_test(pa_ratelimit *r) {
+pa_bool_t pa_ratelimit_test(pa_ratelimit *r, pa_log_level_t t) {
     pa_usec_t now;
     pa_mutex *m;
 
@@ -52,7 +52,7 @@ pa_bool_t pa_ratelimit_test(pa_ratelimit *r) {
         r->begin + r->interval < now) {
 
         if (r->n_missed > 0)
-            pa_log_warn("%u events suppressed", r->n_missed);
+            pa_logl(t, "%u events suppressed", r->n_missed);
 
         r->begin = now;
 
index 9857a291bf2600853a54820be2d8fd58dc280004..9a36195d1de709961d6737d0df14285666bb5680 100644 (file)
@@ -23,6 +23,7 @@
 ***/
 
 #include <pulse/sample.h>
+#include <pulsecore/log.h>
 #include <pulsecore/macro.h>
 
 typedef struct pa_ratelimit {
@@ -51,6 +52,6 @@ typedef struct pa_ratelimit {
         r->begin = 0;                                   \
     } while (FALSE);
 
-pa_bool_t pa_ratelimit_test(pa_ratelimit *r);
+pa_bool_t pa_ratelimit_test(pa_ratelimit *r, pa_log_level_t t);
 
 #endif
index 3cadbff63ce23700dc4e3c16a2c2d6b2abb0f847..62000e0d9af14521c954ee34ab28b7988b29bf3a 100644 (file)
@@ -2989,7 +2989,7 @@ pa_bool_t pa_sink_volume_change_apply(pa_sink *s, pa_usec_t *usec_to_next) {
     if (s->thread_info.volume_changes) {
         if (usec_to_next)
             *usec_to_next = s->thread_info.volume_changes->at - now;
-        if (pa_log_ratelimit())
+        if (pa_log_ratelimit(PA_LOG_DEBUG))
             pa_log_debug("Next volume change in %lld usec", s->thread_info.volume_changes->at - now);
     }
     else {