summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--HISTORY2
-rw-r--r--recorder.c4
-rw-r--r--ringbuffer.c17
-rw-r--r--ringbuffer.h6
-rw-r--r--transfer.c4
5 files changed, 27 insertions, 6 deletions
diff --git a/HISTORY b/HISTORY
index 7d2db65b..a0953fc8 100644
--- a/HISTORY
+++ b/HISTORY
@@ -2728,3 +2728,5 @@ Video Disk Recorder Revision History
- Fixed handling "itemized" texts in EPG data (thanks to Stéphane Esté-Gracias
for pointing out this problem, and Marcel Wiesweg for improving 'libsi').
- Fixed handling VPS times at year boundaries.
+- Avoiding too many consecutive "ring buffer overflow" messages (which only
+ slowed down performance even more).
diff --git a/recorder.c b/recorder.c
index c46c5651..b6b9a240 100644
--- a/recorder.c
+++ b/recorder.c
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: recorder.c 1.8 2003/10/18 11:35:02 kls Exp $
+ * $Id: recorder.c 1.9 2004/03/07 14:39:25 kls Exp $
*/
#include <stdarg.h>
@@ -102,7 +102,7 @@ void cRecorder::Receive(uchar *Data, int Length)
{
int p = ringBuffer->Put(Data, Length);
if (p != Length && active)
- esyslog("ERROR: ring buffer overflow (%d bytes dropped)", Length - p);
+ ringBuffer->ReportOverflow(Length - p);
}
void cRecorder::Action(void)
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)
diff --git a/ringbuffer.h b/ringbuffer.h
index ca5b2069..349096fe 100644
--- a/ringbuffer.h
+++ b/ringbuffer.h
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: ringbuffer.h 1.13 2003/10/18 10:29:25 kls Exp $
+ * $Id: ringbuffer.h 1.14 2004/03/07 13:40:45 kls Exp $
*/
#ifndef __RINGBUFFER_H
@@ -21,6 +21,9 @@ private:
int putTimeout;
int getTimeout;
int size;
+ time_t lastOverflowReport;
+ int overflowCount;
+ int overflowBytes;
protected:
int maxFill;//XXX
int lastPercent;
@@ -39,6 +42,7 @@ public:
cRingBuffer(int Size, bool Statistics = false);
virtual ~cRingBuffer();
void SetTimeouts(int PutTimeout, int GetTimeout);
+ void ReportOverflow(int Bytes);
};
class cRingBufferLinear : public cRingBuffer {
diff --git a/transfer.c b/transfer.c
index 1209dfca..c709928e 100644
--- a/transfer.c
+++ b/transfer.c
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: transfer.c 1.15 2003/10/18 11:36:03 kls Exp $
+ * $Id: transfer.c 1.16 2004/03/07 14:40:15 kls Exp $
*/
#include "transfer.h"
@@ -55,7 +55,7 @@ void cTransfer::Receive(uchar *Data, int Length)
int i = 0;
while (active && Length > 0) {
if (i++ > 10) {
- esyslog("ERROR: ring buffer overflow (%d bytes dropped)", Length);
+ ringBuffer->ReportOverflow(Length);
break;
}
int p = ringBuffer->Put(Data, Length);