summaryrefslogtreecommitdiff
path: root/recorder.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2005-08-13 13:17:24 +0200
committerKlaus Schmidinger <vdr@tvdr.de>2005-08-13 13:17:24 +0200
commitccb0add798961ce2fa24f625a00106cb0d3df709 (patch)
tree43e50aa8938a53236d90e260700e83296b26987d /recorder.c
parent1921c7465fd72d8507b11230729754a17761c7e1 (diff)
downloadvdr-ccb0add798961ce2fa24f625a00106cb0d3df709.tar.gz
vdr-ccb0add798961ce2fa24f625a00106cb0d3df709.tar.bz2
Centralized 'thread active' handling
Diffstat (limited to 'recorder.c')
-rw-r--r--recorder.c25
1 files changed, 7 insertions, 18 deletions
diff --git a/recorder.c b/recorder.c
index dd3f4f60..253d8391 100644
--- a/recorder.c
+++ b/recorder.c
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: recorder.c 1.13 2005/01/16 12:53:17 kls Exp $
+ * $Id: recorder.c 1.14 2005/08/13 11:33:35 kls Exp $
*/
#include <stdarg.h>
@@ -29,7 +29,6 @@ private:
uchar pictureType;
int fileSize;
int recordFile;
- bool active;
time_t lastDiskSpaceCheck;
bool RunningLowOnDiskSpace(void);
bool NextFile(void);
@@ -43,7 +42,6 @@ public:
cFileWriter::cFileWriter(const char *FileName, cRemux *Remux)
:cThread("file writer")
{
- active = false;
fileName = NULL;
remux = Remux;
index = NULL;
@@ -63,7 +61,6 @@ cFileWriter::cFileWriter(const char *FileName, cRemux *Remux)
cFileWriter::~cFileWriter()
{
- active = false;
Cancel(3);
delete index;
delete fileName;
@@ -96,13 +93,11 @@ bool cFileWriter::NextFile(void)
void cFileWriter::Action(void)
{
time_t t = time(NULL);
- active = true;
- while (active) {
+ while (Active()) {
int Count;
uchar *p = remux->Get(Count, &pictureType);
if (p) {
- //XXX+ active??? see old version (Busy)
- if (!active && pictureType == I_FRAME) // finish the recording before the next 'I' frame
+ if (!Active() && pictureType == I_FRAME) // finish the recording before the next 'I' frame
break;
if (NextFile()) {
if (index && pictureType != NO_PICTURE)
@@ -124,15 +119,12 @@ void cFileWriter::Action(void)
t = time(NULL);
}
}
- active = false;
}
cRecorder::cRecorder(const char *FileName, int Ca, int Priority, int VPid, const int *APids, const int *DPids, const int *SPids)
:cReceiver(Ca, Priority, VPid, APids, Setup.UseDolbyDigital ? DPids : NULL, SPids)
,cThread("recording")
{
- active = false;
-
// Make sure the disk is up and running:
SpinUpDisk(FileName);
@@ -157,25 +149,22 @@ void cRecorder::Activate(bool On)
writer->Start();
Start();
}
- else if (active) {
- active = false;
+ else
Cancel(3);
- }
}
void cRecorder::Receive(uchar *Data, int Length)
{
- if (active) {
+ if (Active()) {
int p = ringBuffer->Put(Data, Length);
- if (p != Length && active)
+ if (p != Length && Active())
ringBuffer->ReportOverflow(Length - p);
}
}
void cRecorder::Action(void)
{
- active = true;
- while (active) {
+ while (Active()) {
int r;
uchar *b = ringBuffer->Get(r);
if (b) {