mirror of
https://github.com/vdr-projects/vdr.git
synced 2025-03-01 10:50:46 +00:00
- 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).
143 lines
2.8 KiB
C
143 lines
2.8 KiB
C
/*
|
|
* thread.c: A simple thread base class
|
|
*
|
|
* See the main source file 'vdr.c' for copyright information and
|
|
* how to reach the author.
|
|
*
|
|
* $Id: thread.c 1.7 2000/12/24 12:27:21 kls Exp $
|
|
*/
|
|
|
|
#include "thread.h"
|
|
#include <errno.h>
|
|
#include <signal.h>
|
|
#include <sys/wait.h>
|
|
#include <unistd.h>
|
|
#include "tools.h"
|
|
|
|
// --- cThread ---------------------------------------------------------------
|
|
|
|
// The signal handler is necessary to be able to use SIGIO to wake up any
|
|
// pending 'select()' call.
|
|
|
|
bool cThread::signalHandlerInstalled = false;
|
|
|
|
cThread::cThread(void)
|
|
{
|
|
if (!signalHandlerInstalled) {
|
|
signal(SIGIO, SignalHandler);
|
|
signalHandlerInstalled = true;
|
|
}
|
|
running = false;
|
|
parentPid = threadPid = lockingPid = 0;
|
|
locked = 0;
|
|
}
|
|
|
|
cThread::~cThread()
|
|
{
|
|
}
|
|
|
|
void cThread::SignalHandler(int signum)
|
|
{
|
|
signal(signum, SignalHandler);
|
|
}
|
|
|
|
void *cThread::StartThread(cThread *Thread)
|
|
{
|
|
Thread->threadPid = getpid();
|
|
Thread->Action();
|
|
return NULL;
|
|
}
|
|
|
|
bool cThread::Start(void)
|
|
{
|
|
if (!running) {
|
|
running = true;
|
|
parentPid = getpid();
|
|
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()???
|
|
}
|
|
|
|
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);
|
|
}
|
|
|
|
bool cThread::Lock(void)
|
|
{
|
|
if (!lockingPid || lockingPid != getpid()) {
|
|
Mutex.Lock();
|
|
lockingPid = getpid();
|
|
}
|
|
locked++;
|
|
return true;
|
|
}
|
|
|
|
void cThread::Unlock(void)
|
|
{
|
|
if (!--locked) {
|
|
lockingPid = 0;
|
|
Mutex.Unlock();
|
|
}
|
|
}
|
|
|
|
void cThread::WakeUp(void)
|
|
{
|
|
kill(parentPid, SIGIO); // makes any waiting 'select()' call return immediately
|
|
}
|
|
|
|
// --- cThreadLock -----------------------------------------------------------
|
|
|
|
cThreadLock::cThreadLock(cThread *Thread)
|
|
{
|
|
thread = NULL;
|
|
locked = false;
|
|
Lock(Thread);
|
|
}
|
|
|
|
cThreadLock::~cThreadLock()
|
|
{
|
|
if (thread && locked)
|
|
thread->Unlock();
|
|
}
|
|
|
|
bool cThreadLock::Lock(cThread *Thread)
|
|
{
|
|
if (Thread && !thread) {
|
|
thread = Thread;
|
|
locked = Thread->Lock();
|
|
return locked;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
bool cThreadLock::Locked(void)
|
|
{
|
|
return locked;
|
|
}
|
|
|