diff options
author | Klaus Schmidinger <vdr@tvdr.de> | 2005-08-14 11:24:57 +0200 |
---|---|---|
committer | Klaus Schmidinger <vdr@tvdr.de> | 2005-08-14 11:24:57 +0200 |
commit | af54ce4842850f228d2ac85cb47e6339fd36e9c1 (patch) | |
tree | 5bcf8cb26d825d4e8f4d84b504cd502cfb2bd6e9 | |
parent | 8fe90254f6843fedab11f4bbf7f83090e341f6eb (diff) | |
download | vdr-af54ce4842850f228d2ac85cb47e6339fd36e9c1.tar.gz vdr-af54ce4842850f228d2ac85cb47e6339fd36e9c1.tar.bz2 |
Changed cThread Active() vs. Running()
-rw-r--r-- | HISTORY | 5 | ||||
-rw-r--r-- | cutter.c | 8 | ||||
-rw-r--r-- | device.c | 10 | ||||
-rw-r--r-- | dvbdevice.c | 4 | ||||
-rw-r--r-- | dvbplayer.c | 8 | ||||
-rw-r--r-- | recorder.c | 12 | ||||
-rw-r--r-- | remote.c | 6 | ||||
-rw-r--r-- | sections.c | 4 | ||||
-rw-r--r-- | thread.c | 26 | ||||
-rw-r--r-- | thread.h | 14 | ||||
-rw-r--r-- | transfer.c | 8 |
11 files changed, 52 insertions, 53 deletions
@@ -3672,12 +3672,11 @@ Video Disk Recorder Revision History to Andreas Böttger). - Fixed a memory leak in the SVDRP command LSTE (thanks to Stefan Huelswitt). -2005-08-13: Version 1.3.29 +2005-08-14: Version 1.3.29 - Fixed a race condition in cTransfer (thanks to Klaus ??? for reporting this one). In doing so, the 'active' variables used by the actual derived cThread classes - have been replaced by the cThread::Active() function. The previous functionality - of cThread::Active() has been moved into the new cThread::Running(). + have been replaced by the cThread::Running() function. Plugin authors may want to check their derived cThread classes and replace any 'active' variables the same way as, for instance, done in transfer.c. - Fixed handling EPG data for time shifted events (thanks to Marco Schlüßler). @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: cutter.c 1.9 2005/08/13 11:49:02 kls Exp $ + * $Id: cutter.c 1.10 2005/08/14 10:51:54 kls Exp $ */ #include "cutter.h" @@ -76,7 +76,7 @@ void cCuttingThread::Action(void) uchar buffer[MAXFRAMESIZE]; bool LastMark = false; bool cutIn = true; - while (Active()) { + while (Running()) { uchar FileNumber; int FileOffset, Length; uchar PictureType; @@ -213,7 +213,7 @@ bool cCutter::Start(const char *FileName) void cCutter::Stop(void) { - bool Interrupted = cuttingThread && cuttingThread->Running(); + bool Interrupted = cuttingThread && cuttingThread->Active(); const char *Error = cuttingThread ? cuttingThread->Error() : NULL; delete cuttingThread; cuttingThread = NULL; @@ -230,7 +230,7 @@ void cCutter::Stop(void) bool cCutter::Active(void) { if (cuttingThread) { - if (cuttingThread->Running()) + if (cuttingThread->Active()) return true; error = cuttingThread->Error(); Stop(); @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: device.c 1.104 2005/08/13 11:44:06 kls Exp $ + * $Id: device.c 1.105 2005/08/14 10:52:08 kls Exp $ */ #include "device.h" @@ -1124,8 +1124,8 @@ bool cDevice::Receiving(bool CheckAny) const void cDevice::Action(void) { - if (Active() && OpenDvr()) { - while (Active()) { + if (Running() && OpenDvr()) { + while (Running()) { // Read data from the DVR device: uchar *b = NULL; if (GetTSPacket(b)) { @@ -1186,7 +1186,7 @@ bool cDevice::AttachReceiver(cReceiver *Receiver) Receiver->device = this; receiver[i] = Receiver; Unlock(); - if (!Active()) + if (!Running()) Start(); return true; } @@ -1254,7 +1254,7 @@ void cTSBuffer::Action(void) if (ringBuffer) { bool firstRead = true; cPoller Poller(f); - while (Active()) { + while (Running()) { if (firstRead || Poller.Poll(100)) { firstRead = false; int r = ringBuffer->Read(f); diff --git a/dvbdevice.c b/dvbdevice.c index d81090ca..3f6a7ddf 100644 --- a/dvbdevice.c +++ b/dvbdevice.c @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: dvbdevice.c 1.132 2005/08/13 11:40:46 kls Exp $ + * $Id: dvbdevice.c 1.133 2005/08/14 10:52:26 kls Exp $ */ #include "dvbdevice.h" @@ -291,7 +291,7 @@ bool cDvbTuner::SetFrontend(void) void cDvbTuner::Action(void) { dvb_frontend_event event; - while (Active()) { + while (Running()) { Lock(); if (tunerStatus == tsSet) { while (GetFrontendEvent(event)) diff --git a/dvbplayer.c b/dvbplayer.c index 8763ac82..feb82d8e 100644 --- a/dvbplayer.c +++ b/dvbplayer.c @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: dvbplayer.c 1.37 2005/08/13 12:27:17 kls Exp $ + * $Id: dvbplayer.c 1.38 2005/08/14 10:52:45 kls Exp $ */ #include "dvbplayer.h" @@ -144,7 +144,7 @@ int cNonBlockingFileReader::Read(int FileHandle, uchar *Buffer, int Length) void cNonBlockingFileReader::Action(void) { - while (Active()) { + while (Running()) { Lock(); if (!hasData && f >= 0 && buffer) { int r = safe_read(f, buffer + length, wanted - length); @@ -201,7 +201,7 @@ protected: public: cDvbPlayer(const char *FileName); virtual ~cDvbPlayer(); - bool Active(void) { return cThread::Active(); } + bool Active(void) { return cThread::Running(); } void Pause(void); void Play(void); void Forward(void); @@ -363,7 +363,7 @@ void cDvbPlayer::Action(void) int Length = 0; bool Sleep = false; - while (Active() && (NextFile() || readIndex >= 0 || ringBuffer->Available() || !DeviceFlush(100))) { + while (Running() && (NextFile() || readIndex >= 0 || ringBuffer->Available() || !DeviceFlush(100))) { if (Sleep) { cCondWait::SleepMs(3); // this keeps the CPU load low Sleep = false; @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: recorder.c 1.14 2005/08/13 11:33:35 kls Exp $ + * $Id: recorder.c 1.15 2005/08/14 10:53:28 kls Exp $ */ #include <stdarg.h> @@ -93,11 +93,11 @@ bool cFileWriter::NextFile(void) void cFileWriter::Action(void) { time_t t = time(NULL); - while (Active()) { + while (Running()) { int Count; uchar *p = remux->Get(Count, &pictureType); if (p) { - if (!Active() && pictureType == I_FRAME) // finish the recording before the next 'I' frame + if (!Running() && pictureType == I_FRAME) // finish the recording before the next 'I' frame break; if (NextFile()) { if (index && pictureType != NO_PICTURE) @@ -155,16 +155,16 @@ void cRecorder::Activate(bool On) void cRecorder::Receive(uchar *Data, int Length) { - if (Active()) { + if (Running()) { int p = ringBuffer->Put(Data, Length); - if (p != Length && Active()) + if (p != Length && Running()) ringBuffer->ReportOverflow(Length - p); } } void cRecorder::Action(void) { - while (Active()) { + while (Running()) { int r; uchar *b = ringBuffer->Get(r); if (b) { @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: remote.c 1.43 2005/08/13 11:28:35 kls Exp $ + * $Id: remote.c 1.44 2005/08/14 10:53:55 kls Exp $ */ #include "remote.h" @@ -259,11 +259,11 @@ int cKbdRemote::MapCodeToFunc(uint64 Code) void cKbdRemote::Action(void) { cPoller Poller(STDIN_FILENO); - while (Active()) { + while (Running()) { if (Poller.Poll(100)) { uint64 Command = 0; uint i = 0; - while (Active() && i < sizeof(Command)) { + while (Running() && i < sizeof(Command)) { uchar ch; int r = read(STDIN_FILENO, &ch, 1); if (r == 1) { @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: sections.c 1.12 2005/08/13 11:25:04 kls Exp $ + * $Id: sections.c 1.13 2005/08/14 10:54:39 kls Exp $ */ #include "sections.h" @@ -165,7 +165,7 @@ void cSectionHandler::SetStatus(bool On) void cSectionHandler::Action(void) { SetPriority(19); - while (Active()) { + while (Running()) { Lock(); if (waitForLock) @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: thread.c 1.44 2005/08/13 11:22:37 kls Exp $ + * $Id: thread.c 1.45 2005/08/14 11:15:42 kls Exp $ */ #include "thread.h" @@ -197,7 +197,7 @@ bool cThread::emergencyExitRequested = false; cThread::cThread(const char *Description) { - running = active = false; + active = running = false; childTid = 0; description = NULL; SetDescription(Description); @@ -234,31 +234,31 @@ void *cThread::StartThread(cThread *Thread) Thread->Action(); if (Thread->description) dsyslog("%s thread ended (pid=%d, tid=%ld)", Thread->description, getpid(), pthread_self()); - Thread->active = false; Thread->running = false; + Thread->active = false; return NULL; } bool cThread::Start(void) { - if (!running) { - running = active = true; + if (!active) { + active = running = true; if (pthread_create(&childTid, NULL, (void *(*) (void *))&StartThread, (void *)this) == 0) { pthread_detach(childTid); // auto-reap pthread_setschedparam(childTid, SCHED_RR, 0); } else { LOG_ERROR; - running = active = false; + active = running = false; return false; } } return true; } -bool cThread::Running(void) +bool cThread::Active(void) { - if (running) { + if (active) { // // Single UNIX Spec v2 says: // @@ -273,7 +273,7 @@ bool cThread::Running(void) if (err != ESRCH) LOG_ERROR; childTid = 0; - running = active = false; + active = running = false; } else return true; @@ -283,11 +283,11 @@ bool cThread::Running(void) void cThread::Cancel(int WaitSeconds) { - active = false; - if (running) { + running = false; + if (active) { if (WaitSeconds > 0) { for (time_t t0 = time(NULL) + WaitSeconds; time(NULL) < t0; ) { - if (!Running()) + if (!Active()) return; cCondWait::SleepMs(10); } @@ -295,7 +295,7 @@ void cThread::Cancel(int WaitSeconds) } pthread_cancel(childTid); childTid = 0; - running = false; + active = false; } } @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: thread.h 1.29 2005/08/13 13:01:33 kls Exp $ + * $Id: thread.h 1.30 2005/08/14 11:21:48 kls Exp $ */ #ifndef __THREAD_H @@ -75,8 +75,8 @@ public: class cThread { friend class cThreadLock; private: - bool running; bool active; + bool running; pthread_t childTid; cMutex mutex; char *description; @@ -89,13 +89,13 @@ protected: 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 Active() repeatedly to see whether + ///< a loop, it must check Running() repeatedly to see whether ///< it's time to stop. - bool Active(void) { return active; } + 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 'active' to false, so that + ///< 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. @@ -109,8 +109,8 @@ public: void SetDescription(const char *Description, ...); bool Start(void); ///< Actually starts the thread. - bool Running(void); - ///< Checks whether the thread is actually running. + bool Active(void); + ///< Checks whether the thread is still alive. static bool EmergencyExit(bool Request = false); }; @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: transfer.c 1.29 2005/08/13 11:19:46 kls Exp $ + * $Id: transfer.c 1.30 2005/08/14 10:55:03 kls Exp $ */ #include "transfer.h" @@ -41,9 +41,9 @@ void cTransfer::Activate(bool On) void cTransfer::Receive(uchar *Data, int Length) { - if (IsAttached() && Active()) { + if (IsAttached() && Running()) { int p = ringBuffer->Put(Data, Length); - if (p != Length && Active()) + if (p != Length && Running()) ringBuffer->ReportOverflow(Length - p); return; } @@ -65,7 +65,7 @@ void cTransfer::Action(void) bool GotBufferReserve = false; int RequiredBufferReserve = KILOBYTE(DvbCardWith4MBofSDRAM ? 288 : 576); #endif - while (Active()) { + while (Running()) { #ifdef FW_NEEDS_BUFFER_RESERVE_FOR_AC3 if (needsBufferReserve && !GotBufferReserve) { //XXX For dolby we've to fill the buffer because the firmware does |