From 3fe3c15d5db9c1f3982ffe6dac1ae4ad56d1664d Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Thu, 18 Jan 2001 18:00:00 +0100 Subject: Version 0.70 - VDR now requires driver version 0.8.1 or higher. - Recordings are now saved in PES mode. Note that you now need to install the driver *WITHOUT* 'outstream=0'! This is the default when you 'make insmod' in the DVB/driver directory. Old recordings (in AV_PES mode) can still be replayed (as long as the driver still supports replaying AV_PES files). The only limitation with this is that in fast forward/back mode the picture may be slightly distorted and there may be sound fragments. - The EPG data is now dumped into the file /video/epg.data every ten minutes. Use the Perl script 'epg2html.pl' to convert the raw EPG data into a simple HTML programme listing. - Fixed handling of channel switching with the "Blue" button in the "What's on now/next?" menus. - Fixed saving the MarginStop setup parameter. - Fixed missing initialization in cConfig. - Implemented "On Disk Editing". - There is no more default 'timers.conf' file. - Added Italian language texts (thanks to Alberto Carraro). - Fixed starting a replay session when the program is currently in "transfer mode". - Fixed setting/modifying timers via SVDRP with empty summary fields. - Fixed a problem with recordings that have a single quote character in their name (this is now mapped to 0x01). - Changed the value for Diseqc to '0' in the default 'channels.conf'. - Fixed displaying channels and recording status in the RCU's LED display when a recording is interrupted due to higher priority. - Implemented safe writing of config files (first writes into a temporary file and then renames it). - In case the video data stream is broken the log message will come only every 5 seconds. - The current channel is now saved in the 'setup.conf' file when VDR is cancelled, and will be restored next time it is started (thanks to Deti Fliegl). - The EIT scanning thread is now locked when switching channels to avoid problems. - Encrypted channels can now be selected even without knowing the PNR (however, it is still necessary for the EPG info). --- thread.c | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) (limited to 'thread.c') diff --git a/thread.c b/thread.c index 67b5ab9..363190d 100644 --- a/thread.c +++ b/thread.c @@ -4,12 +4,15 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: thread.c 1.4 2000/11/14 18:38:25 kls Exp $ + * $Id: thread.c 1.7 2000/12/24 12:27:21 kls Exp $ */ #include "thread.h" +#include #include +#include #include +#include "tools.h" // --- cThread --------------------------------------------------------------- @@ -25,7 +28,7 @@ cThread::cThread(void) signalHandlerInstalled = true; } running = false; - parentPid = lockingPid = 0; + parentPid = threadPid = lockingPid = 0; locked = 0; } @@ -40,6 +43,7 @@ void cThread::SignalHandler(int signum) void *cThread::StartThread(cThread *Thread) { + Thread->threadPid = getpid(); Thread->Action(); return NULL; } @@ -49,13 +53,37 @@ bool cThread::Start(void) if (!running) { running = true; parentPid = getpid(); - pthread_create(&thread, NULL, &StartThread, (void *)this); + pthread_create(&thread, NULL, (void *(*) (void *))&StartThread, (void *)this); + usleep(10000); // otherwise calling Active() immediately after Start() causes a "pure virtual method called" error } return true; //XXX return value of pthread_create()??? } -void cThread::Stop(void) +bool cThread::Active(void) { + if (threadPid) { + if (kill(threadPid, SIGIO) < 0) { // couldn't find another way of checking whether the thread is still running - any ideas? + if (errno == ESRCH) + threadPid = 0; + else + LOG_ERROR; + } + else + return true; + } + return false; +} + +void cThread::Cancel(int WaitSeconds) +{ + if (WaitSeconds > 0) { + for (time_t t0 = time(NULL) + WaitSeconds; time(NULL) < t0; ) { + if (!Active()) + return; + usleep(10000); + } + esyslog(LOG_ERR, "ERROR: thread %d won't end (waited %d seconds) - cancelling it...", threadPid, WaitSeconds); + } pthread_cancel(thread); } -- cgit v1.2.3