mirror of
https://github.com/vdr-projects/vdr.git
synced 2025-03-01 10:50:46 +00:00
VDR developer version 2.1.7 is now available at ftp://ftp.tvdr.de/vdr/Developer/vdr-2.1.7.tar.bz2 A 'diff' against the previous version is available at ftp://ftp.tvdr.de/vdr/Developer/vdr-2.1.6-2.1.7.diff MD5 checksums: 1c954bad31ce74cd1cbd7987e62d2a98 vdr-2.1.7.tar.bz2 88a90327a75833b7723942d3bd25f954 vdr-2.1.6-2.1.7.diff WARNING: ======== This is a *developer* version. Even though *I* use it in my productive environment, I strongly recommend that you only use it under controlled conditions and for testing and debugging. From the HISTORY file: - No longer logging an error message in DirSizeMB() if the given directory doesn't exist. This avoids lots of log entries in case several VDRs use the same video directory and one of them has already physically removed a recording directory, while the others still have it in their list of deleted recordings. - Updated the Italian OSD texts (thanks to Diego Pierotto). - A cCamSlot that has WantsTsData set to true in its constructor now also gets the CAT and EMM PIDs data. - Fixed a possible division by zero in frame rate detection. - VDR now reads command line options from *.conf files in /etc/vdr/conf.d (thanks to Lars Hanisch). See vdr.1 and vdr.5 for details. - Fixed a possible crash in the LCARS skin (thanks to Thomas Reufer). - Updated the dvbhddevice plugin source. - Fixed a bug in the Makefile when installing plugins with LCLBLD=1 (thanks to Stefan Huelswitt). - The pid of the PMT in which the CA descriptors of a given channel are broadcast is now stored together with the CA descriptors and can be retrieved by calling GetPmtPid() (this information is only required to receive encrypted channels with the OctopusNet receiver via the 'satip' plugin). - Channels that are not listed in the SDT are now only marked as OBSOLETE if "Setup/DVB/Update channels" is set to a value other than "no" or "PIDs only". - Fixed multiple OBSOLETE marks in channels that are not listed in the SDT in case "Setup/Miscellaneous/Show channel names with source" is set to "yes". - The new function cOsd::DrawScaledBitmap() is now used for drawing subtitles. This function can be reimplemented by high level OSDs which may be able to do the scaling in hardware or otherwise more efficiently (thanks to Thomas Reufer). - Fixed detaching receivers from devices in case a CAM needs to receive the TS (reported by Dietmar Spingler). - Fixed resetting the receiver for EMM pids for CAMs that need to receive the TS (reported by Dietmar Spingler). - Fixed (well, actually worked around) a problem with subtitles not being displayed because the broadcaster doesn't set the data's version numbers as required by the DVB standard (thanks to Rolf Ahrenberg). - Fixed support for systemd (thanks to Christopher Reimer). - Added a missing backslash to the help text of the SVDRP command MOVR (thanks to Lars Hanisch). - Added subsystem id support for DVB devices connected via USB (thanks to Jose Alberto Reguero). - Added the functions IndexOf(), InsertUnique(), AppendUnique() and RemoveElement() to the cVector class (thanks to Stefan Schallenberg). - Fixed a possible out-of-bounds access in cVector::Remove(). - Added functions to set and retrieve the priority of a cReceiver (suggested by Frank Schmirler). - Added the new parameters "Setup/Miscellaneous/Volume steps" and ".../Volume linearize" (thanks to Claus Muus). See the MANUAL for details. - Fixed jumping to an absolute position via the Red key in case replay was paused (reported by Dieter Ferdinand). - Changed the German weekday names from "MonDieMitDonFreSamSon" to "Mo.Di.Mi.Do.Fr.Sa.So." (thanks to Stefan Blochberger). - Now handling CAT sections that consist of more than one TS packet. - Added handling for DTS audio tracks to cPatPmtParser::ParsePmt() (thanks to Thomas Reufer). - Added support for PGS subtitles (thanks to Thomas Reufer). - Use of the function cOsd::GetBitmap() outside of derived classes is now deprecated, and it may be made 'protected' in a future version, since it doesn't work with TrueColor OSDs. Plugin authors may want to modify their code so that it works without this function. - Modified the descriptions of several threads, so that the important information (like device or frontend numbers) is within the first 15 characters of the string, because only these are displayed in thread listings. Plugin authors may want to do the same. - Added the channel name to log messages that reference a channel (suggested by Dietmar Spingler). - Modified the CAM API so that it is possible to implement CAMs that can be freely assigned to any devices (thanks to Jasmin Jessich). - Plugins can now implement the function SetMenuSortMode() in their skin objects derived from cSkinDisplayMenu, to get informed about the currently used sort mode, if applicable (suggested by Martin Schirrmacher). - Added cOsdProvider::OsdSizeChanged(), which plugins that implement an output device can call to signal a change in the OSD that requires a redraw of the currently displayed object (thanks to Thomas Reufer). - Added a comment to cRecorder::Activate() about the need to call Detach() in the destructor (suggested by Eike Sauer). - Now returning from removing deleted recordings after at most 10 seconds, or if the user presses a remote control key, to keep the system from getting unresponsive when removing a huge number of files (reported by Dieter Ferdinand). - Fixed generating the index file of an existing recording in case at the of a TS file there is less data in the buffer than needed by the frame detector. In such a case it was possible that frames were missed, and there was most likely a distortion when replaying that part of a recording. This is mostly a problem for recordings that consist of more than one *.ts file. Single file recordings could only lose some frames at their very end, which probably doesn't matter. At any rate, if you have generated an index file with VDR version 2.0.6, 2.1.5 or 2.1.6, you may want to do so again with this version to make sure the index is OK. - Added the new command line option --updindex, which can be used to update an incomplete index of a recording (based on a patch from Helmut Auer).
212 lines
6.6 KiB
C++
212 lines
6.6 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 3.2 2015/01/14 11:39:55 kls Exp $
|
|
*/
|
|
|
|
#ifndef __THREAD_H
|
|
#define __THREAD_H
|
|
|
|
#include <pthread.h>
|
|
#include <stdio.h>
|
|
#include <sys/types.h>
|
|
|
|
class cCondWait {
|
|
private:
|
|
pthread_mutex_t mutex;
|
|
pthread_cond_t cond;
|
|
bool signaled;
|
|
public:
|
|
cCondWait(void);
|
|
~cCondWait();
|
|
static void SleepMs(int TimeoutMs);
|
|
///< Creates a cCondWait object and uses it to sleep for TimeoutMs
|
|
///< milliseconds, immediately giving up the calling thread's time
|
|
///< slice and thus avoiding a "busy wait".
|
|
///< In order to avoid a possible busy wait, TimeoutMs will be automatically
|
|
///< limited to values >2.
|
|
bool Wait(int TimeoutMs = 0);
|
|
///< Waits at most TimeoutMs milliseconds for a call to Signal(), or
|
|
///< forever if TimeoutMs is 0.
|
|
///< Returns true if Signal() has been called, false it the given
|
|
///< timeout has expired.
|
|
void Signal(void);
|
|
///< Signals a caller of Wait() that the condition it is waiting for is met.
|
|
};
|
|
|
|
class cMutex;
|
|
|
|
class cCondVar {
|
|
private:
|
|
pthread_cond_t cond;
|
|
public:
|
|
cCondVar(void);
|
|
~cCondVar();
|
|
void Wait(cMutex &Mutex);
|
|
bool TimedWait(cMutex &Mutex, int TimeoutMs);
|
|
void Broadcast(void);
|
|
};
|
|
|
|
class cRwLock {
|
|
private:
|
|
pthread_rwlock_t rwlock;
|
|
public:
|
|
cRwLock(bool PreferWriter = false);
|
|
~cRwLock();
|
|
bool Lock(bool Write, int TimeoutMs = 0);
|
|
void Unlock(void);
|
|
};
|
|
|
|
class cMutex {
|
|
friend class cCondVar;
|
|
private:
|
|
pthread_mutex_t mutex;
|
|
int locked;
|
|
public:
|
|
cMutex(void);
|
|
~cMutex();
|
|
void Lock(void);
|
|
void Unlock(void);
|
|
};
|
|
|
|
typedef pid_t tThreadId;
|
|
|
|
class cThread {
|
|
friend class cThreadLock;
|
|
private:
|
|
bool active;
|
|
bool running;
|
|
pthread_t childTid;
|
|
tThreadId childThreadId;
|
|
cMutex mutex;
|
|
char *description;
|
|
bool lowPriority;
|
|
static tThreadId mainThreadId;
|
|
static void *StartThread(cThread *Thread);
|
|
protected:
|
|
void SetPriority(int Priority);
|
|
void SetIOPriority(int Priority);
|
|
void Lock(void) { mutex.Lock(); }
|
|
void Unlock(void) { mutex.Unlock(); }
|
|
virtual void Action(void) = 0;
|
|
///< A derived cThread class must implement the code it wants to
|
|
///< execute as a separate thread in this function. If this is
|
|
///< a loop, it must check Running() repeatedly to see whether
|
|
///< it's time to stop.
|
|
bool Running(void) { return running; }
|
|
///< Returns false if a derived cThread object shall leave its Action()
|
|
///< function.
|
|
void Cancel(int WaitSeconds = 0);
|
|
///< Cancels the thread by first setting 'running' to false, so that
|
|
///< the Action() loop can finish in an orderly fashion and then waiting
|
|
///< up to WaitSeconds seconds for the thread to actually end. If the
|
|
///< thread doesn't end by itself, it is killed.
|
|
///< If WaitSeconds is -1, only 'running' is set to false and Cancel()
|
|
///< returns immediately, without killing the thread.
|
|
public:
|
|
cThread(const char *Description = NULL, bool LowPriority = false);
|
|
///< Creates a new thread.
|
|
///< If Description is present, a log file entry will be made when
|
|
///< the thread starts and stops (see SetDescription()).
|
|
///< The Start() function must be called to actually start the thread.
|
|
///< LowPriority can be set to true to make this thread run at a lower
|
|
///< priority.
|
|
virtual ~cThread();
|
|
void SetDescription(const char *Description, ...) __attribute__ ((format (printf, 2, 3)));
|
|
///< Sets the description of this thread, which will be used when logging
|
|
///< starting or stopping of the thread. Make sure any important information
|
|
///< is within the first 15 characters of Description, because only these
|
|
///< may be displayed in thread listings (like 'htop', for instance).
|
|
bool Start(void);
|
|
///< Actually starts the thread.
|
|
///< If the thread is already running, nothing happens.
|
|
bool Active(void);
|
|
///< Checks whether the thread is still alive.
|
|
static tThreadId ThreadId(void);
|
|
static tThreadId IsMainThread(void) { return ThreadId() == mainThreadId; }
|
|
static void SetMainThreadId(void);
|
|
};
|
|
|
|
// cMutexLock can be used to easily set a lock on mutex 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
|
|
// cMutexLock may itself use a cMutexLock to make one longer lock instead of many
|
|
// short ones.
|
|
|
|
class cMutexLock {
|
|
private:
|
|
cMutex *mutex;
|
|
bool locked;
|
|
public:
|
|
cMutexLock(cMutex *Mutex = NULL);
|
|
~cMutexLock();
|
|
bool Lock(cMutex *Mutex);
|
|
};
|
|
|
|
// 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);
|
|
};
|
|
|
|
#define LOCK_THREAD cThreadLock ThreadLock(this)
|
|
|
|
class cIoThrottle {
|
|
private:
|
|
static cMutex mutex;
|
|
static int count;
|
|
bool active;
|
|
public:
|
|
cIoThrottle(void);
|
|
~cIoThrottle();
|
|
void Activate(void);
|
|
///< Activates the global I/O throttling mechanism.
|
|
///< This function may be called any number of times, but only
|
|
///< the first call after an inactive state will have an effect.
|
|
void Release(void);
|
|
///< Releases the global I/O throttling mechanism.
|
|
///< This function may be called any number of times, but only
|
|
///< the first call after an active state will have an effect.
|
|
bool Active(void) { return active; }
|
|
///< Returns true if this I/O throttling object is currently active.
|
|
static bool Engaged(void);
|
|
///< Returns true if any I/O throttling object is currently active.
|
|
};
|
|
|
|
// 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.
|
|
// With Detached=true, calls command in background and in a separate session,
|
|
// with stdin connected to /dev/null.
|
|
|
|
int SystemExec(const char *Command, bool Detached = false);
|
|
|
|
#endif //__THREAD_H
|