diff options
author | Klaus Schmidinger <vdr@tvdr.de> | 2012-10-04 12:32:31 +0200 |
---|---|---|
committer | Klaus Schmidinger <vdr@tvdr.de> | 2012-10-04 12:32:31 +0200 |
commit | 1e9b16d20bacb9795a07af5ff61db67fc78c3728 (patch) | |
tree | 89f487b4781a65b81e2625f28a18207e82eb1cec | |
parent | 5a407d0e68c8b0ef00613f6839aeadbf6b92224a (diff) | |
download | vdr-1e9b16d20bacb9795a07af5ff61db67fc78c3728.tar.gz vdr-1e9b16d20bacb9795a07af5ff61db67fc78c3728.tar.bz2 |
The cThread constructor now has an additional boolean parameter that can be set to true to have this thread run at a lower priority
-rw-r--r-- | HISTORY | 7 | ||||
-rw-r--r-- | cutter.c | 6 | ||||
-rw-r--r-- | epg.c | 6 | ||||
-rw-r--r-- | recording.c | 6 | ||||
-rw-r--r-- | sections.c | 5 | ||||
-rw-r--r-- | thread.c | 11 | ||||
-rw-r--r-- | thread.h | 7 |
7 files changed, 27 insertions, 21 deletions
@@ -7272,7 +7272,7 @@ Video Disk Recorder Revision History ".keep" to prevent a directory from being deleted when it is empty. Currently the only file name that is ignored is ".sort". -2012-10-03: Version 1.7.32 +2012-10-04: Version 1.7.32 - Pressing the Play key during normal live viewing mode now opens the Recordings menu if there is no "last viewed" recording (thanks to Alexander Wenzel). @@ -7280,3 +7280,8 @@ Video Disk Recorder Revision History - cIoThrottle::Engaged() is now also checked in cRemoveDeletedRecordingsThread::Action(), to suspend removing deleted recordings in case this is necessary to make room for new, ongoing recordings (suggested by Udo Richter). +- The cThread constructor now has an additional boolean parameter that can be set to + true to have this thread run at a lower priority. Plugin authors that use low + priority threads may want to use this instead of the calls to SetPriority(19) and + SetIOPriority(7). The priority of a thread ("low" or "high") is now logged when the + thread starts. @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: cutter.c 2.14 2012/09/20 09:12:47 kls Exp $ + * $Id: cutter.c 2.15 2012/10/04 12:19:37 kls Exp $ */ #include "cutter.h" @@ -33,7 +33,7 @@ public: }; cCuttingThread::cCuttingThread(const char *FromFileName, const char *ToFileName) -:cThread("video cutting") +:cThread("video cutting", true) { error = NULL; fromFile = toFile = NULL; @@ -69,8 +69,6 @@ void cCuttingThread::Action(void) { cMark *Mark = fromMarks.First(); if (Mark) { - SetPriority(19); - SetIOPriority(7); fromFile = fromFileName->Open(); toFile = toFileName->Open(); if (!fromFile || !toFile) @@ -7,7 +7,7 @@ * Original version (as used in VDR before 1.3.0) written by * Robert Schneider <Robert.Schneider@web.de> and Rolf Hakenes <hakenes@hippomi.de>. * - * $Id: epg.c 2.21 2012/09/29 14:29:49 kls Exp $ + * $Id: epg.c 2.22 2012/10/04 12:21:24 kls Exp $ */ #include "epg.h" @@ -1148,14 +1148,12 @@ public: }; cEpgDataWriter::cEpgDataWriter(void) -:cThread("epg data writer") +:cThread("epg data writer", true) { } void cEpgDataWriter::Action(void) { - SetPriority(19); - SetIOPriority(7); Perform(); } diff --git a/recording.c b/recording.c index 8600e077..783a46e5 100644 --- a/recording.c +++ b/recording.c @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: recording.c 2.65 2012/10/03 12:52:13 kls Exp $ + * $Id: recording.c 2.66 2012/10/04 12:21:38 kls Exp $ */ #include "recording.h" @@ -83,14 +83,12 @@ public: }; cRemoveDeletedRecordingsThread::cRemoveDeletedRecordingsThread(void) -:cThread("remove deleted recordings") +:cThread("remove deleted recordings", true) { } void cRemoveDeletedRecordingsThread::Action(void) { - SetPriority(19); - SetIOPriority(7); // Make sure only one instance of VDR does this: cLockFile LockFile(VideoDirectory); if (LockFile.Lock()) { @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: sections.c 2.1 2012/08/26 12:53:39 kls Exp $ + * $Id: sections.c 2.2 2012/10/04 12:21:59 kls Exp $ */ #include "sections.h" @@ -40,7 +40,7 @@ public: // --- cSectionHandler ------------------------------------------------------- cSectionHandler::cSectionHandler(cDevice *Device) -:cThread("section handler") +:cThread("section handler", true) { shp = new cSectionHandlerPrivate; device = Device; @@ -164,7 +164,6 @@ void cSectionHandler::SetStatus(bool On) void cSectionHandler::Action(void) { - SetPriority(19); while (Running()) { Lock(); @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: thread.c 2.5 2012/09/20 09:05:50 kls Exp $ + * $Id: thread.c 2.6 2012/10/04 12:20:43 kls Exp $ */ #include "thread.h" @@ -204,7 +204,7 @@ void cMutex::Unlock(void) tThreadId cThread::mainThreadId = 0; -cThread::cThread(const char *Description) +cThread::cThread(const char *Description, bool LowPriority) { active = running = false; childTid = 0; @@ -212,6 +212,7 @@ cThread::cThread(const char *Description) description = NULL; if (Description) SetDescription("%s", Description); + lowPriority = LowPriority; } cThread::~cThread() @@ -248,12 +249,16 @@ void *cThread::StartThread(cThread *Thread) { Thread->childThreadId = ThreadId(); if (Thread->description) { - dsyslog("%s thread started (pid=%d, tid=%d)", Thread->description, getpid(), Thread->childThreadId); + dsyslog("%s thread started (pid=%d, tid=%d, prio=%s)", Thread->description, getpid(), Thread->childThreadId, Thread->lowPriority ? "low" : "high"); #ifdef PR_SET_NAME if (prctl(PR_SET_NAME, Thread->description, 0, 0, 0) < 0) esyslog("%s thread naming failed (pid=%d, tid=%d)", Thread->description, getpid(), Thread->childThreadId); #endif } + if (Thread->lowPriority) { + Thread->SetPriority(19); + Thread->SetIOPriority(7); + } Thread->Action(); if (Thread->description) dsyslog("%s thread ended (pid=%d, tid=%d)", Thread->description, getpid(), Thread->childThreadId); @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: thread.h 2.2 2012/09/20 08:46:27 kls Exp $ + * $Id: thread.h 2.3 2012/10/04 12:15:39 kls Exp $ */ #ifndef __THREAD_H @@ -83,6 +83,7 @@ private: tThreadId childThreadId; cMutex mutex; char *description; + bool lowPriority; static tThreadId mainThreadId; static void *StartThread(cThread *Thread); protected: @@ -106,11 +107,13 @@ protected: ///< If WaitSeconds is -1, only 'running' is set to false and Cancel() ///< returns immediately, without killing the thread. public: - cThread(const char *Description = NULL); + 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. 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))); bool Start(void); |