summaryrefslogtreecommitdiff
path: root/ringbuffer.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2004-03-07 14:41:45 +0100
committerKlaus Schmidinger <vdr@tvdr.de>2004-03-07 14:41:45 +0100
commit9c1f56ec71a68e945ff7315ae710f6f9f03e8cc8 (patch)
tree671fff5d1d2d8fa1d42a60e7b8db83eb3be8cac6 /ringbuffer.c
parent2dc3a3d399f7315df034c13fc63dc097683f1f97 (diff)
downloadvdr-9c1f56ec71a68e945ff7315ae710f6f9f03e8cc8.tar.gz
vdr-9c1f56ec71a68e945ff7315ae710f6f9f03e8cc8.tar.bz2
Avoiding too many consecutive "ring buffer overflow" messages
Diffstat (limited to 'ringbuffer.c')
-rw-r--r--ringbuffer.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/ringbuffer.c b/ringbuffer.c
index 5eee41ec..6f26748a 100644
--- a/ringbuffer.c
+++ b/ringbuffer.c
@@ -7,7 +7,7 @@
* Parts of this file were inspired by the 'ringbuffy.c' from the
* LinuxDVB driver (see linuxtv.org).
*
- * $Id: ringbuffer.c 1.18 2003/10/18 10:29:25 kls Exp $
+ * $Id: ringbuffer.c 1.19 2004/03/07 13:46:51 kls Exp $
*/
#include "ringbuffer.h"
@@ -17,6 +17,8 @@
// --- cRingBuffer -----------------------------------------------------------
+#define OVERFLOWREPORTDELTA 5 // seconds between reports
+
cRingBuffer::cRingBuffer(int Size, bool Statistics)
{
size = Size;
@@ -24,6 +26,8 @@ cRingBuffer::cRingBuffer(int Size, bool Statistics)
maxFill = 0;
lastPercent = 0;
putTimeout = getTimeout = 0;
+ lastOverflowReport = 0;
+ overflowCount = overflowBytes = 0;
}
cRingBuffer::~cRingBuffer()
@@ -68,6 +72,17 @@ void cRingBuffer::SetTimeouts(int PutTimeout, int GetTimeout)
getTimeout = GetTimeout;
}
+void cRingBuffer::ReportOverflow(int Bytes)
+{
+ overflowCount++;
+ overflowBytes += Bytes;
+ if (time(NULL) - lastOverflowReport > OVERFLOWREPORTDELTA) {
+ esyslog("ERROR: %d ring buffer overflow%s (%d bytes dropped)", overflowCount, overflowCount > 1 ? "s" : "", overflowBytes);
+ overflowCount = overflowBytes = 0;
+ lastOverflowReport = time(NULL);
+ }
+}
+
// --- cRingBufferLinear -----------------------------------------------------
cRingBufferLinear::cRingBufferLinear(int Size, int Margin, bool Statistics)