From cfac68ee8458c6b51e638dd787d931bd5baad57a Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Sun, 21 Apr 2002 18:00:00 +0200 Subject: =?UTF-8?q?Version=201.0.1=20-=20Added=20some=20DVB-T=20channels?= =?UTF-8?q?=20for=20Berlin=20(Germany)=20to=20channels.conf.terr=20(thanks?= =?UTF-8?q?=20to=20=20=20Andreas=20Roedl).=20-=20Implemented=20enhanced=20?= =?UTF-8?q?string=20editing=20with=20upper-/lowercase,=20insert/overwrite?= =?UTF-8?q?=20=20=20and=20delete=20(thanks=20to=20Sergei=20Haller).=20-=20?= =?UTF-8?q?Fixed=20color=20palette=20handling=20on=20"big=20endian"=20syst?= =?UTF-8?q?ems=20(thanks=20to=20Jean=20Martin=20=20=20for=20pointing=20out?= =?UTF-8?q?=20this=20one).=20-=20Updated=20the=20"Blue=20Movie"=20channels?= =?UTF-8?q?=20to=20the=20new=20"Premiere=20Erotik"=20(thanks=20to=20=20=20?= =?UTF-8?q?Thilo=20Wunderlich).=20NOTE:=20this=20adds=20a=20new=20channel?= =?UTF-8?q?=20to=20'channels.conf',=20so=20that=20=20=20any=20timers=20ref?= =?UTF-8?q?erencing=20a=20channel=20with=20a=20number=20higher=20than=2010?= =?UTF-8?q?2=20should=20be=20=20=20checked=20and=20adapted=20if=20necessar?= =?UTF-8?q?y=20(this=20only=20applies=20if=20you=20are=20using=20the=20def?= =?UTF-8?q?ault=20=20=20'channels.conf').=20-=20Improved=20thread=20lockin?= =?UTF-8?q?g=20in=20the=20ring=20buffer=20to=20avoid=20possible=20race=20c?= =?UTF-8?q?onditions=20=20=20under=20heavy=20load=20(thanks=20to=20Werner?= =?UTF-8?q?=20Fink).=20-=20Fixed=20a=20crash=20when=20selecting=20the=20"J?= =?UTF-8?q?ump"=20function=20directly=20after=20setting=20an=20=20=20editi?= =?UTF-8?q?ng=20mark=20(thanks=20to=20Steffen=20Koch=20for=20reporting=20a?= =?UTF-8?q?nd=20Stefan=20Huelswitt=20for=20=20=20fixing=20this=20one).=20-?= =?UTF-8?q?=20Fixed=20some=20missing=20','=20in=20i18n.c=20(thanks=20to=20?= =?UTF-8?q?Matthias=20Hilbig).=20-=20Fixed=20a=20possible=20endless=20loop?= =?UTF-8?q?=20in=20shifting=20recordings=20between=20DVB=20cards=20(thanks?= =?UTF-8?q?=20=20=20to=20Stefan=20Huelswitt=20for=20reporting=20this=20one?= =?UTF-8?q?).=20-=20Updated=20the=20Premiere=20World=20Formula=201=20chann?= =?UTF-8?q?els=20in=20'channels.conf'=20(thanks=20to=20Mel=20=20=20Sch?= =?UTF-8?q?=C3=A4chner).=20-=20No=20longer=20setting=20PIDs=200x1FFF,=20wh?= =?UTF-8?q?ich=20apparently=20fixes=20problems=20with=20CAMs=20and=20=20?= =?UTF-8?q?=20AC3=20sound=20only=20working=20the=20first=20time=20(thanks?= =?UTF-8?q?=20to=20Stefan=20Huelswitt).=20-=20Now=20encoding=20'.'=20at=20?= =?UTF-8?q?the=20end=20of=20a=20directory=20name=20in=20case=20of=20VFAT?= =?UTF-8?q?=3D1,=20since=20Windows=20=20=20can't=20handle=20these=20(thank?= =?UTF-8?q?s=20to=20Simon=20Dean=20for=20reporting=20this=20one).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 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