summaryrefslogtreecommitdiff
path: root/dvbdevice.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <kls (at) cadsoft (dot) de>2004-11-01 18:00:00 +0100
committerKlaus Schmidinger <kls (at) cadsoft (dot) de>2004-11-01 18:00:00 +0100
commit3038be2a6a849e726d6fe99236d5dc61b679198f (patch)
tree9901f3dd92799de71853ed18faf8665f17e5cc79 /dvbdevice.c
parent6f93a5f7819b3c7030a5b199e502bedd4eb7844c (diff)
downloadvdr-patch-lnbsharing-3038be2a6a849e726d6fe99236d5dc61b679198f.tar.gz
vdr-patch-lnbsharing-3038be2a6a849e726d6fe99236d5dc61b679198f.tar.bz2
Version 1.3.15vdr-1.3.15
- 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. - Immediately displaying the new channel info when switching channel groups. - Moved the main program loop variables further up to allow compilation with older compiler versions (thanks to Marco Schlüßler for reporting this one). - Now calling pthread_cond_broadcast() in the destructor of cCondWait and cCondVar to make sure any sleepers will wake up (suggested by Werner Fink). Also using pthread_cond_broadcast() instead of pthread_cond_signal() in cCondWait, in case there is more than one sleeper. - Making sure that timers and channels are only saved together, in a consistent manner (thanks to Mirko Dölle for reporting a problem with inconsistent channel and timer lists). - Now handling the channel name, short name and provider separately. cChannel therefore has two new functions, ShortName() and Provider(). ShortName() can be used to display a short version of the name (in case such a version is available). The optional boolean parameter of ShortName() can be set to true to make it return the name, if no short name is available. The sequence of 'name' and 'short name' in the channels.conf file has been swapped (see man vdr(5)). - Added the 'portal name' to cChannels (thanks to Marco Schlüßler). - Fixed handling key codes that start with 0x1B in the KBD remote control code. - Now using qsort() to sort cListBase lists. For this, the virtual function cListObject::operator<() has been replaced with cListObject::Compare(). Plugins that implement derived cListObject classes may need to adjust their code. - The "Channels" menu can now be sorted "by number" (default), "by name" and "by provider". While in the "Channels" menu, pressing the '0' key switches through these modes. - Fixed the buffer size in cRecording::SortName(). - Now displaying the name of the remote control for which the keys are being learned inside the menu to avoid overwriting the date/time in the 'classic' skin (thanks to Oliver Endriss for reporting this one).
Diffstat (limited to 'dvbdevice.c')
-rw-r--r--dvbdevice.c55
1 files changed, 39 insertions, 16 deletions
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)