summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2011-01-22 01:08:36 +0100
committerColin Guthrie <cguthrie@mandriva.org>2011-01-31 11:36:24 +0000
commit1250b5d735129c3e04c45484f80f99cdb12f39a1 (patch)
tree0d99e99ee91ec03d5369701c1deb412b3815b707 /src
parenta509f10f95448fbbd209f2b4903b7c5441886711 (diff)
ratelimit: fix log levels of log suppression messages
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.
Diffstat (limited to 'src')
-rw-r--r--src/modules/alsa/alsa-sink.c6
-rw-r--r--src/modules/alsa/alsa-source.c4
-rw-r--r--src/modules/module-udev-detect.c2
-rw-r--r--src/pulsecore/asyncq.c2
-rw-r--r--src/pulsecore/flist.c2
-rw-r--r--src/pulsecore/log.c4
-rw-r--r--src/pulsecore/log.h2
-rw-r--r--src/pulsecore/memblock.c2
-rw-r--r--src/pulsecore/protocol-native.c2
-rw-r--r--src/pulsecore/pstream.c2
-rw-r--r--src/pulsecore/ratelimit.c4
-rw-r--r--src/pulsecore/ratelimit.h3
-rw-r--r--src/pulsecore/sink.c2
13 files changed, 19 insertions, 18 deletions
diff --git a/src/modules/alsa/alsa-sink.c b/src/modules/alsa/alsa-sink.c
index f861904f..9ed4d4d9 100644
--- a/src/modules/alsa/alsa-sink.c
+++ b/src/modules/alsa/alsa-sink.c
@@ -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
diff --git a/src/modules/alsa/alsa-source.c b/src/modules/alsa/alsa-source.c
index d2147498..45a7af39 100644
--- a/src/modules/alsa/alsa-source.c
+++ b/src/modules/alsa/alsa-source.c
@@ -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
diff --git a/src/modules/module-udev-detect.c b/src/modules/module-udev-detect.c
index 2eecc25a..1eaa84fd 100644
--- a/src/modules/module-udev-detect.c
+++ b/src/modules/module-udev-detect.c
@@ -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);
diff --git a/src/pulsecore/asyncq.c b/src/pulsecore/asyncq.c
index 072ef02c..e62d0c16 100644
--- a/src/pulsecore/asyncq.c
+++ b/src/pulsecore/asyncq.c
@@ -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))))
diff --git a/src/pulsecore/flist.c b/src/pulsecore/flist.c
index 23af5dd4..e342a579 100644
--- a/src/pulsecore/flist.c
+++ b/src/pulsecore/flist.c
@@ -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;
}
diff --git a/src/pulsecore/log.c b/src/pulsecore/log.c
index 0c5a317c..7ba41ee9 100644
--- a/src/pulsecore/log.c
+++ b/src/pulsecore/log.c
@@ -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);
}
diff --git a/src/pulsecore/log.h b/src/pulsecore/log.h
index 2f379f68..1fd38d44 100644
--- a/src/pulsecore/log.h
+++ b/src/pulsecore/log.h
@@ -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
diff --git a/src/pulsecore/memblock.c b/src/pulsecore/memblock.c
index f38b17c6..454900d1 100644
--- a/src/pulsecore/memblock.c
+++ b/src/pulsecore/memblock.c
@@ -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;
diff --git a/src/pulsecore/protocol-native.c b/src/pulsecore/protocol-native.c
index 85245a93..3943e83e 100644
--- a/src/pulsecore/protocol-native.c
+++ b/src/pulsecore/protocol-native.c
@@ -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);
diff --git a/src/pulsecore/pstream.c b/src/pulsecore/pstream.c
index 1d4ac177..3e0bfa3b 100644
--- a/src/pulsecore/pstream.c
+++ b/src/pulsecore/pstream.c
@@ -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.");
}
diff --git a/src/pulsecore/ratelimit.c b/src/pulsecore/ratelimit.c
index 844dd77d..a274d2cc 100644
--- a/src/pulsecore/ratelimit.c
+++ b/src/pulsecore/ratelimit.c
@@ -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;
diff --git a/src/pulsecore/ratelimit.h b/src/pulsecore/ratelimit.h
index 9857a291..9a36195d 100644
--- a/src/pulsecore/ratelimit.h
+++ b/src/pulsecore/ratelimit.h
@@ -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
diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c
index 3cadbff6..62000e0d 100644
--- a/src/pulsecore/sink.c
+++ b/src/pulsecore/sink.c
@@ -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 {