summaryrefslogtreecommitdiff
path: root/ringbuffer.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <kls (at) cadsoft (dot) de>2003-02-16 18:00:00 +0100
committerKlaus Schmidinger <kls (at) cadsoft (dot) de>2003-02-16 18:00:00 +0100
commitb6e4637356502e707fdfc4b97ed1856e08de3df1 (patch)
treed974f0cc0e63083c75e51958cf8ce0e25bd7060e /ringbuffer.c
parentb09aaa00a58ec72d0331a01f31b3df16d43ce90b (diff)
downloadvdr-patch-lnbsharing-b6e4637356502e707fdfc4b97ed1856e08de3df1.tar.gz
vdr-patch-lnbsharing-b6e4637356502e707fdfc4b97ed1856e08de3df1.tar.bz2
Version 1.1.25vdr-1.1.25
- Fixed high CPU load during replay (thanks to Marcel Wiesweg for pointing out this one). - Fixed margin handling in cRingBufferLinear. - Now polling the output device in 'Transfer Mode' and retrying to put packets into the ring buffer. - Resetting the CAM slot in case communication breaks down. - Improved keyboard detection (thanks to Werner Fink). - Updated 'channels.conf.terr' (thanks to Andy Carter). - Fixed broken support for raw OSDs of plugins (thanks to Marcel Wiesweg for reporting this one). - Broken CAM connections are now restored automatically.
Diffstat (limited to 'ringbuffer.c')
-rw-r--r--ringbuffer.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/ringbuffer.c b/ringbuffer.c
index 48622f0..9eecbba 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.13 2003/01/26 19:47:10 kls Exp $
+ * $Id: ringbuffer.c 1.14 2003/02/15 13:21:50 kls Exp $
*/
#include "ringbuffer.h"
@@ -34,14 +34,14 @@ cRingBuffer::~cRingBuffer()
void cRingBuffer::WaitForPut(void)
{
putMutex.Lock();
- readyForPut.Wait(putMutex);
+ readyForPut.TimedWait(putMutex, 1000);
putMutex.Unlock();
}
void cRingBuffer::WaitForGet(void)
{
getMutex.Lock();
- readyForGet.Wait(getMutex);
+ readyForGet.TimedWait(getMutex, 10);
getMutex.Unlock();
}
@@ -102,7 +102,7 @@ int cRingBufferLinear::Put(const uchar *Data, int Count)
Lock();
int rest = Size() - head;
int diff = tail - head;
- int free = (diff > 0) ? diff - 1 : Size() + diff - (tail < margin ? -(margin - tail) : margin) - 1;
+ int free = ((tail < margin) ? rest : (diff > 0) ? diff : Size() + diff - margin) - 1;
if (statistics) {
int fill = Size() - free - 1 + Count;
if (fill >= Size())
@@ -136,6 +136,8 @@ int cRingBufferLinear::Put(const uchar *Data, int Count)
Count = 0;
Unlock();
EnableGet();
+ if (Count == 0)
+ WaitForPut();
}
return Count;
}
@@ -147,7 +149,7 @@ const uchar *cRingBufferLinear::Get(int &Count)
if (getThreadPid < 0)
getThreadPid = getpid();
int rest = Size() - tail;
- if (tail > Size() - margin && head < tail) {
+ if (rest < margin && head < tail) {
int t = margin - rest;
memcpy(buffer + t, buffer + tail, rest);
tail = t;
@@ -169,10 +171,13 @@ const uchar *cRingBufferLinear::Get(int &Count)
void cRingBufferLinear::Del(int Count)
{
if (Count > 0 && Count <= lastGet) {
+ Lock();
tail += Count;
lastGet -= Count;
if (tail >= Size())
tail = margin;
+ Unlock();
+ EnablePut();
}
else
esyslog("ERROR: invalid Count in cRingBufferLinear::Del: %d", Count);