diff options
author | Michael Niedermayer <michael@niedermayer.cc> | 2020-01-16 16:34:07 +0100 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2020-02-12 10:25:25 +0100 |
commit | 3182114f8815cb3324dd300d8254ecdb07dbe097 (patch) | |
tree | cfd25373619b9cd168cd2bbd59c86a92a4c8fd84 /libavutil/log.c | |
parent | f15007afa90a3eb3639848d9702c1cc3ac3e896b (diff) |
avutil/log: Add av_log_once() for printing a message just once with a high log level
Compared to ad-hoc if(printed) ... code this allows the user to disable
it by adjusting the log level
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavutil/log.c')
-rw-r--r-- | libavutil/log.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/libavutil/log.c b/libavutil/log.c index 78e703b9e9..8d4945249e 100644 --- a/libavutil/log.c +++ b/libavutil/log.c @@ -412,6 +412,15 @@ void av_log(void* avcl, int level, const char *fmt, ...) va_end(vl); } +void av_log_once(void* avcl, int initial_level, int subsequent_level, int *state, const char *fmt, ...) +{ + va_list vl; + va_start(vl, fmt); + av_vlog(avcl, *state ? subsequent_level : initial_level, fmt, vl); + va_end(vl); + *state = 1; +} + void av_vlog(void* avcl, int level, const char *fmt, va_list vl) { AVClass* avc = avcl ? *(AVClass **) avcl : NULL; |