vdr/thread.h
Klaus Schmidinger 8465398c6d Version 0.97
- Implemented a lock file to prevent more than one instance of VDR from removing
  files from the video directory at the same time.
- The new setup parameter SplitEditedFiles can be used to control whether or
  not the result of an editing process shall be written into separate files.
- Fixed handling repeat function when using LIRC (thanks to Matthias Weingart).
- The shutdown program (defined with the '-s' option) now also gets the channel
  number and recording title of the timer (see INSTALL).
- New channel data for 'Premiere One', 'Premiere X-Action', 'Fox Kids Türkce'
  and 'N24' (thanks to Andreas Share, Ulrich Röder, Uwe Scheffler and Simon
  Bauschulte). Note that if you are using the default 'channels.conf' or
  'channels.conf.cable' files you may need to check any exiting timers to see
  whether they still use the correct channel number.
- Fixed the "EPG bugfix" (sometimes had duplicate information in Subtitle and
  Extended Description).
- Fixed checking for valid video device when setting the video mode.
- The external command 'sort' is no longer required. VDR now sorts the list of
  recordings itself, making sure that recordings that stem from repeating timers
  are sorted chronologically. Sorting is done according to the setting of the
  current locale, so you may want to make sure LC_COLLATE is set to the desired
  value (see INSTALL).
- Fixed handling 'newline' characters in EPG texts (thanks to Rolf Hakenes for
  an improved version of his 'libdtv').
  Newline characters are always mapped to a single "blank" in VDR, because they
  would otherwise disturb the Title and Subtitle layout in the channel display
  (where these are assumed to be single line texts) and would have to be
  specially handled in the 'epg.data' file and the LSTE command in SVDRP.
- Mapping ` ("backtick") characters in EPG texts to ' (single quote).
- Fixed timers starting and ending at unexpected times. 'localtime()' was not
  thread safe, now using localtime_r().
- Removed the "system time seen..." message.
- Fixed a bug in the replay mode display when pressing the Green or Yellow
  button while in trick mode (thanks to Stefan Huelswitt)
- Closing all open file descriptors when calling external programs.
- The menu timeout now also works when pressing the "Back" button during replay
  to enter the "Recordings" menu.
- Updated 'channels.conf' for the "Bundesliga" channels of Premiere World
  (thanks to Helmut Schächner).
- Fixed reading timers.conf and channels.conf that contain blanks after numeric
  values.
- Fixed handling trick modes near the beginning and end of a recording.
- Pressing the "Back" button while replaying a DVD now leads to the DVD menu.
2001-10-21 18:00:00 +02:00

113 lines
2.4 KiB
C++

/*
* thread.h: A simple thread base class
*
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
* $Id: thread.h 1.10 2001/10/20 10:25:19 kls Exp $
*/
#ifndef __THREAD_H
#define __THREAD_H
#include <pthread.h>
#include <stdio.h>
#include <sys/types.h>
class cMutex;
class cCondVar {
private:
pthread_cond_t cond;
public:
cCondVar(void);
~cCondVar();
bool Wait(cMutex &Mutex);
//bool TimedWait(cMutex &Mutex, unsigned long tmout);
void Broadcast(void);
//void Signal(void);
};
class cMutex {
friend class cCondVar;
private:
pthread_mutex_t mutex;
pid_t lockingPid;
int locked;
public:
cMutex(void);
~cMutex();
void Lock(void);
void Unlock(void);
};
class cThread {
friend class cThreadLock;
private:
pthread_t thread;
cMutex Mutex;
pid_t parentPid, threadPid, lockingPid;
int locked;
bool running;
static time_t lastPanic;
static int panicLevel;
static bool emergencyExitRequested;
static bool signalHandlerInstalled;
static void SignalHandler(int signum);
static void *StartThread(cThread *Thread);
bool Lock(void);
void Unlock(void);
protected:
void WakeUp(void);
virtual void Action(void) = 0;
void Cancel(int WaitSeconds = 0);
public:
cThread(void);
virtual ~cThread();
bool Start(void);
bool Active(void);
static void RaisePanic(void);
static bool EmergencyExit(bool Request = false);
};
// cThreadLock can be used to easily set a lock in a thread and make absolutely
// sure that it will be unlocked when the block will be left. Several locks can
// be stacked, so a function that makes many calls to another function which uses
// cThreadLock may itself use a cThreadLock to make one longer lock instead of many
// short ones.
class cThreadLock {
private:
cThread *thread;
bool locked;
public:
cThreadLock(cThread *Thread = NULL);
~cThreadLock();
bool Lock(cThread *Thread);
bool Locked(void);
};
#define LOCK_THREAD cThreadLock ThreadLock(this)
// cPipe implements a pipe that closes all unnecessary file descriptors in
// the child process.
class cPipe {
private:
pid_t pid;
FILE *f;
public:
cPipe(void);
~cPipe();
operator FILE* () { return f; }
bool Open(const char *Command, const char *Mode);
int Close(void);
};
// SystemExec() implements a 'system()' call that closes all unnecessary file
// descriptors in the child process.
int SystemExec(const char *Command);
#endif //__THREAD_H