From fa0af7065e92abc566346b264740570991ae3f13 Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Wed, 4 Jan 2006 11:48:38 +0100 Subject: [PATCH] Now using FE_READ_STATUS to read the current frontend status --- CONTRIBUTORS | 3 +- HISTORY | 4 ++- dvbdevice.c | 80 +++++++++++++++++++++++----------------------------- 3 files changed, 41 insertions(+), 46 deletions(-) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index c469f1d0..002934aa 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -520,8 +520,9 @@ Christian Rienecker Joerg Riechardt for filling in some missing teletext PIDs -Holger Wächtler +Holger Wächtler for some valuable advice during adapting to the NEWSTRUCT driver + for suggesting to use FE_READ_STATUS to read the current frontend status Jürgen Zimmermann for adding some missing #includes to files in libdtv for gcc 3.2 diff --git a/HISTORY b/HISTORY index 42dcf138..7d0b7f4e 100644 --- a/HISTORY +++ b/HISTORY @@ -3963,7 +3963,7 @@ Video Disk Recorder Revision History commands may now be executed at any time, and the message will be displayed (no more "pending message"). -2006-01-03: Version 1.3.38 +2006-01-04: Version 1.3.38 - Fixed handling second audio and Dolby Digital PIDs for encrypted channels (was broken in version 1.3.37). @@ -4077,3 +4077,5 @@ Video Disk Recorder Revision History - Fixed handling TS packets in cTS2PES (thanks to Reinhard Nissl). - Added cTimer::SetPriority() to set a timer's priority (suggested by Kendy Kutzner). - Added cMenuEditStrItem::InEditMode() (suggested by Christian Wieninger). +- Now using FE_READ_STATUS to read the current frontend status (suggested by + Holger Wächtler). diff --git a/dvbdevice.c b/dvbdevice.c index 2f040513..e10d5e02 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.145 2006/01/03 10:42:47 kls Exp $ + * $Id: dvbdevice.c 1.146 2006/01/04 11:47:36 kls Exp $ */ #include "dvbdevice.h" @@ -84,7 +84,7 @@ private: cMutex mutex; cCondVar locked; cCondVar newSet; - bool GetFrontendEvent(dvb_frontend_event &Event, int TimeoutMs = 0); + bool GetFrontendStatus(fe_status_t &Status, int TimeoutMs = 0); bool SetFrontend(void); virtual void Action(void); public: @@ -147,26 +147,20 @@ bool cDvbTuner::Locked(int TimeoutMs) return tunerStatus >= tsLocked; } -bool cDvbTuner::GetFrontendEvent(dvb_frontend_event &Event, int TimeoutMs) +bool cDvbTuner::GetFrontendStatus(fe_status_t &Status, 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); - } + cPoller Poller(fd_frontend); + if (Poller.Poll(TimeoutMs)) { + // just to clear the event queue - we'll read the actual status below + dvb_frontend_event Event; + CHECK(ioctl(fd_frontend, FE_GET_EVENT, &Event)); + } + else return false; - } while (0); } do { - int stat = ioctl(fd_frontend, FE_GET_EVENT, &Event); + int stat = ioctl(fd_frontend, FE_READ_STATUS, &Status); if (stat == 0) return true; if (stat < 0) { @@ -304,17 +298,16 @@ void cDvbTuner::Action(void) { cTimeMs Timer; bool LostLock = false; - dvb_frontend_event event; + fe_status_t Status = (fe_status_t)0; while (Running()) { - bool hasEvent = GetFrontendEvent(event, 1); - + fe_status_t NewStatus; + if (GetFrontendStatus(NewStatus, 10)) + Status = NewStatus; cMutexLock MutexLock(&mutex); switch (tunerStatus) { case tsIdle: break; case tsSet: - if (hasEvent) - continue; tunerStatus = SetFrontend() ? tsTuned : tsIdle; Timer.Set(tuneTimeout); continue; @@ -329,29 +322,28 @@ void cDvbTuner::Action(void) continue; } case tsLocked: - if (hasEvent) { - if (event.status & FE_REINIT) { - tunerStatus = tsSet; - diseqcCommands = NULL; - esyslog("ERROR: frontend %d was reinitialized", cardIndex); - lastTimeoutReport = 0; - } - else if (event.status & FE_HAS_LOCK) { - if (LostLock) { - esyslog("frontend %d regained lock", cardIndex); - LostLock = false; - } - tunerStatus = tsLocked; - locked.Broadcast(); - lastTimeoutReport = 0; - } - else if (tunerStatus == tsLocked) { - LostLock = true; - esyslog("ERROR: frontend %d lost lock", cardIndex); - tunerStatus = tsTuned; - Timer.Set(lockTimeout); - lastTimeoutReport = 0; + if (Status & FE_REINIT) { + tunerStatus = tsSet; + diseqcCommands = NULL; + esyslog("ERROR: frontend %d was reinitialized", cardIndex); + lastTimeoutReport = 0; + continue; + } + else if (Status & FE_HAS_LOCK) { + if (LostLock) { + esyslog("frontend %d regained lock", cardIndex); + LostLock = false; } + tunerStatus = tsLocked; + locked.Broadcast(); + lastTimeoutReport = 0; + } + else if (tunerStatus == tsLocked) { + LostLock = true; + esyslog("ERROR: frontend %d lost lock", cardIndex); + tunerStatus = tsTuned; + Timer.Set(lockTimeout); + lastTimeoutReport = 0; continue; } }