Skip to content

Commit

Permalink
TV: Move debug OSD into MythPlayerUI
Browse files Browse the repository at this point in the history
  • Loading branch information
mark-kendall committed Oct 21, 2020
1 parent 3cf2647 commit 3273b58
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 75 deletions.
42 changes: 42 additions & 0 deletions mythtv/libs/libmythtv/mythplayerui.cpp
Expand Up @@ -23,13 +23,19 @@ MythPlayerUI::MythPlayerUI(MythMainWindow* MainWindow, TV* Tv,
DisplayPauseFrame();
});

// Seeking has finished
connect(this, &MythPlayerUI::SeekingComplete, [=]()
{
m_osdLock.lock();
if (m_osd)
m_osd->HideWindow("osd_message");
m_osdLock.unlock();
});

// Setup OSD debug
m_osdDebugTimer.setInterval(1000);
connect(&m_osdDebugTimer, &QTimer::timeout, this, &MythPlayerUI::UpdateOSDDebug);
connect(m_tv, &TV::ChangeOSDDebug, this, &MythPlayerUI::ChangeOSDDebug);
}

bool MythPlayerUI::StartPlaying()
Expand Down Expand Up @@ -834,6 +840,42 @@ void MythPlayerUI::GetCodecDescription(InfoMap& Map)
Map["videodescrip"] = "SD";
}

void MythPlayerUI::UpdateOSDDebug()
{
m_osdLock.lock();
if (m_osd)
{
InfoMap infoMap;
GetPlaybackData(infoMap);
m_osd->ResetWindow("osd_debug");
m_osd->SetText("osd_debug", infoMap, kOSDTimeout_None);
}
m_osdLock.unlock();
}

void MythPlayerUI::ChangeOSDDebug()
{
m_osdLock.lock();
if (m_osd)
{
bool enable = !m_osd->IsWindowVisible("osd_debug");
if (m_playerCtx->m_buffer)
m_playerCtx->m_buffer->EnableBitrateMonitor(enable);
EnableFrameRateMonitor(enable);
if (enable)
{
UpdateOSDDebug();
m_osdDebugTimer.start();
}
else
{
m_osdDebugTimer.stop();
m_osd->HideWindow("osd_debug");
}
}
m_osdLock.unlock();
}

void MythPlayerUI::EnableFrameRateMonitor(bool Enable)
{
bool verbose = VERBOSE_LEVEL_CHECK(VB_PLAYBACK, LOG_ANY);
Expand Down
13 changes: 12 additions & 1 deletion mythtv/libs/libmythtv/mythplayerui.h
Expand Up @@ -12,6 +12,12 @@ class MTV_PUBLIC MythPlayerUI : public MythPlayerVisualiserUI, public MythVideoS
{
Q_OBJECT

public slots:
void ChangeOSDDebug();

protected slots:
void UpdateOSDDebug();

public:
MythPlayerUI(MythMainWindow* MainWindow, TV* Tv, PlayerContext* Context, PlayerFlags Flags);

Expand All @@ -34,7 +40,6 @@ class MTV_PUBLIC MythPlayerUI : public MythPlayerVisualiserUI, public MythVideoS
void GetPlaybackData(InfoMap& Map);
void GetCodecDescription(InfoMap& Map);
void ToggleAdjustFill(AdjustFillMode Mode = kAdjustFill_Toggle);
void EnableFrameRateMonitor(bool Enable = false);
bool CanSupportDoubleRate();
void SetWatched(bool ForceWatched = false);
virtual void SetBookmark(bool Clear = false);
Expand Down Expand Up @@ -66,13 +71,19 @@ class MTV_PUBLIC MythPlayerUI : public MythPlayerVisualiserUI, public MythVideoS
void RefreshPauseFrame();
void RenderVideoFrame(MythVideoFrame* Frame, FrameScanType Scan, bool Prepare, int64_t Wait);
void DoDisplayVideoFrame(MythVideoFrame* Frame, int64_t Due);
void EnableFrameRateMonitor(bool Enable = false);

Jitterometer m_outputJmeter { "Player" };

// N.B. Editor - keep ringfenced and move into subclass
QElapsedTimer m_editUpdateTimer;
float m_speedBeforeEdit { 1.0 };
bool m_pausedBeforeEdit { false };

private:
Q_DISABLE_COPY(MythPlayerUI)

QTimer m_osdDebugTimer;
};

#endif
73 changes: 2 additions & 71 deletions mythtv/libs/libmythtv/tv_play.cpp
Expand Up @@ -2676,35 +2676,6 @@ void TV::timerEvent(QTimerEvent *Event)
handled = true;
}

if (handled)
return;

if (timer_id == m_updateOSDDebugTimerId)
{
bool update = false;
GetPlayerReadLock();
OSD *osd = GetOSDL();
if (osd && osd->IsWindowVisible("osd_debug") &&
(StateIsLiveTV(m_playerContext.GetState()) || StateIsPlaying(m_playerContext.GetState())))
{
update = true;
}
else
{
KillTimer(m_updateOSDDebugTimerId);
m_updateOSDDebugTimerId = 0;
if (m_playerContext.m_buffer)
m_playerContext.m_buffer->EnableBitrateMonitor(false);
if (m_player)
m_player->EnableFrameRateMonitor(false);
}
ReturnOSDLock();
if (update)
UpdateOSDDebug();
ReturnPlayerLock();
handled = true;
}

if (handled)
return;

Expand Down Expand Up @@ -4179,7 +4150,7 @@ bool TV::ActiveHandleAction(const QStringList &Actions,
ToggleOSD(true);
}
else if (has_action(ACTION_TOGGLEOSDDEBUG, Actions))
ToggleOSDDebug();
emit ChangeOSDDebug();
else if (!IsDVDStillFrame && SeekHandleAction(Actions, IsDVD))
{
}
Expand Down Expand Up @@ -6598,46 +6569,6 @@ void TV::ToggleOSD(bool IncludeStatusOSD)
}
}

void TV::ToggleOSDDebug()
{
bool show = false;
OSD *osd = GetOSDL();
if (osd && osd->IsWindowVisible("osd_debug"))
{
if (m_playerContext.m_buffer)
m_playerContext.m_buffer->EnableBitrateMonitor(false);
if (m_player)
m_player->EnableFrameRateMonitor(false);
osd->HideWindow("osd_debug");
}
else if (osd)
{
if (m_playerContext.m_buffer)
m_playerContext.m_buffer->EnableBitrateMonitor(true);
if (m_player)
m_player->EnableFrameRateMonitor(true);
show = true;
if (!m_updateOSDDebugTimerId)
m_updateOSDDebugTimerId = StartTimer(250, __LINE__);
}
ReturnOSDLock();
if (show)
UpdateOSDDebug();
}

void TV::UpdateOSDDebug()
{
OSD *osd = GetOSDL();
if (osd && m_player)
{
InfoMap infoMap;
m_player->GetPlaybackData(infoMap);
osd->ResetWindow("osd_debug");
osd->SetText("osd_debug", infoMap, kOSDTimeout_None);
}
ReturnOSDLock();
}

/** \fn TV::UpdateOSDProgInfo(const PlayerContext*, const char *whichInfo)
* \brief Update and display the passed OSD set with programinfo
*/
Expand Down Expand Up @@ -8734,7 +8665,7 @@ void TV::OSDDialogEvent(int Result, const QString& Text, QString Action)
else if (Action == ACTION_SEEKRWND)
DoSeekRWND();
else if (Action == ACTION_TOGGLEOSDDEBUG)
ToggleOSDDebug();
emit ChangeOSDDebug();
else if (Action == "TOGGLEMANUALZOOM")
SetManualZoom(true, tr("Zoom Mode ON"));
else if (Action == ACTION_BOTTOMLINEMOVE)
Expand Down
4 changes: 1 addition & 3 deletions mythtv/libs/libmythtv/tv_play.h
Expand Up @@ -317,6 +317,7 @@ class MTV_PUBLIC TV : public QObject, public MenuItemDisplayer, public Reference
void ChangeOSDPositionUpdates(bool Enable);
void ChangeMuteState(bool CycleChannels);
void ChangeVolume(bool Direction, int Volume, bool UpdateOSD);
void ChangeOSDDebug();

protected slots:
void onApplicationStateChange(Qt::ApplicationState State);
Expand Down Expand Up @@ -553,8 +554,6 @@ class MTV_PUBLIC TV : public QObject, public MenuItemDisplayer, public Reference
// OSD
bool ClearOSD();
void ToggleOSD( bool IncludeStatusOSD);
void ToggleOSDDebug();
void UpdateOSDDebug();
void UpdateOSDProgInfo(const char *WhichInfo);
void UpdateOSDStatus(const QString& Title, const QString& Desc,
const QString& Value, int Type, const QString& Units,
Expand Down Expand Up @@ -823,7 +822,6 @@ class MTV_PUBLIC TV : public QObject, public MenuItemDisplayer, public Reference
volatile int m_ccInputTimerId {0};
volatile int m_asInputTimerId {0};
volatile int m_queueInputTimerId {0};
volatile int m_updateOSDDebugTimerId {0};
volatile int m_endOfPlaybackTimerId {0};
volatile int m_endOfRecPromptTimerId {0};
volatile int m_videoExitDialogTimerId {0};
Expand Down

0 comments on commit 3273b58

Please sign in to comment.