From 89d835a23c564db4c18b124929c686fd004cc4fc Mon Sep 17 00:00:00 2001 From: martii Date: Sat, 24 May 2014 13:04:06 +0200 Subject: [PATCH] libeplayer3/input.cpp: filter duplicated messages Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/8ae08d022c9995f8f99899708c4583a2ce74259d Author: martii Date: 2014-05-24 (Sat, 24 May 2014) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- libeplayer3/input.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/libeplayer3/input.cpp b/libeplayer3/input.cpp index c243d30..9ab4b76 100644 --- a/libeplayer3/input.cpp +++ b/libeplayer3/input.cpp @@ -262,10 +262,22 @@ bool Input::Play() return res; } +static std::string lastlog_message; +static unsigned int lastlog_repeats; + static void log_callback(void *ptr __attribute__ ((unused)), int lvl __attribute__ ((unused)), const char *format, va_list ap) { -// if (debug_level > 10) - vfprintf(stderr, format, ap); + char m[1024]; + if (sizeof(m) - 1 > (unsigned int) vsnprintf(m, sizeof(m), format, ap)) { + if (lastlog_message.compare(m) || lastlog_repeats > 999) { + if (lastlog_repeats) + fprintf(stderr, "last message repeated %u times\n", lastlog_repeats); + lastlog_message = m; + lastlog_repeats = 0; + fprintf(stderr, "%s", m); + } else + lastlog_repeats++; + } } bool Input::ReadSubtitle(const char *filename, const char *format, int pid)