Skip to content

Commit

Permalink
Revert "Convert NuppelVideoRecorder threads to QThreads"
Browse files Browse the repository at this point in the history
This reverts commit 72f13d4.

Conflicts:

	mythtv/libs/libmythtv/NuppelVideoRecorder.cpp
	mythtv/libs/libmythtv/NuppelVideoRecorder.h
  • Loading branch information
daniel-kristjansson committed Mar 28, 2011
1 parent 2c2bcfb commit d64f768
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 52 deletions.
48 changes: 27 additions & 21 deletions mythtv/libs/libmythtv/NuppelVideoRecorder.cpp
Expand Up @@ -1109,7 +1109,7 @@ void NuppelVideoRecorder::StartRecording(void)
return;
}

if (!SpawnChildren())
if (SpawnChildren() < 0)
{
VERBOSE(VB_IMPORTANT, LOC_ERR + "Couldn't spawn children");
errored = true;
Expand Down Expand Up @@ -1862,38 +1862,42 @@ void NuppelVideoRecorder::DoV4L2(void) {}
void NuppelVideoRecorder::DoMJPEG(void) {}
#endif // USING_V4L

bool NuppelVideoRecorder::SpawnChildren(void)
int NuppelVideoRecorder::SpawnChildren(void)
{
int result;

childrenLive = true;

WriteThread.SetParent(this);
WriteThread.start();
if (!WriteThread.isRunning())
result = pthread_create(&write_tid, NULL,
NuppelVideoRecorder::WriteThread, this);

if (result)
{
VERBOSE(VB_IMPORTANT, LOC_ERR + "Couldn't spawn writer thread, exiting");
return false;
return -1;
}

AudioThread.SetParent(this);
AudioThread.start();
if (!AudioThread.isRunning())
result = pthread_create(&audio_tid, NULL,
NuppelVideoRecorder::AudioThread, this);

if (result)
{
VERBOSE(VB_IMPORTANT, LOC_ERR + "Couldn't spawn audio thread, exiting");
return false;
return -1;
}

if ((vbimode != VBIMode::None) && (OpenVBIDevice() >= 0))
vbi_thread = new VBIThread(this);

return true;
return 0;
}

void NuppelVideoRecorder::KillChildren(void)
{
childrenLive = false;

WriteThread.wait();
AudioThread.wait();
pthread_join(write_tid, NULL);
pthread_join(audio_tid, NULL);
if (vbi_thread)
{
vbi_thread->wait();
Expand Down Expand Up @@ -2321,20 +2325,22 @@ void NuppelVideoRecorder::Reset(void)
curRecording->ClearPositionMap(MARK_KEYFRAME);
}

void NVRWriteThread::run(void)
void *NuppelVideoRecorder::WriteThread(void *param)
{
if (!m_parent)
return;
NuppelVideoRecorder *nvr = (NuppelVideoRecorder *)param;

m_parent->doWriteThread();
nvr->doWriteThread();

return NULL;
}

void NVRAudioThread::run(void)
void *NuppelVideoRecorder::AudioThread(void *param)
{
if (!m_parent)
return;
NuppelVideoRecorder *nvr = (NuppelVideoRecorder *)param;

nvr->doAudioThread();

m_parent->doAudioThread();
return NULL;
}

void NuppelVideoRecorder::doAudioThread(void)
Expand Down
39 changes: 8 additions & 31 deletions mythtv/libs/libmythtv/NuppelVideoRecorder.h
Expand Up @@ -6,7 +6,7 @@

#include <sys/time.h>
#include <time.h>
#include <QThread>
#include <pthread.h>
#ifdef MMX
#undef MMX
#define MMXBLAH
Expand Down Expand Up @@ -45,35 +45,8 @@ class FilterManager;
class FilterChain;
class AudioInput;

class NuppelVideoRecorder;

class NVRWriteThread : public QThread
{
Q_OBJECT
public:
NVRWriteThread() : m_parent(NULL) {}
void run(void);
void SetParent(NuppelVideoRecorder *parent) { m_parent = parent; }
private:
NuppelVideoRecorder *m_parent;
};

class NVRAudioThread : public QThread
{
Q_OBJECT
public:
NVRAudioThread() : m_parent(NULL) {}
void run(void);
void SetParent(NuppelVideoRecorder *parent) { m_parent = parent; }
private:
NuppelVideoRecorder *m_parent;
};

class MTV_PUBLIC NuppelVideoRecorder : public V4LRecorder, public CC608Input
{
friend class NVRWriteThread;
friend class NVRAudioThread;
friend class NVRVbiThread;
public:
NuppelVideoRecorder(TVRec *rec, ChannelBase *channel);
~NuppelVideoRecorder();
Expand Down Expand Up @@ -132,6 +105,10 @@ class MTV_PUBLIC NuppelVideoRecorder : public V4LRecorder, public CC608Input
void SetNewVideoParams(double newaspect);

protected:
static void *WriteThread(void *param);
static void *AudioThread(void *param);
static void *VbiThread(void *param);

void doWriteThread(void);
void doAudioThread(void);

Expand All @@ -146,7 +123,7 @@ class MTV_PUBLIC NuppelVideoRecorder : public V4LRecorder, public CC608Input

bool MJPEGInit(void);

bool SpawnChildren(void);
int SpawnChildren(void);
void KillChildren(void);

void BufferIt(unsigned char *buf, int len = -1, bool forcekey = false);
Expand Down Expand Up @@ -230,8 +207,8 @@ class MTV_PUBLIC NuppelVideoRecorder : public V4LRecorder, public CC608Input

bool childrenLive;

NVRWriteThread WriteThread;
NVRAudioThread AudioThread;
pthread_t write_tid;
pthread_t audio_tid;

bool recording;
bool errored;
Expand Down

0 comments on commit d64f768

Please sign in to comment.