summaryrefslogtreecommitdiff
path: root/ringbuffer.c
diff options
context:
space:
mode:
Diffstat (limited to 'ringbuffer.c')
-rw-r--r--ringbuffer.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/ringbuffer.c b/ringbuffer.c
index 269623d4..abe78990 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 2.4 2012/09/17 08:23:43 kls Exp $
+ * $Id: ringbuffer.c 2.5 2012/09/22 11:26:49 kls Exp $
*/
#include "ringbuffer.h"
@@ -20,6 +20,8 @@
#define OVERFLOWREPORTDELTA 5 // seconds between reports
#define PERCENTAGEDELTA 10
#define PERCENTAGETHRESHOLD 70
+#define IOTHROTTLELOW 20
+#define IOTHROTTLEHIGH 50
cRingBuffer::cRingBuffer(int Size, bool Statistics)
{
@@ -31,10 +33,12 @@ cRingBuffer::cRingBuffer(int Size, bool Statistics)
putTimeout = getTimeout = 0;
lastOverflowReport = 0;
overflowCount = overflowBytes = 0;
+ ioThrottle = NULL;
}
cRingBuffer::~cRingBuffer()
{
+ delete ioThrottle;
if (statistics)
dsyslog("buffer stats: %d (%d%%) used", maxFill, maxFill * 100 / (size - 1));
}
@@ -50,6 +54,12 @@ void cRingBuffer::UpdatePercentage(int Fill)
lastPercent = percent;
}
}
+ if (ioThrottle) {
+ if (percent >= IOTHROTTLEHIGH)
+ ioThrottle->Activate();
+ else if (percent < IOTHROTTLELOW)
+ ioThrottle->Release();
+ }
}
void cRingBuffer::WaitForPut(void)
@@ -82,6 +92,12 @@ void cRingBuffer::SetTimeouts(int PutTimeout, int GetTimeout)
getTimeout = GetTimeout;
}
+void cRingBuffer::SetIoThrottle(void)
+{
+ if (!ioThrottle)
+ ioThrottle = new cIoThrottle;
+}
+
void cRingBuffer::ReportOverflow(int Bytes)
{
overflowCount++;