summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Kendall <mkendall@mythtv.org>2011-01-25 00:28:52 (GMT)
committer Mark Kendall <mkendall@mythtv.org>2011-01-25 00:28:52 (GMT)
commitb4bbb41032d3c9810309bc270b39471a0e2a94af (patch)
tree2335f2f82ec46ae7555d915d4f76ea65f8293791
parent32839c314e837e1e2644cdeee01af591e1cacc4b (diff)
OSD: Improved locking in MythPlayer and its subclasses.
This adds a couple of missing locks and ensures some existing locks are fully protecting access to the OSD object.
-rw-r--r--mythtv/libs/libmythtv/mythbdplayer.cpp2
-rw-r--r--mythtv/libs/libmythtv/mythdvdplayer.cpp9
-rw-r--r--mythtv/libs/libmythtv/mythplayer.cpp80
3 files changed, 53 insertions, 38 deletions
diff --git a/mythtv/libs/libmythtv/mythbdplayer.cpp b/mythtv/libs/libmythtv/mythbdplayer.cpp
index fcfef27..9bbb2a1 100644
--- a/mythtv/libs/libmythtv/mythbdplayer.cpp
+++ b/mythtv/libs/libmythtv/mythbdplayer.cpp
@@ -35,7 +35,7 @@ void MythBDPlayer::DisplayMenu(void)
osdLock.lock();
BDOverlay *overlay = NULL;
- while (NULL != (overlay = player_ctx->buffer->BD()->GetOverlay()))
+ while (osd && (NULL != (overlay = player_ctx->buffer->BD()->GetOverlay())))
osd->DisplayBDOverlay(overlay);
osdLock.unlock();
}
diff --git a/mythtv/libs/libmythtv/mythdvdplayer.cpp b/mythtv/libs/libmythtv/mythdvdplayer.cpp
index 9d17d77..42c3e7f 100644
--- a/mythtv/libs/libmythtv/mythdvdplayer.cpp
+++ b/mythtv/libs/libmythtv/mythdvdplayer.cpp
@@ -209,10 +209,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);
}
@@ -488,8 +490,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;
@@ -497,7 +501,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 051f6d7..1e84d86 100644
--- a/mythtv/libs/libmythtv/mythplayer.cpp
+++ b/mythtv/libs/libmythtv/mythplayer.cpp
@@ -1202,22 +1202,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;
@@ -1225,17 +1224,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)
@@ -1262,7 +1259,7 @@ bool MythPlayer::HandleTeletextAction(const QString &action)
osdLock.lock();
if (action == "MENU" || action == ACTION_TOGGLETT || action == "ESCAPE")
DisableTeletext();
- else
+ else if (osd)
handled = osd->TeletextAction(action);
osdLock.unlock();
@@ -1271,16 +1268,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();
}
}
@@ -1289,10 +1288,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");
@@ -1310,12 +1308,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)
{
@@ -2040,11 +2040,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);
@@ -3481,10 +3481,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);
@@ -3546,10 +3547,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);
@@ -3565,13 +3569,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);
@@ -3587,7 +3594,6 @@ void MythPlayer::DisableEdit(bool save)
Play(speedBeforeEdit);
else
SetOSDStatus(QObject::tr("Paused"), kOSDTimeout_None);
- osdLock.unlock();
}
bool MythPlayer::HandleProgramEditorActions(QStringList &actions,
@@ -3705,8 +3711,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();
}
@@ -4453,11 +4462,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;
@@ -4610,28 +4620,26 @@ void MythPlayer::ToggleStudioLevels(void)
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)