Skip to content
Permalink
Browse files

OSD: Improved locking in MythPlayer and its subclasses.

(cherry picked from commit b4bbb41)
  • Loading branch information
Mark Kendall
Mark Kendall committed Jan 26, 2011
1 parent 57812c6 commit efe64a46adfead6d1af1c80bdca1906eb5e618e5
Showing with 52 additions and 37 deletions.
  1. +8 −1 mythtv/libs/libmythtv/mythdvdplayer.cpp
  2. +44 −36 mythtv/libs/libmythtv/mythplayer.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,16 +497,21 @@ 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;
}

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();
}
@@ -1188,40 +1188,37 @@ 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;

/* If subtitles are enabled before the teletext menu was displayed,
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)

0 comments on commit efe64a4

Please sign in to comment.
You can’t perform that action at this time.