summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Kendall <mkendall@mythtv.org>2010-12-08 02:23:25 (GMT)
committer Mark Kendall <mkendall@mythtv.org>2010-12-08 02:23:25 (GMT)
commit3429e9b27366503e731f138e2bac1fcfc0c58a72 (patch)
tree37486093d82855c5cd49915853aab5be09bcbdda
parent5b7b93d2e6c94f4ba29fc49f445a4bdcf5b54a3b (diff)
Don't create an additional thread for media playback.
After the threading changes prior to the 0.24 release, this extra thread serves no purpose and is slowing down both startup and exiting of video playback. It may also have an impact on sluggish keypress responses reported by several people. There are various cleanups that can now be made in the TV class.
-rw-r--r--mythtv/libs/libmythtv/tv_play.cpp78
-rw-r--r--mythtv/libs/libmythtv/tv_play.h11
-rw-r--r--mythtv/programs/mythfrontend/guidegrid.cpp7
3 files changed, 24 insertions, 72 deletions
diff --git a/mythtv/libs/libmythtv/tv_play.cpp b/mythtv/libs/libmythtv/tv_play.cpp
index 0dcbcc6..83241c1 100644
--- a/mythtv/libs/libmythtv/tv_play.cpp
+++ b/mythtv/libs/libmythtv/tv_play.cpp
@@ -845,14 +845,6 @@ void TV::ResetKeys(void)
}
-class TVInitRunnable : public QRunnable
-{
- public:
- TVInitRunnable(TV *ourTV) : tv(ourTV) {}
- virtual void run(void) { tv->InitFromDB(); }
- TV *tv;
-};
-
/** \fn TV::TV(void)
* \sa Init(void)
*/
@@ -954,7 +946,7 @@ TV::TV(void)
playerActive = 0;
playerLock.unlock();
- QThreadPool::globalInstance()->start(new TVInitRunnable(this), 99);
+ InitFromDB();
VERBOSE(VB_PLAYBACK, LOC + "ctor -- end");
}
@@ -1181,15 +1173,29 @@ bool TV::Init(bool createWindow)
}
}
- mainLoopCondLock.lock();
- start();
- mainLoopCond.wait(&mainLoopCondLock);
+ PlayerContext *mctx = GetPlayerReadLock(0, __FILE__, __LINE__);
+ mctx->paused = false;
+ mctx->ff_rew_state = 0;
+ mctx->ff_rew_index = kInitFFRWSpeed;
+ mctx->ff_rew_speed = 0;
+ mctx->ts_normal = 1.0f;
+ ReturnPlayerLock(mctx);
+
+ sleep_index = 0;
+
+ SetUpdateOSDPosition(false);
+
+ const PlayerContext *ctx = GetPlayerReadLock(0, __FILE__, __LINE__);
+ ClearInputQueues(ctx, false);
+ ReturnPlayerLock(ctx);
+
+ switchToRec = NULL;
+ SetExitPlayer(false, false);
+
errorRecoveryTimerId = StartTimer(kErrorRecoveryCheckFrequency, __LINE__);
lcdTimerId = StartTimer(1, __LINE__);
speedChangeTimerId = StartTimer(kSpeedChangeCheckFrequency, __LINE__);
- mainLoopCondLock.unlock();
-
VERBOSE(VB_PLAYBACK, LOC + "Init -- end");
return true;
}
@@ -1218,9 +1224,6 @@ TV::~TV(void)
myWindow = NULL;
}
- TV::exit(0);
- TV::wait();
-
VERBOSE(VB_PLAYBACK, "TV::~TV() -- lock");
// restore window to gui size and position
@@ -2453,44 +2456,6 @@ void TV::TeardownPlayer(PlayerContext *mctx, PlayerContext *ctx)
}
}
-void TV::run(void)
-{
- PlayerContext *mctx = GetPlayerReadLock(0, __FILE__, __LINE__);
- mctx->paused = false;
- mctx->ff_rew_state = 0;
- mctx->ff_rew_index = kInitFFRWSpeed;
- mctx->ff_rew_speed = 0;
- mctx->ts_normal = 1.0f;
- ReturnPlayerLock(mctx);
-
- sleep_index = 0;
-
- SetUpdateOSDPosition(false);
-
- const PlayerContext *ctx = GetPlayerReadLock(0, __FILE__, __LINE__);
- ClearInputQueues(ctx, false);
- ReturnPlayerLock(ctx);
-
- switchToRec = NULL;
- SetExitPlayer(false, false);
-
- mainLoopCondLock.lock();
- mainLoopCond.wakeAll();
- mainLoopCondLock.unlock();
-
- exec();
-
- mctx = GetPlayerWriteLock(0, __FILE__, __LINE__);
- if (!mctx->IsErrored() && (GetState(mctx) != kState_None))
- {
- mctx->ForceNextStateNone();
- HandleStateChange(mctx, mctx);
- if (jumpToProgram)
- TeardownPlayer(mctx, mctx);
- }
- ReturnPlayerLock(mctx);
-}
-
void TV::timerEvent(QTimerEvent *te)
{
const int timer_id = te->timerId();
@@ -2499,7 +2464,6 @@ void TV::timerEvent(QTimerEvent *te)
if (mctx->IsErrored())
{
ReturnPlayerLock(mctx);
- QThread::exit(1);
return;
}
ReturnPlayerLock(mctx);
@@ -3465,7 +3429,7 @@ bool TV::event(QEvent *e)
break;
}
- return QThread::event(e);
+ return QObject::event(e);
}
bool TV::HandleTrackAction(PlayerContext *ctx, const QString &action)
diff --git a/mythtv/libs/libmythtv/tv_play.h b/mythtv/libs/libmythtv/tv_play.h
index 11ac935..c048fc7 100644
--- a/mythtv/libs/libmythtv/tv_play.h
+++ b/mythtv/libs/libmythtv/tv_play.h
@@ -164,9 +164,8 @@ class AskProgramInfo
ProgramInfo *info;
};
-class MPUBLIC TV : public QThread
+class MPUBLIC TV : public QObject
{
- friend class QTVEventThread;
friend class PlaybackBox;
friend class GuideGrid;
friend class TvPlayWindow;
@@ -233,9 +232,6 @@ class MPUBLIC TV : public QThread
// Boolean queries
/// Returns true if we are currently in the process of switching recorders.
bool IsSwitchingCards(void) const { return switchToRec; }
- /// Returns true if the TV event thread is running. Should always be true
- /// between the end of the constructor and the beginning of the destructor.
- bool IsRunning(void) const { return isRunning(); }
/// Returns true if the user told Mythtv to allow re-recording of the show
bool getAllowRerecord(void) const { return allowRerecord; }
/// This is set to true if the player reaches the end of the
@@ -298,7 +294,6 @@ class MPUBLIC TV : public QThread
void DoEditSchedule(int editType = kScheduleProgramGuide);
- virtual void run(void);
void TVEventThreadChecks(void);
void PauseAudioUntilBuffered(PlayerContext *ctx);
@@ -861,10 +856,6 @@ class MPUBLIC TV : public QThread
TimerContextMap signalMonitorTimerId;
TimerContextMap tvchainUpdateTimerId;
- /// Condition to signal that the Event thread is up and running
- QWaitCondition mainLoopCond;
- QMutex mainLoopCondLock;
-
/// Condition to signal State changes
QWaitCondition stateChangeCond;
QMutex stateChangeCondLock;
diff --git a/mythtv/programs/mythfrontend/guidegrid.cpp b/mythtv/programs/mythfrontend/guidegrid.cpp
index 9af1caf..c05b876 100644
--- a/mythtv/programs/mythfrontend/guidegrid.cpp
+++ b/mythtv/programs/mythfrontend/guidegrid.cpp
@@ -264,9 +264,6 @@ GuideGrid::GuideGrid(MythScreenStack *parent,
m_currentStartTime = m_originalStartTime.addSecs(secsoffset);
m_startChanID = chanid;
m_startChanNum = channum;
-
- if (m_player)
- m_embedVideo = m_player->IsRunning() && m_embedVideo;
}
bool GuideGrid::Create()
@@ -2200,7 +2197,7 @@ void GuideGrid::EmbedTVWindow(void)
void GuideGrid::refreshVideo(void)
{
- if (m_player && m_player->IsRunning() && m_usingNullVideo)
+ if (m_player && m_usingNullVideo)
{
GetMythMainWindow()->GetPaintWindow()->update(m_videoRect);
}
@@ -2216,7 +2213,7 @@ void GuideGrid::aboutToHide(void)
void GuideGrid::aboutToShow(void)
{
- if (m_player && m_player->IsRunning())
+ if (m_player)
EmbedTVWindow();
MythScreenType::aboutToShow();