CAM handling refactored; multiple recordings with one CAM; automatic CAM selection

This commit is contained in:
Klaus Schmidinger
2007-01-07 14:46:14 +01:00
parent b4cab10eca
commit 87dd5139ff
32 changed files with 2116 additions and 1457 deletions

View File

@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
* $Id: thread.c 1.58 2006/09/24 12:54:47 kls Exp $
* $Id: thread.c 1.59 2007/01/07 14:44:22 kls Exp $
*/
#include "thread.h"
@@ -249,17 +249,29 @@ void *cThread::StartThread(cThread *Thread)
return NULL;
}
#define THREAD_STOP_TIMEOUT 3000 // ms to wait for a thread to stop before newly starting it
#define THREAD_STOP_SLEEP 30 // ms to sleep while waiting for a thread to stop
bool cThread::Start(void)
{
if (!active) {
active = running = true;
if (pthread_create(&childTid, NULL, (void *(*) (void *))&StartThread, (void *)this) == 0) {
pthread_detach(childTid); // auto-reap
if (!running) {
if (active) {
// Wait until the previous incarnation of this thread has completely ended
// before starting it newly:
cTimeMs RestartTimeout;
while (!running && active && RestartTimeout.Elapsed() < THREAD_STOP_TIMEOUT)
cCondWait::SleepMs(THREAD_STOP_SLEEP);
}
else {
LOG_ERROR;
active = running = false;
return false;
if (!active) {
active = running = true;
if (pthread_create(&childTid, NULL, (void *(*) (void *))&StartThread, (void *)this) == 0) {
pthread_detach(childTid); // auto-reap
}
else {
LOG_ERROR;
active = running = false;
return false;
}
}
}
return true;