From 3038be2a6a849e726d6fe99236d5dc61b679198f Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Mon, 1 Nov 2004 18:00:00 +0100 Subject: =?UTF-8?q?Version=201.3.15=20-=20Fixed=20some=20typos=20in=20the?= =?UTF-8?q?=20Makefile's=20'font'=20target=20(thanks=20to=20Uwe=20Hanke).?= =?UTF-8?q?=20-=20Added=20more=20checks=20and=20polling=20when=20getting?= =?UTF-8?q?=20frontend=20events=20(based=20on=20a=20patch=20=20=20from=20W?= =?UTF-8?q?erner=20Fink).=20-=20No=20longer=20explicitly=20waiting=20for?= =?UTF-8?q?=20a=20tuner=20lock=20when=20switching=20channels=20=20=20(appa?= =?UTF-8?q?rently=20setting=20"live"=20PIDs=20before=20the=20tuner=20is=20?= =?UTF-8?q?locked=20doesn't=20hurt).=20=20=20Moved=20the=20wait=20into=20c?= =?UTF-8?q?Device::AttachReceiver()=20instead.=20-=20Immediately=20display?= =?UTF-8?q?ing=20the=20new=20channel=20info=20when=20switching=20channel?= =?UTF-8?q?=20groups.=20-=20Moved=20the=20main=20program=20loop=20variable?= =?UTF-8?q?s=20further=20up=20to=20allow=20compilation=20with=20=20=20olde?= =?UTF-8?q?r=20compiler=20versions=20(thanks=20to=20Marco=20Schl=C3=BC?= =?UTF-8?q?=C3=9Fler=20for=20reporting=20this=20one).=20-=20Now=20calling?= =?UTF-8?q?=20pthread=5Fcond=5Fbroadcast()=20in=20the=20destructor=20of=20?= =?UTF-8?q?cCondWait=20and=20=20=20cCondVar=20to=20make=20sure=20any=20sle?= =?UTF-8?q?epers=20will=20wake=20up=20(suggested=20by=20Werner=20Fink).=20?= =?UTF-8?q?=20=20Also=20using=20pthread=5Fcond=5Fbroadcast()=20instead=20o?= =?UTF-8?q?f=20pthread=5Fcond=5Fsignal()=20in=20=20=20cCondWait,=20in=20ca?= =?UTF-8?q?se=20there=20is=20more=20than=20one=20sleeper.=20-=20Making=20s?= =?UTF-8?q?ure=20that=20timers=20and=20channels=20are=20only=20saved=20tog?= =?UTF-8?q?ether,=20in=20a=20consistent=20=20=20manner=20(thanks=20to=20Mi?= =?UTF-8?q?rko=20D=C3=B6lle=20for=20reporting=20a=20problem=20with=20incon?= =?UTF-8?q?sistent=20=20=20channel=20and=20timer=20lists).=20-=20Now=20han?= =?UTF-8?q?dling=20the=20channel=20name,=20short=20name=20and=20provider?= =?UTF-8?q?=20separately.=20cChannel=20=20=20therefore=20has=20two=20new?= =?UTF-8?q?=20functions,=20ShortName()=20and=20Provider().=20ShortName()?= =?UTF-8?q?=20=20=20can=20be=20used=20to=20display=20a=20short=20version?= =?UTF-8?q?=20of=20the=20name=20(in=20case=20such=20a=20version=20=20=20is?= =?UTF-8?q?=20available).=20The=20optional=20boolean=20parameter=20of=20Sh?= =?UTF-8?q?ortName()=20can=20be=20set=20to=20=20=20true=20to=20make=20it?= =?UTF-8?q?=20return=20the=20name,=20if=20no=20short=20name=20is=20availab?= =?UTF-8?q?le.=20=20=20The=20sequence=20of=20'name'=20and=20'short=20name'?= =?UTF-8?q?=20in=20the=20channels.conf=20file=20has=20been=20=20=20swapped?= =?UTF-8?q?=20(see=20man=20vdr(5)).=20-=20Added=20the=20'portal=20name'=20?= =?UTF-8?q?to=20cChannels=20(thanks=20to=20Marco=20Schl=C3=BC=C3=9Fler).?= =?UTF-8?q?=20-=20Fixed=20handling=20key=20codes=20that=20start=20with=200?= =?UTF-8?q?x1B=20in=20the=20KBD=20remote=20control=20code.=20-=20Now=20usi?= =?UTF-8?q?ng=20qsort()=20to=20sort=20cListBase=20lists.=20For=20this,=20t?= =?UTF-8?q?he=20virtual=20function=20=20=20cListObject::operator<()=20has?= =?UTF-8?q?=20been=20replaced=20with=20cListObject::Compare().=20=20=20Plu?= =?UTF-8?q?gins=20that=20implement=20derived=20cListObject=20classes=20may?= =?UTF-8?q?=20need=20to=20adjust=20their=20=20=20code.=20-=20The=20"Channe?= =?UTF-8?q?ls"=20menu=20can=20now=20be=20sorted=20"by=20number"=20(default?= =?UTF-8?q?),=20"by=20name"=20and=20=20=20"by=20provider".=20While=20in=20?= =?UTF-8?q?the=20"Channels"=20menu,=20pressing=20the=20'0'=20key=20switche?= =?UTF-8?q?s=20=20=20through=20these=20modes.=20-=20Fixed=20the=20buffer?= =?UTF-8?q?=20size=20in=20cRecording::SortName().=20-=20Now=20displaying?= =?UTF-8?q?=20the=20name=20of=20the=20remote=20control=20for=20which=20the?= =?UTF-8?q?=20keys=20are=20being=20=20=20learned=20inside=20the=20menu=20t?= =?UTF-8?q?o=20avoid=20overwriting=20the=20date/time=20in=20the=20'classic?= =?UTF-8?q?'=20=20=20skin=20(thanks=20to=20Oliver=20Endriss=20for=20report?= =?UTF-8?q?ing=20this=20one).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dvbdevice.c | 55 +++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 39 insertions(+), 16 deletions(-) (limited to 'dvbdevice.c') diff --git a/dvbdevice.c b/dvbdevice.c index 3f38a0a..fb87ae4 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.100 2004/10/24 11:06:37 kls Exp $ + * $Id: dvbdevice.c 1.102 2004/10/30 14:53:30 kls Exp $ */ #include "dvbdevice.h" @@ -35,7 +35,6 @@ extern "C" { #define DO_REC_AND_PLAY_ON_PRIMARY_DEVICE 1 #define DO_MULTIPLE_RECORDINGS 1 -#define TUNER_LOCK_TIMEOUT 5000 // ms #define DEV_VIDEO "/dev/video" #define DEV_DVB_ADAPTER "/dev/dvb/adapter" @@ -81,6 +80,7 @@ private: cMutex mutex; cCondVar locked; cCondWait newSet; + bool GetFrontendEvent(dvb_frontend_event &Event, int TimeoutMs = 0); bool SetFrontend(void); virtual void Action(void); public: @@ -144,6 +144,36 @@ bool cDvbTuner::Locked(int TimeoutMs) return tunerStatus >= tsLocked; } +bool cDvbTuner::GetFrontendEvent(dvb_frontend_event &Event, int TimeoutMs) +{ + if (TimeoutMs) { + struct pollfd pfd; + pfd.fd = fd_frontend; + pfd.events = POLLIN | POLLPRI; + do { + int stat = poll(&pfd, 1, TimeoutMs); + if (stat == 1) + break; + if (stat < 0) { + if (errno == EINTR) + continue; + esyslog("ERROR: frontend %d poll failed: %m", cardIndex); + } + return false; + } while (0); + } + do { + int stat = ioctl(fd_frontend, FE_GET_EVENT, &Event); + if (stat == 0) + return true; + if (stat < 0) { + if (errno == EINTR) + continue; + } + } while (0); + return false; +} + static unsigned int FrequencyToHz(unsigned int f) { while (f && f < 1000000) @@ -260,18 +290,17 @@ bool cDvbTuner::SetFrontend(void) void cDvbTuner::Action(void) { + dvb_frontend_event event; active = true; while (active) { Lock(); if (tunerStatus == tsSet) { - dvb_frontend_event event; - while (ioctl(fd_frontend, FE_GET_EVENT, &event) == 0) + while (GetFrontendEvent(event)) ; // discard stale events tunerStatus = SetFrontend() ? tsTuned : tsIdle; } if (tunerStatus != tsIdle) { - dvb_frontend_event event; - while (ioctl(fd_frontend, FE_GET_EVENT, &event) == 0) { + while (GetFrontendEvent(event, 10)) { if (event.status & FE_REINIT) { tunerStatus = tsSet; esyslog("ERROR: frontend %d was reinitialized - re-tuning", cardIndex); @@ -306,7 +335,8 @@ void cDvbTuner::Action(void) } Unlock(); // in the beginning we loop more often to let the CAM connection start up fast - newSet.Wait((tunerStatus == tsTuned || ciHandler && (time(NULL) - startTime < 20)) ? 100 : 1000); + if (tunerStatus != tsTuned) + newSet.Wait((ciHandler && (time(NULL) - startTime < 20)) ? 100 : 1000); } } @@ -764,13 +794,6 @@ bool cDvbDevice::SetChannelDevice(const cChannel *Channel, bool LiveView) if (EITScanner.UsesDevice(this)) return true; - // Wait for a lock: - - if (!dvbTuner->Locked(TUNER_LOCK_TIMEOUT)) { - esyslog("ERROR: no lock for channel %d on device %d", Channel->Number(), CardIndex() + 1); - return false; - } - // PID settings: if (TurnOnLivePIDs) { @@ -793,9 +816,9 @@ bool cDvbDevice::SetChannelDevice(const cChannel *Channel, bool LiveView) return true; } -bool cDvbDevice::HasLock(void) +bool cDvbDevice::HasLock(int TimeoutMs) { - return dvbTuner ? dvbTuner->Locked() : false; + return dvbTuner ? dvbTuner->Locked(TimeoutMs) : false; } void cDvbDevice::SetVolumeDevice(int Volume) -- cgit v1.2.3