From ae8a947367b4be57c9b0ca7bbf0032de0e2018d3 Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Thu, 9 May 2002 18:00:00 +0200 Subject: Version 1.1.0 - Begin of the 1.1 development branch. THIS IS NOT A STABLE VERSION! The current stable version for every day use is still the 1.0 branch. - First step towards a universal plugin interface. See the file PLUGINS.html for a detailed description. The man page vdr(1) describes the new options '-L' and '-P' used to load plugins. This first step implements the complete "outer" shell for plugins. The "inner" access to VDR data structures will follow. - The VDR version number is now displayed in the title line of the "Setup" menu. --- ringbuffer.c | 66 ++++++++++++++++++++++++++++++++---------------------------- 1 file changed, 35 insertions(+), 31 deletions(-) (limited to 'ringbuffer.c') diff --git a/ringbuffer.c b/ringbuffer.c index 8b8420c..a52683d 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.5 2001/11/03 09:50:46 kls Exp $ + * $Id: ringbuffer.c 1.6 2002/04/18 15:46:36 kls Exp $ */ #include "ringbuffer.h" @@ -154,7 +154,6 @@ int cRingBufferLinear::Put(const uchar *Data, int Count) Lock(); int rest = Size() - head; int diff = tail - head; - Unlock(); int free = (diff > 0) ? diff - 1 : Size() + diff - 1; if (statistics) { int fill = Size() - free - 1 + Count; @@ -167,22 +166,25 @@ int cRingBufferLinear::Put(const uchar *Data, int Count) dsyslog(LOG_INFO, "buffer usage: %d%%", percent); } } - if (free <= 0) - return 0; - if (free < Count) - Count = free; - if (Count > maxFill) - maxFill = Count; - if (Count >= rest) { - memcpy(buffer + head, Data, rest); - if (Count - rest) - memcpy(buffer, Data + rest, Count - rest); - head = Count - rest; - } - else { - memcpy(buffer + head, Data, Count); - head += Count; + if (free > 0) { + if (free < Count) + Count = free; + if (Count > maxFill) + maxFill = Count; + if (Count >= rest) { + memcpy(buffer + head, Data, rest); + if (Count - rest) + memcpy(buffer, Data + rest, Count - rest); + head = Count - rest; + } + else { + memcpy(buffer + head, Data, Count); + head += Count; + } } + else + Count = 0; + Unlock(); } return Count; } @@ -193,22 +195,24 @@ int cRingBufferLinear::Get(uchar *Data, int Count) Lock(); int rest = Size() - tail; int diff = head - tail; - Unlock(); int cont = (diff >= 0) ? diff : Size() + diff; - if (rest <= 0) - return 0; - if (cont < Count) - Count = cont; - if (Count >= rest) { - memcpy(Data, buffer + tail, rest); - if (Count - rest) - memcpy(Data + rest, buffer, Count - rest); - tail = Count - rest; - } - else { - memcpy(Data, buffer + tail, Count); - tail += Count; + if (rest > 0) { + if (cont < Count) + Count = cont; + if (Count >= rest) { + memcpy(Data, buffer + tail, rest); + if (Count - rest) + memcpy(Data + rest, buffer, Count - rest); + tail = Count - rest; + } + else { + memcpy(Data, buffer + tail, Count); + tail += Count; + } } + else + Count = 0; + Unlock(); } return Count; } -- cgit v1.2.3