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 --- dvbdevice.c | 42 +++++++++++++++--------------------------- 1 file changed, 15 insertions(+), 27 deletions(-) (limited to 'dvbdevice.c') diff --git a/dvbdevice.c b/dvbdevice.c index 8334801..561b6c6 100644 --- a/dvbdevice.c +++ b/dvbdevice.c @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: dvbdevice.c 1.93 2004/06/19 09:33:42 kls Exp $ + * $Id: dvbdevice.c 1.97 2004/10/17 09:10:43 kls Exp $ */ #include "dvbdevice.h" @@ -78,8 +78,7 @@ private: bool useCa; time_t startTime; eTunerStatus tunerStatus; - cMutex mutex; - cCondVar newSet; + cCondWait newSet; bool SetFrontend(void); virtual void Action(void); public: @@ -111,7 +110,7 @@ cDvbTuner::~cDvbTuner() { active = false; tunerStatus = tsIdle; - newSet.Broadcast(); + newSet.Signal(); Cancel(3); } @@ -122,7 +121,7 @@ bool cDvbTuner::IsTunedTo(const cChannel *Channel) const void cDvbTuner::Set(const cChannel *Channel, bool Tune, bool UseCa) { - cMutexLock MutexLock(&mutex); + Lock(); if (Tune) tunerStatus = tsSet; else if (tunerStatus == tsCam) @@ -131,7 +130,8 @@ void cDvbTuner::Set(const cChannel *Channel, bool Tune, bool UseCa) if (Channel->Ca() && tunerStatus != tsCam) startTime = time(NULL); channel = *Channel; - newSet.Broadcast(); + Unlock(); + newSet.Signal(); } static unsigned int FrequencyToHz(unsigned int f) @@ -252,7 +252,7 @@ void cDvbTuner::Action(void) { active = true; while (active) { - cMutexLock MutexLock(&mutex); + Lock(); if (tunerStatus == tsSet) tunerStatus = SetFrontend() ? tsTuned : tsIdle; if (tunerStatus == tsTuned) { @@ -267,7 +267,6 @@ void cDvbTuner::Action(void) if (event.status & FE_REINIT) { tunerStatus = tsSet; esyslog("ERROR: frontend %d was reinitialized - re-tuning", cardIndex); - continue; } } } @@ -292,8 +291,9 @@ void cDvbTuner::Action(void) else if (tunerStatus > tsLocked) tunerStatus = tsLocked; } + Unlock(); // in the beginning we loop more often to let the CAM connection start up fast - newSet.TimedWait(mutex, (ciHandler && (time(NULL) - startTime < 20)) ? 100 : 1000); + newSet.Wait((ciHandler && (time(NULL) - startTime < 20)) ? 100 : 1000); } } @@ -307,6 +307,7 @@ cDvbDevice::cDvbDevice(int n) frontendType = fe_type_t(-1); // don't know how else to initialize this - there is no FE_UNKNOWN spuDecoder = NULL; playMode = pmNone; + aPid1 = aPid2 = 0; // Devices that are present on all card types: @@ -371,8 +372,6 @@ cDvbDevice::cDvbDevice(int n) else esyslog("ERROR: can't open DVB device %d", n); - aPid1 = aPid2 = 0; - StartSectionHandler(); } @@ -786,7 +785,8 @@ void cDvbDevice::SetVolumeDevice(int Volume) { if (HasDecoder()) { audio_mixer_t am; - am.volume_left = am.volume_right = Volume; + // conversion for linear volume response: + am.volume_left = am.volume_right = 2 * Volume - Volume * Volume / 255; CHECK(ioctl(fd_audio, AUDIO_SET_MIXER, &am)); } } @@ -1101,29 +1101,17 @@ bool cDvbDevice::OpenDvr(void) void cDvbDevice::CloseDvr(void) { if (fd_dvr >= 0) { - close(fd_dvr); - fd_dvr = -1; delete tsBuffer; tsBuffer = NULL; + close(fd_dvr); + fd_dvr = -1; } } bool cDvbDevice::GetTSPacket(uchar *&Data) { if (tsBuffer) { - int r = tsBuffer->Read(); - if (r >= 0) { - Data = tsBuffer->Get(); - return true; - } - else if (FATALERRNO) { - if (errno == EOVERFLOW) - esyslog("ERROR: DVB driver buffer overflow on device %d", CardIndex() + 1); - else { - LOG_ERROR; - return false; - } - } + Data = tsBuffer->Get(); return true; } return false; -- cgit v1.2.3