From af483c11aebd8146a978dba3d604bda0951e24ac Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Sun, 17 Oct 2004 18:00:00 +0200 Subject: =?UTF-8?q?Version=201.3.13=20-=20Fixed=20checking=20for=20the=20p?= =?UTF-8?q?resence=20of=20NPTL=20(thanks=20to=20Jouni=20Karvo).=20-=20Maki?= =?UTF-8?q?ng=20sure=20section=20filters=20are=20only=20set=20if=20the=20d?= =?UTF-8?q?evice=20actually=20has=20a=20lock=20=20=20(thanks=20to=20Andrea?= =?UTF-8?q?s=20Share=20for=20pointing=20this=20out).=20-=20Fixed=20a=20pos?= =?UTF-8?q?sible=20NULL=20pointer=20assignment=20in=20cMenuText::SetText()?= =?UTF-8?q?=20(thanks=20to=20=20=20Marco=20Schl=C3=BCssler).=20-=20Fixed?= =?UTF-8?q?=20a=20crash=20in=20case=20the=20last=20line=20in=20channels.co?= =?UTF-8?q?nf=20is=20a=20group=20separator=20and=20=20=20that=20group=20is?= =?UTF-8?q?=20selected=20in=20the=20channel=20display=20(thanks=20to=20Dic?= =?UTF-8?q?k=20Streefland).=20-=20Added=20cRingBufferLinear::Read()=20to?= =?UTF-8?q?=20read=20directly=20from=20a=20file=20handle=20into=20the=20?= =?UTF-8?q?=20=20ring=20buffer.=20-=20Using=20timeouts=20in=20ring=20buffe?= =?UTF-8?q?rs=20to=20avoid=20'usleep()'.=20-=20Clearing=20the=20'Transfer?= =?UTF-8?q?=20Mode'=20ring=20buffer=20after=20clearing=20the=20device=20to?= =?UTF-8?q?=20avoid=20=20=20an=20"almost=20full"=20ring=20buffer.=20-=20Re?= =?UTF-8?q?moved=20locking=20from=20cRingBufferLinear=20for=20better=20per?= =?UTF-8?q?formance=20under=20high=20load.=20-=20Using=20a=20cRingBufferLi?= =?UTF-8?q?near=20in=20cRemux=20to=20avoid=20unnecessary=20copying=20of=20?= =?UTF-8?q?data.=20-=20Using=20a=20cRingBufferLinear=20in=20cTSBuffer=20an?= =?UTF-8?q?d=20filling=20it=20in=20a=20separate=20thread=20=20=20to=20avoi?= =?UTF-8?q?d=20buffer=20overflows.=20Plugins=20using=20cTSBuffer=20will=20?= =?UTF-8?q?need=20to=20remove=20the=20=20=20call=20to=20the=20now=20obsole?= =?UTF-8?q?te=20Read()=20function=20(see=20cDvbDevice::GetTSPacket()=20for?= =?UTF-8?q?=20=20=20the=20new=20usage=20of=20cTSBuffer).=20-=20cRemux::Pro?= =?UTF-8?q?cess()=20has=20been=20split=20into=20Put(),=20Get()=20and=20Del?= =?UTF-8?q?()=20to=20allow=20for=20a=20=20=20better=20decoupling=20of=20th?= =?UTF-8?q?e=20remuxing=20and=20disk=20writing=20process.=20Plugins=20usin?= =?UTF-8?q?g=20=20=20cRemux=20will=20need=20to=20be=20modified=20according?= =?UTF-8?q?ly.=20-=20The=20actual=20disk=20writing=20in=20recordings=20is?= =?UTF-8?q?=20now=20done=20in=20a=20separate=20thread=20to=20=20=20improve?= =?UTF-8?q?=20the=20overall=20throughput.=20-=20Changed=20cRemux=20so=20th?= =?UTF-8?q?at=20it=20returns=20the=20maximum=20available=20amount=20of=20d?= =?UTF-8?q?ata=20with=20=20=20each=20call,=20not=20just=202048=20byte.=20-?= =?UTF-8?q?=20Added=20a=20visual=20display=20of=20all=20cRingBufferLinear?= =?UTF-8?q?=20buffers=20for=20debugging.=20To=20=20=20activate=20it,=20def?= =?UTF-8?q?ine=20DEBUGRINGBUFFERS=20in=20ringbuffer.h.=20-=20Instead=20of?= =?UTF-8?q?=20cCondVar=20now=20using=20the=20new=20cCondWait=20(which=20al?= =?UTF-8?q?so=20avoids=20a=20possible=20=20=20"near=20miss"=20condition;?= =?UTF-8?q?=20thanks=20to=20Sascha=20Volkenandt=20for=20pointing=20out=20t?= =?UTF-8?q?his=20one).=20=20=20cCondVar=20is=20still=20present=20for=20plu?= =?UTF-8?q?gins=20that=20use=20it=20(and=20VDR=20itself=20also=20still=20?= =?UTF-8?q?=20=20uses=20it=20in=20cRemote).=20-=20The=20cRingBuffer=20now?= =?UTF-8?q?=20does=20EnableGet()/EnablePut()=20only=20if=20the=20buffer=20?= =?UTF-8?q?is=20more=20than=20=20=20one=20third=20full=20or=20empty,=20res?= =?UTF-8?q?pectively.=20This=20dramatically=20improves=20recording=20=20?= =?UTF-8?q?=20performance=20and=20reduces=20system=20load=20(thanks=20to?= =?UTF-8?q?=20Marco=20Schl=C3=BC=C3=9Fler=20for=20doing=20some=20=20=20tes?= =?UTF-8?q?ting=20regarding=20buffer=20performance=20and=20giving=20me=20s?= =?UTF-8?q?ome=20hints=20that=20finally=20led=20=20=20to=20finding=20out?= =?UTF-8?q?=20that=20this=20was=20the=20basic=20problem=20causing=20buffer?= =?UTF-8?q?=20overflows).=20-=20Improved=20Transfer=20Mode=20(thanks=20to?= =?UTF-8?q?=20Marco=20Schl=C3=BC=C3=9Fler=20for=20suggestions=20and=20test?= =?UTF-8?q?ing).=20-=20Fixed=20a=20possible=20crash=20with=20inconsistent?= =?UTF-8?q?=20SI=20data=20(thanks=20to=20Marcel=20Wiesweg).=20-=20Fixed=20?= =?UTF-8?q?showing=20the=20replay=20mode=20if=20the=20OSD=20is=20currently?= =?UTF-8?q?=20in=20use=20(thanks=20to=20Kimmo=20=20=20Tykkala=20for=20poin?= =?UTF-8?q?ting=20out=20this=20problem).=20-=20cOsdProvider::NewOsd()=20no?= =?UTF-8?q?w=20always=20returns=20a=20valid=20pointer,=20even=20if=20the?= =?UTF-8?q?=20OSD=20is=20=20=20currently=20in=20use=20(it=20will=20then=20?= =?UTF-8?q?return=20a=20dummy=20cOsd=20object=20and=20write=20a=20message?= =?UTF-8?q?=20to=20=20=20the=20log=20file).=20-=20Added=20Estonian=20langu?= =?UTF-8?q?age=20texts=20(thanks=20to=20Arthur=20Konovalov).=20-=20Fixed?= =?UTF-8?q?=20'newplugin'=20and=20libsi/Makefile=20to=20use=20the=20compil?= =?UTF-8?q?er=20defined=20in=20$(CXX)=20for=20=20=20generating=20file=20de?= =?UTF-8?q?pendencies=20(thanks=20to=20Andreas=20Brachold).=20-=20Moved=20?= =?UTF-8?q?the=20initialization=20of=20aPid1=20and=20aPid2=20to=20the=20be?= =?UTF-8?q?ginning=20of=20cDvbDevice::cDvbDevice()=20=20=20to=20have=20the?= =?UTF-8?q?m=20set=20in=20case=20a=20patch=20references=20them=20(thanks?= =?UTF-8?q?=20to=20Wayne=20Keer=20for=20pointing=20=20=20this=20out).=20-?= =?UTF-8?q?=20Completed=20the=20Russian=20OSD=20texts=20(thanks=20to=20Vya?= =?UTF-8?q?cheslav=20Dikonov).=20-=20Avoiding=20unnecessary=20section=20fi?= =?UTF-8?q?lter=20start/stops=20(thanks=20to=20Marco=20Schl=C3=BC=C3=9Fler?= =?UTF-8?q?).=20-=20Made=20the=20"Channel=20not=20available!"=20message=20?= =?UTF-8?q?and=20mtInfo=20instead=20of=20mtError=20(suggested=20=20=20by?= =?UTF-8?q?=20Wayne=20Keer).=20-=20Made=20volume=20control=20more=20linear?= =?UTF-8?q?=20(thanks=20to=20Emil=20Naepflein=20and=20Udo=20Richter).=20-?= =?UTF-8?q?=20Now=20skipping=20code=20table=20info=20in=20SI=20data=20(sug?= =?UTF-8?q?gested=20by=20Milos=20Kapoun).=20-=20Added=20missing=20Czech=20?= =?UTF-8?q?characters=20to=20fontosd-iso8859-2.c=20(thanks=20to=20Milos=20?= =?UTF-8?q?Kapoun).=20-=20Fixed=20a=20crash=20in=20the=20time=20search=20m?= =?UTF-8?q?echanism=20(reported=20by=20Reinhard=20Nissl).=20-=20If=20one?= =?UTF-8?q?=20PID=20can't=20be=20added,=20the=20whole=20cDevice::AttachRec?= =?UTF-8?q?eiver()=20will=20now=20fail=20=20=20and=20all=20PIDs=20added=20?= =?UTF-8?q?so=20far=20will=20be=20deleted=20(thanks=20to=20Marco=20Schl?= =?UTF-8?q?=C3=BC=C3=9Fler=20for=20=20=20pointing=20out=20this=20one).=20-?= =?UTF-8?q?=20Now=20only=20saving=20channels.conf=20after=20a=20modificati?= =?UTF-8?q?on=20made=20by=20the=20user=20(avoids=20=20=20lots=20of=20disk?= =?UTF-8?q?=20access=20due=20to=20automatic=20channel=20updates).=20Automa?= =?UTF-8?q?tic=20channel=20=20=20modifications=20will=20be=20saved=20every?= =?UTF-8?q?=2010=20minutes=20if=20no=20recording=20is=20currently=20=20=20?= =?UTF-8?q?active.=20-=20Removed=20the=20'Log'=20parameter=20from=20the=20?= =?UTF-8?q?cChannel::Set...=20functions.=20Instead=20=20=20checking=20if?= =?UTF-8?q?=20the=20channel=20has=20a=20non-zero=20number.=20-=20Updated?= =?UTF-8?q?=20'channels.conf.terr'=20for=20Hannover=20(thanks=20to=20Sven?= =?UTF-8?q?=20Kreiensen).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libsi/Makefile | 4 ++-- libsi/descriptor.c | 14 ++++---------- libsi/si.c | 26 +++++++++++++++++++------- libsi/si.h | 30 +++++++++++++++++++++--------- libsi/util.c | 6 ++---- libsi/util.h | 9 +++++++-- 6 files changed, 55 insertions(+), 34 deletions(-) (limited to 'libsi') diff --git a/libsi/Makefile b/libsi/Makefile index 613fbee..2d8713b 100644 --- a/libsi/Makefile +++ b/libsi/Makefile @@ -1,7 +1,7 @@ # # Makefile for a libsi # -# $Id: Makefile 1.2 2003/12/13 10:41:39 kls Exp $ +# $Id: Makefile 1.3 2004/10/16 13:31:50 kls Exp $ ### The C++ compiler and options: @@ -30,7 +30,7 @@ OBJS = util.o si.o section.o descriptor.o # Dependencies: -MAKEDEP = g++ -MM -MG +MAKEDEP = $(CXX) -MM -MG DEPFILE = .dependencies $(DEPFILE): Makefile @$(MAKEDEP) $(DEFINES) $(INCLUDES) $(OBJS:%.o=%.c) > $@ diff --git a/libsi/descriptor.c b/libsi/descriptor.c index eb921c9..207b7c2 100644 --- a/libsi/descriptor.c +++ b/libsi/descriptor.c @@ -6,7 +6,7 @@ * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * - * $Id: descriptor.c 1.13 2004/06/06 14:47:30 kls Exp $ + * $Id: descriptor.c 1.14 2004/10/16 09:51:05 kls Exp $ * * ***************************************************************************/ @@ -110,9 +110,7 @@ char *ExtendedEventDescriptors::getText(char *buffer, int size, const char *sepa continue; ExtendedEventDescriptor::Item item; - for (Loop::Iterator it; d->itemLoop.hasNext(it); ) { - item=d->itemLoop.getNext(it); - + for (Loop::Iterator it; d->itemLoop.getNext(item, it); ) { if (!separated && size > sepLen2) { strcpy(buffer+index, separation2); // let's have a separator between the long text and the items index += sepLen2; @@ -207,9 +205,7 @@ char *ExtendedEventDescriptors::getTextItemized(char *buffer, int size, const ch continue; ExtendedEventDescriptor::Item item; - for (Loop::Iterator it; d->itemLoop.hasNext(it); ) { - item=d->itemLoop.getNext(it); - + for (Loop::Iterator it; d->itemLoop.getNext(item, it); ) { item.itemDescription.getText(buffer+index, size); len = strlen(buffer+index); index += len; @@ -251,9 +247,7 @@ bool ExtendedEventDescriptors::getTextItemized(Loop::Iterator &it, bool &valid, continue; ExtendedEventDescriptor::Item item; - if (d->itemLoop.hasNext(it)) { - item=d->itemLoop.getNext(it); - + if (d->itemLoop.getNext(item, it)) { item.item.getText(itemDescription, sizeItemDescription); item.itemDescription.getText(itemText, sizeItemText); valid=true; diff --git a/libsi/si.c b/libsi/si.c index 40f9453..ba97c6e 100644 --- a/libsi/si.c +++ b/libsi/si.c @@ -6,7 +6,7 @@ * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * - * $Id: si.c 1.11 2004/06/06 14:43:56 kls Exp $ + * $Id: si.c 1.13 2004/10/16 15:12:57 kls Exp $ * * ***************************************************************************/ @@ -30,6 +30,10 @@ void Object::setData(CharArray &d) { data=d; } +bool Object::checkSize(unsigned int offset) { + return data.checkSize(offset); +} + Section::Section(const unsigned char *data, bool doCopy) { setData(data, getLength(data), doCopy); } @@ -50,15 +54,15 @@ int Section::getLength(const unsigned char *d) { return HILO(((const SectionHeader *)d)->section_length)+sizeof(SectionHeader); } -bool CRCSection::isValid() { +bool CRCSection::isCRCValid() { return CRC32::isValid((const char *)data.getData(), getLength()/*, data.FourBytes(getLength()-4)*/); } bool CRCSection::CheckCRCAndParse() { - if (!isValid()) + if (!isCRCValid()) return false; CheckParse(); - return true; + return isValid(); } int NumberedSection::getTableIdExtension() const { @@ -102,7 +106,7 @@ DescriptorTag Descriptor::getDescriptorTag(const unsigned char *d) { } Descriptor *DescriptorLoop::getNext(Iterator &it) { - if (it.i friend class StructureLoop; void setData(CharArray &d); + //returns whether the given offset fits within the limits of the actual data + //The valid flag will be set accordingly + bool checkSize(unsigned int offset); }; class Section : public Object { @@ -205,7 +210,7 @@ public: //convenience: sets data and parses if doParse CRCSection(const unsigned char *data, bool doCopy=true) : Section(data, doCopy) {} CRCSection() {} - bool isValid(); + bool isCRCValid(); //convenience: isValid+CheckParse bool CheckCRCAndParse(); }; @@ -229,9 +234,9 @@ public: class VariableLengthPart : public Object { public: //never forget to call this - void setData(CharArray d, int l) { Object::setData(d); length=l; } + void setData(CharArray d, int l) { Object::setData(d); checkSize(l); length=l; } //convenience method - void setDataAndOffset(CharArray d, int l, unsigned int &offset) { Object::setData(d); length=l; offset+=l; } + void setDataAndOffset(CharArray d, int l, unsigned int &offset) { Object::setData(d); checkSize(l); length=l; offset+=l; } virtual int getLength() { return length; } private: int length; @@ -281,29 +286,36 @@ template class StructureLoop : public Loop { public: //currently you must use a while-loop testing for hasNext() //i must be 0 to get the first descriptor (with the first call) - T getNext(Iterator &it) + bool getNext(T &obj, Iterator &it) { + if (!isValid() || it.i >= getLength()) + return false; CharArray d=data; d.addOffset(it.i); T ret; ret.setData(d); ret.CheckParse(); + if (!checkSize(ret.getLength())) + return false; it.i+=ret.getLength(); - return ret; + obj=ret; + return true; } T* getNextAsPointer(Iterator &it) { - if (getLength() <= it.i) + if (!isValid() || it.i >= getLength()) return 0; CharArray d=data; d.addOffset(it.i); T *ret=new T(); ret->setData(d); ret->CheckParse(); + if (!checkSize(ret->getLength())) + return 0; it.i+=ret->getLength(); return ret; } - bool hasNext(Iterator &it) { return getLength() > it.i; } + //bool hasNext(Iterator &it) { return getLength() > it.i; } }; //contains descriptors of different types @@ -385,7 +397,7 @@ public: it.i+=sizeof(T); return ret; } - bool hasNext(Iterator &it) { return getLength() > it.i; } + bool hasNext(Iterator &it) { return isValid() && (getLength() > it.i); } }; class MHP_DescriptorLoop : public DescriptorLoop { diff --git a/libsi/util.c b/libsi/util.c index a2a6f0d..c6ad234 100644 --- a/libsi/util.c +++ b/libsi/util.c @@ -6,7 +6,7 @@ * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * - * $Id: util.c 1.3 2003/12/22 14:03:03 kls Exp $ + * $Id: util.c 1.4 2004/10/16 09:58:41 kls Exp $ * * ***************************************************************************/ @@ -88,9 +88,7 @@ CharArray CharArray::operator+(const unsigned int offset) const { return f; } -CharArray::Data::Data() : count_(1) { - size=0; - data=0; +CharArray::Data::Data() : data(0), size(0), count_(1), valid(true) { /* lockingPid = 0; locked = 0; diff --git a/libsi/util.h b/libsi/util.h index db01923..db2a0a1 100644 --- a/libsi/util.h +++ b/libsi/util.h @@ -6,7 +6,7 @@ * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * - * $Id: util.h 1.3 2003/12/22 14:07:41 kls Exp $ + * $Id: util.h 1.4 2004/10/16 09:59:48 kls Exp $ * * ***************************************************************************/ @@ -58,6 +58,9 @@ public: u_int16_t TwoBytes(const unsigned int index) const { return data_->data ? data_->TwoBytes(off+index) : 0; } u_int32_t FourBytes(const unsigned int index) const { return data_->data ? data_->FourBytes(off+index) : 0; } + bool isValid() const { return data_->valid; } + bool checkSize(unsigned int offset) { return (data_->valid && (data_->valid=(off+offset < data_->size))); } + void addOffset(unsigned int offset) { off+=offset; } private: class Data { @@ -86,10 +89,12 @@ private: const unsigned char*data; unsigned int size; - unsigned count_; // count_ is the number of CharArray objects that point at this // count_ must be initialized to 1 by all constructors // (it starts as 1 since it is pointed to by the CharArray object that created it) + unsigned count_; + + bool valid; /* pthread_mutex_t mutex; -- cgit v1.2.3