summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Kendall <mkendall@mythtv.org>2011-04-12 02:44:15 (GMT)
committer Mark Kendall <mkendall@mythtv.org>2011-04-12 02:44:15 (GMT)
commit4068639223cf10eab3c63af8b57a1928b4c5965b (patch)
treef3b7e059f516ea08399c6c5256b1f0c50a930f45
parent2a9d9f5e4c2847f347d9fd23adc6d83158970a89 (diff)
libmythtv: Use the actual MythPlayer pause state
Remove the pause member variable from PlayerContext and access the pause state of the player directly. Fixes some inconsistencies in the pause state and another step along the long road of removing PlayerContext entirely. Pimped from master 8c18a320ac62b4921a0a Closes #9665
-rw-r--r--mythtv/libs/libmythtv/mythplayer.h1
-rw-r--r--mythtv/libs/libmythtv/playercontext.cpp2
-rw-r--r--mythtv/libs/libmythtv/playercontext.h1
-rw-r--r--mythtv/libs/libmythtv/tv_play.cpp136
-rw-r--r--mythtv/libs/libmythtv/tv_play.h3
-rw-r--r--mythtv/libs/libmythtv/tvbrowsehelper.cpp8
6 files changed, 80 insertions, 71 deletions
diff --git a/mythtv/libs/libmythtv/mythplayer.h b/mythtv/libs/libmythtv/mythplayer.h
index 87f8753..d3d4d70 100644
--- a/mythtv/libs/libmythtv/mythplayer.h
+++ b/mythtv/libs/libmythtv/mythplayer.h
@@ -173,6 +173,7 @@ class MPUBLIC MythPlayer
PIPLocation GetNextPIPLocation(void) const;
// Bool Gets
+ bool IsPaused(void) { return allpaused; }
bool GetRawAudioState(void) const;
bool GetLimitKeyRepeat(void) const { return limitKeyRepeat; }
bool GetEof(void);
diff --git a/mythtv/libs/libmythtv/playercontext.cpp b/mythtv/libs/libmythtv/playercontext.cpp
index 2464bdd..5a238dc 100644
--- a/mythtv/libs/libmythtv/playercontext.cpp
+++ b/mythtv/libs/libmythtv/playercontext.cpp
@@ -42,7 +42,7 @@ PlayerContext::PlayerContext(const QString &inUseID) :
// Fast forward state
ff_rew_state(0), ff_rew_index(0), ff_rew_speed(0),
// Other state
- paused(false), playingState(kState_None),
+ playingState(kState_None),
errored(false),
// pseudo states
pseudoLiveTVRec(NULL), pseudoLiveTVState(kPseudoNormalLiveTV),
diff --git a/mythtv/libs/libmythtv/playercontext.h b/mythtv/libs/libmythtv/playercontext.h
index 97faf89..e2f6b28 100644
--- a/mythtv/libs/libmythtv/playercontext.h
+++ b/mythtv/libs/libmythtv/playercontext.h
@@ -184,7 +184,6 @@ class MPUBLIC PlayerContext
int ff_rew_index;
/// Caches value of ff_rew_speeds[ff_rew_index]
int ff_rew_speed;
- bool paused;
TVState playingState;
bool errored;
diff --git a/mythtv/libs/libmythtv/tv_play.cpp b/mythtv/libs/libmythtv/tv_play.cpp
index baf1d23..f17fd37 100644
--- a/mythtv/libs/libmythtv/tv_play.cpp
+++ b/mythtv/libs/libmythtv/tv_play.cpp
@@ -1178,7 +1178,6 @@ bool TV::Init(bool createWindow)
}
PlayerContext *mctx = GetPlayerReadLock(0, __FILE__, __LINE__);
- mctx->paused = false;
mctx->ff_rew_state = 0;
mctx->ff_rew_index = kInitFFRWSpeed;
mctx->ff_rew_speed = 0;
@@ -3111,18 +3110,12 @@ void TV::HandleEndOfPlaybackTimerEvent(void)
void TV::HandleIsNearEndWhenEmbeddingTimerEvent(void)
{
PlayerContext *actx = GetPlayerReadLock(-1, __FILE__, __LINE__);
-
- bool toggle = !actx->paused && !StateIsLiveTV(GetState(actx));
-
- if (toggle)
+ if (!StateIsLiveTV(GetState(actx)))
{
actx->LockDeletePlayer(__FILE__, __LINE__);
-
- toggle = actx->player && actx->player->IsEmbedding()
- && actx->player->IsNearEnd();
-
+ bool toggle = actx->player && actx->player->IsEmbedding() &&
+ actx->player->IsNearEnd() && !actx->player->IsPaused();
actx->UnlockDeletePlayer(__FILE__, __LINE__);
-
if (toggle)
DoTogglePause(actx, true);
}
@@ -3155,7 +3148,7 @@ void TV::HandleEndOfRecordingExitPromptTimerEvent(void)
jumped_back = false;
do_prompt = mctx->player->IsNearEnd() && !jumped_back &&
- !mctx->player->IsEmbedding() && !mctx->paused;
+ !mctx->player->IsEmbedding() && !mctx->player->IsPaused();
}
mctx->UnlockDeletePlayer(__FILE__, __LINE__);
@@ -3921,7 +3914,7 @@ bool TV::ActiveHandleAction(PlayerContext *ctx,
DoPlay(ctx);
else if (has_action("PAUSE", actions))
{
- if (ctx->paused)
+ if (ContextIsPaused(ctx, __FILE__, __LINE__))
SendMythSystemPlayEvent("PLAY_UNPAUSED", ctx->playingInfo);
else
SendMythSystemPlayEvent("PLAY_PAUSED", ctx->playingInfo);
@@ -4482,12 +4475,13 @@ void TV::ProcessNetworkControlCommand(PlayerContext *ctx,
}
else if (tokens.size() == 3 && tokens[1] == "SPEED")
{
+ bool paused = ContextIsPaused(ctx, __FILE__, __LINE__);
+
if (tokens[2] == "0x")
{
NormalSpeed(ctx);
StopFFRew(ctx);
-
- if (!ctx->paused)
+ if (!paused)
DoTogglePause(ctx, true);
}
else
@@ -4529,7 +4523,7 @@ void TV::ProcessNetworkControlCommand(PlayerContext *ctx,
float searchSpeed = fabs(tmpSpeed);
unsigned int index;
- if (ctx->paused)
+ if (paused)
DoTogglePause(ctx, true);
if (tmpSpeed == 0.0f)
@@ -4537,7 +4531,7 @@ void TV::ProcessNetworkControlCommand(PlayerContext *ctx,
NormalSpeed(ctx);
StopFFRew(ctx);
- if (!ctx->paused)
+ if (!paused)
DoTogglePause(ctx, true);
}
else if (tmpSpeed == 1.0f)
@@ -4675,8 +4669,7 @@ void TV::ProcessNetworkControlCommand(PlayerContext *ctx,
if (tokens[2] == "POSITION")
{
QString speedStr;
-
- if (ctx->paused)
+ if (ContextIsPaused(ctx, __FILE__, __LINE__))
{
speedStr = "pause";
}
@@ -5522,10 +5515,9 @@ void TV::DoPlay(PlayerContext *ctx)
ctx->player->Play(ctx->ts_normal, true);
ctx->ff_rew_speed = 0;
}
- else if (ctx->paused || (ctx->ff_rew_speed != 0))
+ else if (ctx->player->IsPaused() || (ctx->ff_rew_speed != 0))
{
ctx->player->Play(ctx->ts_normal, true);
- ctx->paused = false;
ctx->ff_rew_speed = 0;
}
ctx->UnlockDeletePlayer(__FILE__, __LINE__);
@@ -5555,7 +5547,7 @@ float TV::DoTogglePauseStart(PlayerContext *ctx)
ctx->UnlockDeletePlayer(__FILE__, __LINE__);
return 0.0f;
}
- if (ctx->paused)
+ if (ctx->player->IsPaused())
{
ctx->player->Play(ctx->ts_normal, true);
}
@@ -5571,9 +5563,6 @@ float TV::DoTogglePauseStart(PlayerContext *ctx)
ctx->player->Pause();
}
ctx->UnlockDeletePlayer(__FILE__, __LINE__);
-
- ctx->paused = !ctx->paused;
-
return time;
}
@@ -5585,7 +5574,7 @@ void TV::DoTogglePauseFinish(PlayerContext *ctx, float time, bool showOSD)
if (ctx->buffer && ctx->buffer->InDVDMenuOrStillFrame())
return;
- if (ctx->paused)
+ if (ContextIsPaused(ctx, __FILE__, __LINE__))
{
if (ctx->buffer)
ctx->buffer->WaitForPause();
@@ -5689,7 +5678,7 @@ bool TV::SeekHandleAction(PlayerContext *actx, const QStringList &actions,
{
DoArbSeek(actx, static_cast<ArbSeekWhence>(flags & kWhenceMask));
}
- else if (actx->paused)
+ else if (ContextIsPaused(actx, __FILE__, __LINE__))
{
if (!isDVD)
{
@@ -5791,7 +5780,7 @@ void TV::ChangeSpeed(PlayerContext *ctx, int direction)
{
int old_speed = ctx->ff_rew_speed;
- if (ctx->paused)
+ if (ContextIsPaused(ctx, __FILE__, __LINE__))
ctx->ff_rew_speed = -4;
ctx->ff_rew_speed += direction;
@@ -5827,8 +5816,6 @@ void TV::ChangeSpeed(PlayerContext *ctx, int direction)
return;
}
ctx->UnlockDeletePlayer(__FILE__, __LINE__);
-
- ctx->paused = false;
DoPlayerSeek(ctx, time);
UpdateOSDSeekMessage(ctx, mesg, kOSDTimeout_Med);
@@ -5888,7 +5875,6 @@ void TV::ChangeFFRew(PlayerContext *ctx, int direction)
else
{
NormalSpeed(ctx);
- ctx->paused = false;
ctx->ff_rew_state = direction;
SetFFRew(ctx, kInitFFRWSpeed);
}
@@ -6447,12 +6433,11 @@ void TV::ToggleInputs(PlayerContext *ctx, uint inputid)
return;
}
- // If Nuppel Video Player is paused, unpause it
- if (ctx->paused)
+ // If MythPlayer is paused, unpause it
+ if (ContextIsPaused(ctx, __FILE__, __LINE__))
{
HideOSDWindow(ctx, "osd_status");
GetMythUI()->DisableScreensaver();
- ctx->paused = false;
}
const QString curinputname = ctx->recorder->GetInput();
@@ -6777,11 +6762,10 @@ void TV::ChangeChannel(PlayerContext *ctx, int direction)
QString oldinputname = ctx->recorder->GetInput();
- if (ctx->paused)
+ if (ContextIsPaused(ctx, __FILE__, __LINE__))
{
HideOSDWindow(ctx, "osd_status");
GetMythUI()->DisableScreensaver();
- ctx->paused = false;
}
// Save the current channel if this is the first time
@@ -6890,11 +6874,10 @@ void TV::ChangeChannel(PlayerContext *ctx, uint chanid, const QString &chan)
if (getit || !ctx->recorder || !ctx->recorder->CheckChannel(channum))
return;
- if (ctx->paused)
+ if (ContextIsPaused(ctx, __FILE__, __LINE__))
{
HideOSDWindow(ctx, "osd_status");
GetMythUI()->DisableScreensaver();
- ctx->paused = false;
}
// Save the current channel if this is the first time
@@ -7019,12 +7002,12 @@ bool TV::ClearOSD(const PlayerContext *ctx)
/** \fn TV::ToggleOSD(const PlayerContext*, bool includeStatus)
* \brief Cycle through the available Info OSDs.
*/
-void TV::ToggleOSD(const PlayerContext *ctx, bool includeStatusOSD)
+void TV::ToggleOSD(PlayerContext *ctx, bool includeStatusOSD)
{
OSD *osd = GetOSDLock(ctx);
bool hideAll = false;
bool showStatus = false;
- if (ctx->paused || !osd)
+ if (ContextIsPaused(ctx, __FILE__, __LINE__) || !osd)
{
ReturnOSDLock(ctx, osd);
return;
@@ -7660,7 +7643,9 @@ vector<bool> TV::DoSetPauseState(PlayerContext *lctx, const vector<bool> &pause)
vector<float> times;
for (uint i = 0; lctx && i < player.size() && i < pause.size(); i++)
{
- was_paused.push_back(GetPlayer(lctx,i)->paused);
+ PlayerContext *actx = GetPlayer(lctx, i);
+ if (actx)
+ was_paused.push_back(ContextIsPaused(actx, __FILE__, __LINE__));
float time = 0.0f;
if (pause[i] ^ was_paused.back())
time = DoTogglePauseStart(GetPlayer(lctx,i));
@@ -7711,18 +7696,23 @@ void TV::DoEditSchedule(int editType)
bool isNearEnd = false;
bool isLiveTV = StateIsLiveTV(GetState(actx));
bool allowEmbedding = false;
+ bool paused = false;
{
actx->LockDeletePlayer(__FILE__, __LINE__);
- pause_active = !actx->player || !actx->player->getVideoOutput();
- if (actx->player && actx->player->getVideoOutput())
- allowEmbedding = actx->player->getVideoOutput()->AllowPreviewEPG();
-
- if (!pause_active)
- {
- long long margin = (long long)
- (actx->last_framerate * actx->player->GetAudioStretchFactor());
- isNearEnd = actx->player->IsNearEnd(margin);
+ pause_active = !actx->player;
+ if (actx->player)
+ {
+ pause_active = !actx->player->getVideoOutput();
+ paused = actx->player->IsPaused();
+ if (actx->player->getVideoOutput())
+ allowEmbedding = actx->player->getVideoOutput()->AllowPreviewEPG();
+ if (!pause_active)
+ {
+ long long margin = (long long)
+ (actx->last_framerate * actx->player->GetAudioStretchFactor());
+ isNearEnd = actx->player->IsNearEnd(margin);
+ }
}
actx->UnlockDeletePlayer(__FILE__, __LINE__);
}
@@ -7732,7 +7722,7 @@ void TV::DoEditSchedule(int editType)
pause_active |= kScheduleProgramFinder == editType;
pause_active |=
!isLiveTV && (!db_continue_embedded || isNearEnd);
- pause_active |= actx->paused;
+ pause_active |= paused;
vector<bool> do_pause;
do_pause.insert(do_pause.begin(), true, player.size());
do_pause[find_player_index(actx)] = pause_active;
@@ -7875,13 +7865,10 @@ void TV::ChangeTimeStretch(PlayerContext *ctx, int dir, bool allowEdit)
ctx->ts_normal = new_ts_normal;
- if (!ctx->paused)
- {
- ctx->LockDeletePlayer(__FILE__, __LINE__);
- if (ctx->player)
+ ctx->LockDeletePlayer(__FILE__, __LINE__);
+ if (ctx->player && !ctx->player->IsPaused())
ctx->player->Play(ctx->ts_normal, true);
- ctx->UnlockDeletePlayer(__FILE__, __LINE__);
- }
+ ctx->UnlockDeletePlayer(__FILE__, __LINE__);
if (!browsehelper->IsBrowsing())
{
@@ -9053,7 +9040,7 @@ void TV::ShowOSDAlreadyEditing(PlayerContext *ctx)
if (osd)
{
osd->DialogQuit();
- bool was_paused = ctx->paused;
+ bool was_paused = ContextIsPaused(ctx, __FILE__, __LINE__);
if (!was_paused)
DoTogglePause(ctx, true);
@@ -9074,13 +9061,15 @@ void TV::HandleOSDAlreadyEditing(PlayerContext *ctx, QString action,
if (!DialogIsVisible(ctx, OSD_DLG_EDITING))
return;
+ bool paused = ContextIsPaused(ctx, __FILE__, __LINE__);
+
if (action == "STOP")
{
ctx->LockPlayingInfo(__FILE__, __LINE__);
if (ctx->playingInfo)
ctx->playingInfo->SaveEditing(false);
ctx->UnlockPlayingInfo(__FILE__, __LINE__);
- if (!was_paused && ctx->paused)
+ if (!was_paused && paused)
DoTogglePause(ctx, true);
}
else // action == "CONTINUE"
@@ -9090,7 +9079,7 @@ void TV::HandleOSDAlreadyEditing(PlayerContext *ctx, QString action,
{
ctx->playingInfo->SaveEditing(false);
editmode = ctx->player->EnableEdit();
- if (!editmode && !was_paused && ctx->paused)
+ if (!editmode && !was_paused && paused)
DoTogglePause(ctx, false);
}
ctx->UnlockDeletePlayer(__FILE__, __LINE__);
@@ -9594,7 +9583,7 @@ void TV::OSDDialogEvent(int result, QString text, QString action)
StopFFRew(actx);
- if (actx->paused)
+ if (ContextIsPaused(actx, __FILE__, __LINE__))
DoTogglePause(actx, true);
ChangeTimeStretch(actx, 0, !floatRead); // just display
@@ -11218,7 +11207,7 @@ void TV::ITVRestart(PlayerContext *ctx, bool isLive)
uint chanid = 0;
uint cardid = 0;
- if (ctx->paused)
+ if (ContextIsPaused(ctx, __FILE__, __LINE__))
return;
ctx->LockPlayingInfo(__FILE__, __LINE__);
@@ -11419,7 +11408,7 @@ void TV::ShowOSDStopWatchingRecording(PlayerContext *ctx)
if ((ctx != GetPlayer(ctx, 0)))
return;
- if (!ctx->paused)
+ if (!ContextIsPaused(ctx, __FILE__, __LINE__))
DoTogglePause(ctx, false);
QString message;
@@ -11540,7 +11529,7 @@ void TV::ShowOSDPromptDeleteRecording(PlayerContext *ctx, QString title,
ClearOSD(ctx);
- bool paused = ctx->paused;
+ bool paused = ContextIsPaused(ctx, __FILE__, __LINE__);
if (!paused)
DoTogglePause(ctx, false);
@@ -11691,8 +11680,9 @@ bool TV::PromptRecGroupPassword(PlayerContext *ctx)
if (!lastProgram)
return false;
- bool stayPaused = ctx->paused;
- if (!ctx->paused)
+ bool paused = ContextIsPaused(ctx, __FILE__, __LINE__);
+ bool stayPaused = paused;
+ if (!paused)
DoTogglePause(ctx, false);
QString recGroupPassword;
lastProgram->SetRecordingGroup(lastProgram->QueryRecordingGroup());
@@ -11717,14 +11707,14 @@ bool TV::PromptRecGroupPassword(PlayerContext *ctx)
{
SetOSDMessage(ctx, tr("Password Failed"));
- if (ctx->paused && !stayPaused)
+ if (ContextIsPaused(ctx, __FILE__, __LINE__) && !stayPaused)
DoTogglePause(ctx, false);
return false;
}
}
- if (ctx->paused && !stayPaused)
+ if (ContextIsPaused(ctx, __FILE__, __LINE__) && !stayPaused)
DoTogglePause(ctx, false);
return true;
@@ -11806,6 +11796,18 @@ void TV::HandleUDPNotifyEvent(void)
ReturnPlayerLock(mctx);
}
+bool TV::ContextIsPaused(PlayerContext *ctx, const char *file, int location)
+{
+ if (!ctx)
+ return false;
+ bool paused = false;
+ ctx->LockDeletePlayer(file, location);
+ if (ctx->player)
+ paused = ctx->player->IsPaused();
+ ctx->UnlockDeletePlayer(file, location);
+ return paused;
+}
+
OSD *TV::GetOSDL(const char *file, int location)
{
PlayerContext *actx = GetPlayerReadLock(-1, file, location);
diff --git a/mythtv/libs/libmythtv/tv_play.h b/mythtv/libs/libmythtv/tv_play.h
index 64f80c7..205cd7a 100644
--- a/mythtv/libs/libmythtv/tv_play.h
+++ b/mythtv/libs/libmythtv/tv_play.h
@@ -307,6 +307,7 @@ class MPUBLIC TV : public QObject
static EMBEDRETURNVOIDSCHEDIT RunScheduleEditorPtr;
private:
+ bool ContextIsPaused(PlayerContext *ctx, const char *file, int location);
void SetActive(PlayerContext *lctx, int index, bool osd_msg);
PlayerContext *GetPlayerWriteLock(
@@ -462,7 +463,7 @@ class MPUBLIC TV : public QObject
const QStringList &actions);
bool ClearOSD(const PlayerContext*);
- void ToggleOSD(const PlayerContext*, bool includeStatusOSD);
+ void ToggleOSD(PlayerContext*, bool includeStatusOSD);
void UpdateOSDProgInfo(const PlayerContext*, const char *whichInfo);
void UpdateOSDStatus(const PlayerContext *ctx, QString title, QString desc,
QString value, int type, QString units,
diff --git a/mythtv/libs/libmythtv/tvbrowsehelper.cpp b/mythtv/libs/libmythtv/tvbrowsehelper.cpp
index d3f2abf..d08db85 100644
--- a/mythtv/libs/libmythtv/tvbrowsehelper.cpp
+++ b/mythtv/libs/libmythtv/tvbrowsehelper.cpp
@@ -6,6 +6,7 @@
#include "playercontext.h"
#include "remoteencoder.h"
#include "recordinginfo.h"
+#include "mythplayer.h"
#include "tv_play.h"
#define GetPlayer(X,Y) GetPlayerHaveLock(X, Y, __FILE__ , __LINE__)
@@ -65,7 +66,12 @@ bool TVBrowseHelper::BrowseStart(PlayerContext *ctx, bool skip_browse)
if (m_ctx)
return m_ctx == ctx;
- if (ctx->paused)
+ bool paused = false;
+ ctx->LockDeletePlayer(__FILE__, __LINE__);
+ if (ctx->player)
+ paused = ctx->player->IsPaused();
+ ctx->UnlockDeletePlayer(__FILE__, __LINE__);
+ if (paused)
return false;
m_tv->ClearOSD(ctx);