Skip to content

Commit

Permalink
Revert "Convert MHEG Engine Thread to QThread"
Browse files Browse the repository at this point in the history
This reverts commit eb7d2bd.
  • Loading branch information
daniel-kristjansson committed Mar 28, 2011
1 parent cb8c753 commit 38481ad
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 26 deletions.
21 changes: 10 additions & 11 deletions mythtv/libs/libmythtv/mhi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ MHIContext::MHIContext(InteractiveTV *parent)
: m_parent(parent), m_dsmcc(NULL),
m_keyProfile(0),
m_engine(NULL), m_stop(false),
m_updated(false),
m_stopped(false), m_updated(false),
m_displayWidth(StdDisplayWidth), m_displayHeight(StdDisplayHeight),
m_face_loaded(false), m_currentChannel(-1),
m_isLive(false), m_currentCard(0),
Expand Down Expand Up @@ -132,13 +132,13 @@ void MHIContext::StopEngine()
{
if (m_engine)
{
while (m_engineThread.isRunning())
while (!m_stopped)
{
m_stop = true;
m_engine_wait.wakeAll();
usleep(1000);
}
m_engineThread.wait();
pthread_join(m_engineThread, NULL);
}
}

Expand Down Expand Up @@ -191,23 +191,22 @@ void MHIContext::Restart(uint chanid, uint cardid, bool isLive)
m_isLive = isLive;
// Don't set the NBI version here. Restart is called
// after the PMT is processed.
m_engineThread.SetParent(this);
m_engineThread.start();

m_stopped = pthread_create(&m_engineThread, NULL,
StartMHEGEngine, this) != 0;
m_audioTag = -1;
m_videoTag = -1;
m_tuningTo = -1;
}
}

// Thread function to run the MHEG engine.
void MHEGEngineThread::run(void)
void *MHIContext::StartMHEGEngine(void *param)
{
//VERBOSE(VB_GENERAL, "Starting MHEG Engine");
if (!m_parent)
return;

m_parent->RunMHEGEngine();
MHIContext *context = (MHIContext*) param;
context->RunMHEGEngine();
context->m_stopped = true;
return NULL;
}

void MHIContext::RunMHEGEngine(void)
Expand Down
20 changes: 5 additions & 15 deletions mythtv/libs/libmythtv/mhi.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#ifndef _MHI_H_
#define _MHI_H_

// POSIX header
#include <pthread.h>

// Misc header
#include <ft2build.h>
#include FT_FREETYPE_H
Expand All @@ -15,7 +18,6 @@ using namespace std;
#include <QString>
#include <QWaitCondition>
#include <QImage>
#include <QThread>

// MythTV headers
#include "../libmythfreemheg/freemheg.h"
Expand All @@ -33,25 +35,12 @@ class MythPainter;
class InteractiveScreen;
class DSMCCPacket;
class MHIImageData;
class MHIContext;

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

/** \class MHIContext
* \brief Contains various utility functions for interactive television.
*/
class MHIContext : public MHContext
{
friend class MHEGEngineThread;
public:
MHIContext(InteractiveTV *parent);
virtual ~MHIContext();
Expand Down Expand Up @@ -170,6 +159,7 @@ class MHIContext : public MHContext

QWaitCondition m_engine_wait;
bool m_stop;
bool m_stopped;
QMutex m_display_lock;
bool m_updated;
int m_displayWidth;
Expand All @@ -182,7 +172,7 @@ class MHIContext : public MHContext
FT_Face m_face;
bool m_face_loaded;

MHEGEngineThread m_engineThread;
pthread_t m_engineThread;

int m_currentChannel;
bool m_isLive;
Expand Down

0 comments on commit 38481ad

Please sign in to comment.