summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Kendall <mkendall@mythtv.org>2011-01-26 02:24:42 (GMT)
committer Mark Kendall <mkendall@mythtv.org>2011-01-26 02:24:42 (GMT)
commitefe64a46adfead6d1af1c80bdca1906eb5e618e5 (patch)
treec11b128d1733cfe8a2ec6affc452376928d32157
parent57812c6f8af8ceb45144638f45c66560fc0c499b (diff)
OSD: Improved locking in MythPlayer and its subclasses.
(cherry picked from commit b4bbb41032d3c9810309bc270b39471a0e2a94af)
-rw-r--r--mythtv/libs/libmythtv/mythdvdplayer.cpp9
-rw-r--r--mythtv/libs/libmythtv/mythplayer.cpp80
2 files changed, 52 insertions, 37 deletions
diff --git a/mythtv/libs/libmythtv/mythdvdplayer.cpp b/mythtv/libs/libmythtv/mythdvdplayer.cpp
index a446991..9e26b1a 100644
--- a/mythtv/libs/libmythtv/mythdvdplayer.cpp
+++ b/mythtv/libs/libmythtv/mythdvdplayer.cpp
@@ -218,10 +218,12 @@ void MythDVDPlayer::DisplayLastFrame(void)
DisplayDVDButton();
+ osdLock.lock();
videofiltersLock.lock();
videoOutput->ProcessFrame(NULL, osd, videoFilters, pip_players,
kScan_Progressive);
videofiltersLock.unlock();
+ osdLock.unlock();
AVSync(NULL, true);
}
@@ -495,8 +497,10 @@ void MythDVDPlayer::DisplayDVDButton(void)
if (!numbuttons || !dvdSubtitle || (buttonversion == 0))
{
SetCaptionsEnabled(false, false);
+ osdLock.lock();
if (osd)
osd->ClearSubtitles();
+ osdLock.unlock();
m_buttonVersion = 0;
player_ctx->buffer->DVD()->ReleaseMenuButton();
return;
@@ -504,7 +508,10 @@ void MythDVDPlayer::DisplayDVDButton(void)
m_buttonVersion = buttonversion;
QRect buttonPos = player_ctx->buffer->DVD()->GetButtonCoords();
- osd->DisplayDVDButton(dvdSubtitle, buttonPos);
+ osdLock.lock();
+ if (osd)
+ osd->DisplayDVDButton(dvdSubtitle, buttonPos);
+ osdLock.unlock();
textDisplayMode = kDisplayDVDButton;
player_ctx->buffer->DVD()->ReleaseMenuButton();
}
diff --git a/mythtv/libs/libmythtv/mythplayer.cpp b/mythtv/libs/libmythtv/mythplayer.cpp
index 19f2803..f6c195d 100644
--- a/mythtv/libs/libmythtv/mythplayer.cpp
+++ b/mythtv/libs/libmythtv/mythplayer.cpp
@@ -1188,22 +1188,21 @@ void MythPlayer::WindowResized(const QSize &new_size)
void MythPlayer::EnableTeletext(int page)
{
+ QMutexLocker locker(&osdLock);
if (!osd)
return;
- osdLock.lock();
osd->EnableTeletext(true, page);
prevTextDisplayMode = textDisplayMode;
textDisplayMode = kDisplayTeletextMenu;
- osdLock.unlock();
}
void MythPlayer::DisableTeletext(void)
{
+ QMutexLocker locker(&osdLock);
if (!osd)
return;
- osdLock.lock();
osd->EnableTeletext(false, 0);
textDisplayMode = kDisplayNone;
@@ -1211,17 +1210,15 @@ void MythPlayer::DisableTeletext(void)
re-enabled them. */
if (prevTextDisplayMode & kDisplayAllCaptions)
EnableCaptions(prevTextDisplayMode, false);
- osdLock.unlock();
}
void MythPlayer::ResetTeletext(void)
{
+ QMutexLocker locker(&osdLock);
if (!osd)
return;
- osdLock.lock();
osd->TeletextReset();
- osdLock.unlock();
}
/** \fn MythPlayer::SetTeletextPage(uint)
@@ -1248,7 +1245,7 @@ bool MythPlayer::HandleTeletextAction(const QString &action)
osdLock.lock();
if (action == "MENU" || action == "TOGGLETT" || action == "ESCAPE")
DisableTeletext();
- else
+ else if (osd)
handled = osd->TeletextAction(action);
osdLock.unlock();
@@ -1257,16 +1254,18 @@ bool MythPlayer::HandleTeletextAction(const QString &action)
void MythPlayer::ResetCaptions(void)
{
- if (osd && ((textDisplayMode & kDisplayAVSubtitle) ||
- (textDisplayMode & kDisplayTextSubtitle) ||
- (textDisplayMode & kDisplayRawTextSubtitle) ||
- (textDisplayMode & kDisplayDVDButton) ||
- (textDisplayMode & kDisplayCC608) ||
- (textDisplayMode & kDisplayCC708)))
+ QMutexLocker locker(&osdLock);
+ if (!osd)
+ return;
+
+ if (((textDisplayMode & kDisplayAVSubtitle) ||
+ (textDisplayMode & kDisplayTextSubtitle) ||
+ (textDisplayMode & kDisplayRawTextSubtitle) ||
+ (textDisplayMode & kDisplayDVDButton) ||
+ (textDisplayMode & kDisplayCC608) ||
+ (textDisplayMode & kDisplayCC708)))
{
- osdLock.lock();
osd->ClearSubtitles();
- osdLock.unlock();
}
}
@@ -1275,10 +1274,9 @@ void MythPlayer::DisableCaptions(uint mode, bool osd_msg)
{
textDisplayMode &= ~mode;
ResetCaptions();
- if (!osd)
- return;
QMutexLocker locker(&osdLock);
+
QString msg = "";
if (kDisplayNUVTeletextCaptions & mode)
msg += QObject::tr("TXT CAP");
@@ -1296,12 +1294,14 @@ void MythPlayer::DisableCaptions(uint mode, bool osd_msg)
{
int type = toTrackType(mode);
msg += decoder->GetTrackDesc(type, GetTrack(type));
- osd->EnableSubtitles(preserve);
+ if (osd)
+ osd->EnableSubtitles(preserve);
}
if (kDisplayTextSubtitle & mode)
{
msg += QObject::tr("Text subtitles");
- osd->EnableSubtitles(preserve);
+ if (osd)
+ osd->EnableSubtitles(preserve);
}
if (!msg.isEmpty() && osd_msg)
{
@@ -1943,11 +1943,11 @@ void MythPlayer::PreProcessNormalFrame(void)
{
#ifdef USING_MHEG
// handle Interactive TV
- if (GetInteractiveTV() && osd)
+ if (GetInteractiveTV())
{
osdLock.lock();
itvLock.lock();
- if (videoOutput->GetOSDPainter())
+ if (osd && videoOutput->GetOSDPainter())
{
InteractiveScreen *window =
(InteractiveScreen*)osd->GetWindow(OSD_WIN_INTERACT);
@@ -3393,10 +3393,11 @@ void MythPlayer::WaitForSeek(uint64_t frame, bool override_seeks,
need_clear = true;
}
}
- if (need_clear && osd)
+ if (need_clear)
{
osdLock.lock();
- osd->HideWindow("osd_message");
+ if (osd)
+ osd->HideWindow("osd_message");
osdLock.unlock();
}
decoder->setExactSeeks(after);
@@ -3459,10 +3460,13 @@ bool MythPlayer::EnableEdit(void)
return false;
}
- if (!osd || deleteMap.IsFileEditing(player_ctx))
+ if (deleteMap.IsFileEditing(player_ctx))
+ return false;
+
+ QMutexLocker locker(&osdLock);
+ if (!osd)
return false;
- osdLock.lock();
speedBeforeEdit = play_speed;
pausedBeforeEdit = Pause();
deleteMap.SetEditing(true);
@@ -3478,13 +3482,16 @@ bool MythPlayer::EnableEdit(void)
player_ctx->playingInfo->SaveEditing(true);
player_ctx->UnlockPlayingInfo(__FILE__, __LINE__);
editUpdateTimer.start();
- osdLock.unlock();
+
return deleteMap.IsEditing();
}
void MythPlayer::DisableEdit(bool save)
{
- osdLock.lock();
+ QMutexLocker locker(&osdLock);
+ if (!osd)
+ return;
+
deleteMap.SetEditing(false, osd);
if (save)
deleteMap.SaveMap(totalFrames, player_ctx);
@@ -3500,7 +3507,6 @@ void MythPlayer::DisableEdit(bool save)
Play(speedBeforeEdit);
else
SetOSDStatus(QObject::tr("Paused"), kOSDTimeout_None);
- osdLock.unlock();
}
bool MythPlayer::HandleProgramEditorActions(QStringList &actions,
@@ -3618,8 +3624,11 @@ bool MythPlayer::HandleProgramEditorActions(QStringList &actions,
if (handled && refresh)
{
osdLock.lock();
- deleteMap.UpdateOSD(framesPlayed, totalFrames, video_frame_rate,
- player_ctx, osd);
+ if (osd)
+ {
+ deleteMap.UpdateOSD(framesPlayed, totalFrames, video_frame_rate,
+ player_ctx, osd);
+ }
osdLock.unlock();
}
@@ -4367,11 +4376,12 @@ int64_t MythPlayer::GetChapter(int chapter)
InteractiveTV *MythPlayer::GetInteractiveTV(void)
{
#ifdef USING_MHEG
- if (!interactiveTV && osd && itvEnabled)
+ if (!interactiveTV && itvEnabled)
{
QMutexLocker locker1(&osdLock);
QMutexLocker locker2(&itvLock);
- interactiveTV = new InteractiveTV(this);
+ if (osd)
+ interactiveTV = new InteractiveTV(this);
}
#endif // USING_MHEG
return interactiveTV;
@@ -4507,28 +4517,26 @@ QString MythPlayer::GetError(void) const
void MythPlayer::SetOSDMessage(const QString &msg, OSDTimeout timeout)
{
+ QMutexLocker locker(&osdLock);
if (!osd)
return;
- osdLock.lock();
QHash<QString,QString> info;
info.insert("message_text", msg);
osd->SetText("osd_message", info, timeout);
- osdLock.unlock();
}
void MythPlayer::SetOSDStatus(const QString &title, OSDTimeout timeout)
{
+ QMutexLocker locker(&osdLock);
if (!osd)
return;
- osdLock.lock();
osdInfo info;
calcSliderPos(info);
info.text.insert("title", title);
osd->SetText("osd_status", info.text, timeout);
osd->SetValues("osd_status", info.values, timeout);
- osdLock.unlock();
}
static unsigned dbg_ident(const MythPlayer *player)