From 664df0902e624904098bad2aacc922c40d26a01c Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Sat, 30 Oct 2004 15:10:50 +0200 Subject: [PATCH] No longer explicitly waiting for a tuner lock when switching channels --- HISTORY | 3 +++ device.c | 9 +++++++-- device.h | 6 ++++-- dvbdevice.c | 14 +++----------- dvbdevice.h | 4 ++-- 5 files changed, 19 insertions(+), 17 deletions(-) diff --git a/HISTORY b/HISTORY index 9aa6db33..d4f4fe6b 100644 --- a/HISTORY +++ b/HISTORY @@ -3083,3 +3083,6 @@ Video Disk Recorder Revision History - Fixed some typos in the Makefile's 'font' target (thanks to Uwe Hanke). - Added more checks and polling when getting frontend events (based on a patch from Werner Fink). +- No longer explicitly waiting for a tuner lock when switching channels + (apparently setting "live" PIDs before the tuner is locked doesn't hurt). + Moved the wait into cDevice::AttachReceiver() instead. diff --git a/device.c b/device.c index 5a57faf8..5a750ca0 100644 --- a/device.c +++ b/device.c @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: device.c 1.61 2004/10/23 10:15:31 kls Exp $ + * $Id: device.c 1.62 2004/10/30 14:53:38 kls Exp $ */ #include "device.h" @@ -23,6 +23,7 @@ // The default priority for non-primary devices: #define DEFAULTPRIORITY -1 +#define TUNER_LOCK_TIMEOUT 5000 // ms int cDevice::numDevices = 0; int cDevice::useDevice = 0; @@ -467,7 +468,7 @@ bool cDevice::SetChannelDevice(const cChannel *Channel, bool LiveView) return false; } -bool cDevice::HasLock(void) +bool cDevice::HasLock(int TimeoutMs) { return true; } @@ -765,6 +766,10 @@ bool cDevice::AttachReceiver(cReceiver *Receiver) return false; if (Receiver->device == this) return true; + if (!HasLock(TUNER_LOCK_TIMEOUT)) { + esyslog("ERROR: device %d has no lock, can't attach receiver!", CardIndex() + 1); + return false; + } for (int i = 0; i < MAXRECEIVERS; i++) { if (!receiver[i]) { for (int n = 0; n < MAXRECEIVEPIDS; n++) { diff --git a/device.h b/device.h index bec6bf5b..16ec2c09 100644 --- a/device.h +++ b/device.h @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: device.h 1.45 2004/09/24 14:07:22 kls Exp $ + * $Id: device.h 1.46 2004/10/30 14:49:56 kls Exp $ */ #ifndef __DEVICE_H @@ -187,10 +187,12 @@ protected: public: static int CurrentChannel(void) { return primaryDevice ? currentChannel : 0; } ///< Returns the number of the current channel on the primary device. - virtual bool HasLock(void);//XXX PLUGINS.html + virtual bool HasLock(int TimeoutMs = 0);//XXX PLUGINS.html ///< Returns true if the device has a lock on the requested transponder. ///< Default is true, a specific device implementation may return false ///< to indicate that it is not ready yet. + ///< If TimeoutMs is not zero, waits for the given number of milliseconds + ///< before returning false. virtual bool HasProgramme(void); ///< Returns true if the device is currently showing any programme to ///< the user, either through replaying or live. diff --git a/dvbdevice.c b/dvbdevice.c index d71702cf..fb87ae4b 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.101 2004/10/30 14:18:53 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" @@ -795,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) { @@ -824,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) diff --git a/dvbdevice.h b/dvbdevice.h index f7a4b925..7dd6174d 100644 --- a/dvbdevice.h +++ b/dvbdevice.h @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: dvbdevice.h 1.28 2004/06/19 08:51:33 kls Exp $ + * $Id: dvbdevice.h 1.29 2004/10/30 14:48:27 kls Exp $ */ #ifndef __DVBDEVICE_H @@ -64,7 +64,7 @@ public: protected: virtual bool SetChannelDevice(const cChannel *Channel, bool LiveView); public: - virtual bool HasLock(void); + virtual bool HasLock(int TimeoutMs = 0); // PID handle facilities