114 changes: 56 additions & 58 deletions mythtv/libs/libmythtv/mythplayeravsync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,30 @@ MythPlayerAVSync::MythPlayerAVSync()

void MythPlayerAVSync::InitAVSync(void)
{
m_rtcBase = 0;
m_priorAudioTimecode = 0;
m_priorVideoTimecode = 0;
m_rtcBase = 0us;
m_priorAudioTimecode = 0ms;
m_priorVideoTimecode = 0ms;
m_lastFix = 0.0;
m_avsyncAvg = 0;
LOG(VB_PLAYBACK | VB_TIMESTAMP, LOG_INFO, LOC + "Reset");
}

void MythPlayerAVSync::WaitForFrame(int64_t FrameDue)
void MythPlayerAVSync::WaitForFrame(std::chrono::microseconds FrameDue)
{
int64_t unow = m_avTimer.nsecsElapsed() / 1000;
int64_t delay = FrameDue - unow;
if (delay > 0)
QThread::usleep(static_cast<unsigned long>(delay));
auto unow = std::chrono::microseconds(m_avTimer.nsecsElapsed() / 1000);
auto delay = FrameDue - unow;
if (delay > 0us)
QThread::usleep(delay.count());
}

int64_t& MythPlayerAVSync::DisplayTimecode()
std::chrono::milliseconds& MythPlayerAVSync::DisplayTimecode()
{
return m_dispTimecode;
}

void MythPlayerAVSync::ResetAVSyncClockBase()
{
m_rtcBase = 0;
m_rtcBase = 0us;
}

bool MythPlayerAVSync::GetAVSyncAudioPause() const
Expand All @@ -54,10 +54,10 @@ void MythPlayerAVSync::SetAVSyncAudioPause(bool Pause)

bool MythPlayerAVSync::ResetAVSyncForLiveTV(AudioPlayer* Audio)
{
bool result = m_rtcBase != 0;
bool result = m_rtcBase != 0us;
Audio->Pause(true);
m_avsyncAudioPaused = true;
m_rtcBase = 0;
m_rtcBase = 0us;
return result;
}

Expand All @@ -72,37 +72,36 @@ void MythPlayerAVSync::GetAVSyncData(InfoMap& Map) const
Map.insert("avsync", QObject::tr("%1 ms").arg(m_avsyncAvg / 1000));
}

#define AVSYNC_MAX_LATE 10000000
int64_t MythPlayerAVSync::AVSync(AudioPlayer *Audio, MythVideoFrame *Frame,
int FrameInterval, float PlaySpeed,
static constexpr std::chrono::microseconds AVSYNC_MAX_LATE { 10s };
std::chrono::microseconds MythPlayerAVSync::AVSync(AudioPlayer *Audio, MythVideoFrame *Frame,
std::chrono::microseconds FrameInterval, float PlaySpeed,
bool HaveVideo, bool Force)
{
int64_t videotimecode = 0;
std::chrono::milliseconds videotimecode = 0ms;
bool dropframe = false;
bool pause_audio = false;
int64_t framedue = 0;
int64_t audio_adjustment = 0;
int64_t unow = 0;
int64_t lateness = 0;
auto playspeed1000 = static_cast<int64_t>(1000.0F / PlaySpeed);
std::chrono::microseconds framedue = 0us;
std::chrono::milliseconds audio_adjustment = 0ms;
std::chrono::microseconds unow = 0ms;
std::chrono::microseconds lateness = 0us;
bool reset = false;
int intervalms = FrameInterval / 1000;
auto intervalms = duration_cast<std::chrono::milliseconds>(FrameInterval);
// controller gain
static float const s_av_control_gain = 0.4F;
// time weighted exponential filter coefficient
static float const s_sync_fc = 0.9F;

while (framedue == 0)
while (framedue == 0us)
{
if (Frame)
{
videotimecode = Frame->m_timecode & 0x0000ffffffffffff;
videotimecode = std::chrono::milliseconds(Frame->m_timecode & 0x0000ffffffffffff);
// Detect bogus timecodes from DVD and ignore them.
if (videotimecode != Frame->m_timecode)
if (videotimecode != std::chrono::milliseconds(Frame->m_timecode))
videotimecode = m_maxTcVal;
}

unow = m_avTimer.nsecsElapsed() / 1000;
unow = std::chrono::microseconds(m_avTimer.nsecsElapsed() / 1000);

if (Force)
{
Expand All @@ -111,30 +110,30 @@ int64_t MythPlayerAVSync::AVSync(AudioPlayer *Audio, MythVideoFrame *Frame,
}

// first time or after a seek - setup of m_rtcBase
if (m_rtcBase == 0)
if (m_rtcBase == 0us)
{
// cater for DVB radio
if (videotimecode == 0)
videotimecode = Audio->GetAudioTime().count();
if (videotimecode == 0ms)
videotimecode = Audio->GetAudioTime();

// cater for data only streams (i.e. MHEG)
bool dataonly = !Audio->HasAudioIn() && !HaveVideo;

// On first frame we get nothing, so exit out.
// FIXME - does this mean we skip the first frame? Should be avoidable.
if (videotimecode == 0 && !dataonly)
return 0;
if (videotimecode == 0ms && !dataonly)
return 0us;

m_rtcBase = unow - videotimecode * playspeed1000;
m_maxTcVal = 0;
m_rtcBase = unow - chronodivide<std::chrono::microseconds>(videotimecode, PlaySpeed);
m_maxTcVal = 0ms;
m_maxTcFrames = 0;
m_numDroppedFrames = 0;
}

if (videotimecode == 0)
if (videotimecode == 0ms)
videotimecode = m_maxTcVal + intervalms;
int64_t tcincr = videotimecode - m_maxTcVal;
if (tcincr > 0 || tcincr < -100)
std::chrono::milliseconds tcincr = videotimecode - m_maxTcVal;
if (tcincr > 0ms || tcincr < -100ms)
{
m_maxTcVal = videotimecode;
m_maxTcFrames = 0;
Expand All @@ -146,51 +145,50 @@ int64_t MythPlayerAVSync::AVSync(AudioPlayer *Audio, MythVideoFrame *Frame,
}

if (PlaySpeed > 0.0F)
framedue = m_rtcBase + videotimecode * playspeed1000;
framedue = m_rtcBase + chronodivide<std::chrono::microseconds>(videotimecode, PlaySpeed);
else
framedue = unow + FrameInterval / 2;

lateness = unow - framedue;
dropframe = false;
if (lateness > 30000)
if (lateness > 30ms)
dropframe = m_numDroppedFrames < 10;

if (lateness <= 30000 && m_priorAudioTimecode > 0 && m_priorVideoTimecode > 0)
if (lateness <= 30ms && m_priorAudioTimecode > 0ms && m_priorVideoTimecode > 0ms)
{
// Get video in sync with audio
audio_adjustment = m_priorAudioTimecode - m_priorVideoTimecode;
// If there is excess audio - throw it away.
if (audio_adjustment < -200)
if (audio_adjustment < -200ms)
{
Audio->Reset();
audio_adjustment = 0;
audio_adjustment = 0ms;
}
int sign = audio_adjustment < 0 ? -1 : 1;
float fix_amount = (m_lastFix * s_sync_fc + (1 - s_sync_fc) * audio_adjustment) * sign * s_av_control_gain;
m_lastFix = fix_amount * sign;
auto speedup1000 = static_cast<int64_t>(1000 * PlaySpeed);
m_rtcBase -= static_cast<int64_t>(1000000 * fix_amount * sign / speedup1000);
int sign = audio_adjustment < 0ms ? -1 : 1;
float fix_amount_ms = (m_lastFix * s_sync_fc + (1 - s_sync_fc) * audio_adjustment.count()) * sign * s_av_control_gain;
m_lastFix = fix_amount_ms * sign;
m_rtcBase -= microsecondsFromFloat(1000 * fix_amount_ms * sign / PlaySpeed);

if ((audio_adjustment * sign) > intervalms)
{
LOG(VB_PLAYBACK, LOG_INFO, LOC + QString("Audio %1 by %2 ms")
.arg(audio_adjustment > 0 ? "ahead" : "behind").arg(abs(audio_adjustment)));
.arg(audio_adjustment > 0ms ? "ahead" : "behind").arg(abs(audio_adjustment.count())));
}
if (audio_adjustment > 200)
if (audio_adjustment > 200ms)
pause_audio = true;
}

// sanity check - reset m_rtcBase if time codes have gone crazy.
if ((lateness > AVSYNC_MAX_LATE || lateness < - AVSYNC_MAX_LATE))
{
framedue = 0;
m_rtcBase = 0;
framedue = 0us;
m_rtcBase = 0us;
if (reset)
{
LOG(VB_GENERAL, LOG_ERR, LOC + QString("Resetting: lateness %1").arg(lateness));
return -1;
LOG(VB_GENERAL, LOG_ERR, LOC + QString("Resetting: lateness %1").arg(lateness.count()));
return -1us;
}
LOG(VB_PLAYBACK, LOG_INFO, LOC + QString("Resetting: lateness = %1").arg(lateness));
LOG(VB_PLAYBACK, LOG_INFO, LOC + QString("Resetting: lateness = %1").arg(lateness.count()));
reset = true;
}
}
Expand All @@ -211,21 +209,21 @@ int64_t MythPlayerAVSync::AVSync(AudioPlayer *Audio, MythVideoFrame *Frame,
}

// get time codes for calculating difference next time
m_priorAudioTimecode = Audio->GetAudioTime().count();
m_priorAudioTimecode = Audio->GetAudioTime();

if (dropframe)
{
m_numDroppedFrames++;
LOG(VB_PLAYBACK, LOG_INFO, LOC + QString("Dropping frame: Video is behind by %1ms")
.arg(lateness / 1000));
return -1;
.arg(duration_cast<std::chrono::milliseconds>(lateness).count()));
return -1us;
}

m_numDroppedFrames = 0;

LOG(VB_PLAYBACK | VB_TIMESTAMP, LOG_INFO, LOC +
QString("A/V timecodes audio=%1 video=%2 frameinterval=%3 audioadj=%4 unow=%5 udue=%6 ")
.arg(m_priorAudioTimecode).arg(m_priorVideoTimecode).arg(FrameInterval)
.arg(audio_adjustment).arg(unow).arg(framedue));
.arg(m_priorAudioTimecode.count()).arg(m_priorVideoTimecode.count()).arg(FrameInterval.count())
.arg(audio_adjustment.count()).arg(unow.count()).arg(framedue.count()));
return framedue;
}
19 changes: 10 additions & 9 deletions mythtv/libs/libmythtv/mythplayeravsync.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ class MythPlayerAVSync

public:
void InitAVSync ();
int64_t AVSync (AudioPlayer* Audio, MythVideoFrame* Frame, int FrameInterval,
float PlaySpeed, bool HaveVideo, bool Force);
void WaitForFrame (int64_t FrameDue);
int64_t& DisplayTimecode ();
std::chrono::microseconds AVSync (AudioPlayer* Audio, MythVideoFrame* Frame,
std::chrono::microseconds FrameInterval,
float PlaySpeed, bool HaveVideo, bool Force);
void WaitForFrame (std::chrono::microseconds FrameDue);
std::chrono::milliseconds& DisplayTimecode ();
void ResetAVSyncClockBase();
void GetAVSyncData (InfoMap& Map) const;
bool GetAVSyncAudioPause () const;
Expand All @@ -32,11 +33,11 @@ class MythPlayerAVSync
QElapsedTimer m_avTimer;
bool m_avsyncAudioPaused { false };
int m_avsyncAvg { 0 };
int64_t m_dispTimecode { 0 };
int64_t m_rtcBase { 0 }; // real time clock base for presentation time (microsecs)
int64_t m_maxTcVal { 0 }; // maximum to date video tc
int64_t m_priorAudioTimecode { 0 }; // time code from prior frame
int64_t m_priorVideoTimecode { 0 }; // time code from prior frame
std::chrono::milliseconds m_dispTimecode { 0ms };
std::chrono::microseconds m_rtcBase { 0us }; // real time clock base for presentation time
std::chrono::milliseconds m_maxTcVal { 0ms }; // maximum to date video tc
std::chrono::milliseconds m_priorAudioTimecode { 0ms }; // time code from prior frame
std::chrono::milliseconds m_priorVideoTimecode { 0ms }; // time code from prior frame
int m_maxTcFrames { 0 }; // number of frames seen since max to date tc
int m_numDroppedFrames { 0 }; // number of consecutive dropped frames.
float m_lastFix { 0.0F }; //last sync adjustment to prior frame]
Expand Down
24 changes: 12 additions & 12 deletions mythtv/libs/libmythtv/mythplayerui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -503,11 +503,11 @@ void MythPlayerUI::InitFrameInterval()
SetFrameInterval(GetScanType(), 1.0 / (m_videoFrameRate * static_cast<double>(m_playSpeed)));
MythPlayer::InitFrameInterval();
LOG(VB_PLAYBACK, LOG_INFO, LOC + QString("Display Refresh Rate: %1 Video Frame Rate: %2")
.arg(1000000.0 / m_display->GetRefreshInterval(m_frameInterval), 0, 'f', 3)
.arg(1000000.0 / m_frameInterval, 0, 'f', 3));
.arg(1000000.0 / m_display->GetRefreshInterval(m_frameInterval).count(), 0, 'f', 3)
.arg(1000000.0 / m_frameInterval.count(), 0, 'f', 3));
}

void MythPlayerUI::RenderVideoFrame(MythVideoFrame *Frame, FrameScanType Scan, bool Prepare, int64_t Wait)
void MythPlayerUI::RenderVideoFrame(MythVideoFrame *Frame, FrameScanType Scan, bool Prepare, std::chrono::microseconds Wait)
{
if (!m_videoOutput)
return;
Expand All @@ -521,7 +521,7 @@ void MythPlayerUI::RenderVideoFrame(MythVideoFrame *Frame, FrameScanType Scan, b
m_videoOutput->RenderOverlays(m_osd);
m_videoOutput->RenderEnd();

if (Wait > 0)
if (Wait > 0us)
m_avSync.WaitForFrame(Wait);

m_videoOutput->EndFrame();
Expand Down Expand Up @@ -576,9 +576,9 @@ void MythPlayerUI::RefreshPauseFrame()
}
}

void MythPlayerUI::DoDisplayVideoFrame(MythVideoFrame* Frame, int64_t Due)
void MythPlayerUI::DoDisplayVideoFrame(MythVideoFrame* Frame, std::chrono::microseconds Due)
{
if (Due < 0)
if (Due < 0us)
{
m_videoOutput->SetFramesPlayed(static_cast<long long>(++m_framesPlayed));
}
Expand Down Expand Up @@ -641,7 +641,7 @@ void MythPlayerUI::DisplayPauseFrame()

FrameScanType scan = GetScanType();
scan = (kScan_Detect == scan || kScan_Ignore == scan) ? kScan_Progressive : scan;
RenderVideoFrame(nullptr, scan, true, 0);
RenderVideoFrame(nullptr, scan, true, 0ms);
}

void MythPlayerUI::DisplayNormalFrame(bool CheckPrebuffer)
Expand Down Expand Up @@ -685,7 +685,7 @@ void MythPlayerUI::DisplayNormalFrame(bool CheckPrebuffer)
}

// When is the next frame due
int64_t due = m_avSync.AVSync(&m_audio, frame, m_frameInterval, m_playSpeed, !m_videoDim.isEmpty(),
std::chrono::microseconds due = m_avSync.AVSync(&m_audio, frame, m_frameInterval, m_playSpeed, !m_videoDim.isEmpty(),
!m_normalSpeed || FlagIsSet(kMusicChoice));
// Display it
DoDisplayVideoFrame(frame, due);
Expand Down Expand Up @@ -788,18 +788,18 @@ void MythPlayerUI::SetBookmark(bool Clear)

bool MythPlayerUI::CanSupportDoubleRate()
{
int refreshinterval = 1;
std::chrono::microseconds refreshinterval = 1us;
if (m_display)
refreshinterval = m_display->GetRefreshInterval(m_frameInterval);

// At this point we may not have the correct frame rate.
// Since interlaced is always at 25 or 30 fps, if the interval
// is less than 30000 (33fps) it must be representing one
// field and not one frame, so multiply by 2.
int realfi = m_frameInterval;
if (m_frameInterval < 30000)
std::chrono::microseconds realfi = m_frameInterval;
if (m_frameInterval < 30ms)
realfi = m_frameInterval * 2;
return ((realfi / 2.0) > (refreshinterval * 0.995));
return (duration_cast<floatusecs>(realfi) / 2.0) > (duration_cast<floatusecs>(refreshinterval) * 0.995);
}

void MythPlayerUI::GetPlaybackData(InfoMap& Map)
Expand Down
4 changes: 2 additions & 2 deletions mythtv/libs/libmythtv/mythplayerui.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ class MTV_PUBLIC MythPlayerUI : public MythPlayerVisualiserUI, public MythVideoS

void FileChanged();
void RefreshPauseFrame();
void RenderVideoFrame(MythVideoFrame* Frame, FrameScanType Scan, bool Prepare, int64_t Wait);
void DoDisplayVideoFrame(MythVideoFrame* Frame, int64_t Due);
void RenderVideoFrame(MythVideoFrame* Frame, FrameScanType Scan, bool Prepare, std::chrono::microseconds Wait);
void DoDisplayVideoFrame(MythVideoFrame* Frame, std::chrono::microseconds Due);
void EnableFrameRateMonitor(bool Enable = false);
void EnableBitrateMonitor(bool Enable = false);

Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythtv/mythvideoout.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class MythVideoOutput : public MythVideoBounds
virtual void InitPictureAttributes () { }
bool HasSoftwareFrames () const { return codec_sw_copy(m_videoCodecID); }
virtual void RenderOverlays (OSD& /*Osd*/) {}
virtual void UpdatePauseFrame (int64_t& /*DisplayTimecode*/,
virtual void UpdatePauseFrame (std::chrono::milliseconds& /*DisplayTimecode*/,
FrameScanType /*Scan*/ = kScan_Progressive) {}

protected:
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythtv/mythvideooutgpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ void MythVideoOutputGPU::RenderOverlays(OSD& Osd)
Osd.Draw(GetDisplayVisibleRect());
}

void MythVideoOutputGPU::UpdatePauseFrame(int64_t& DisplayTimecode, FrameScanType Scan)
void MythVideoOutputGPU::UpdatePauseFrame(std::chrono::milliseconds& DisplayTimecode, FrameScanType Scan)
{
MythVideoFrame* release = nullptr;
m_videoBuffers.BeginLock(kVideoBuffer_used);
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythtv/mythvideooutgpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class MythVideoOutputGPU : public MythVideoOutput
void SetVideoFrameRate (float NewRate) override;
void DiscardFrames (bool KeyFrame, bool Flushed) override;
void DoneDisplayingFrame (MythVideoFrame* Frame) override;
void UpdatePauseFrame (int64_t& DisplayTimecode, FrameScanType Scan = kScan_Progressive) override;
void UpdatePauseFrame (std::chrono::milliseconds& DisplayTimecode, FrameScanType Scan = kScan_Progressive) override;
bool InputChanged (QSize VideoDim, QSize VideoDispDim,
float Aspect, MythCodecID CodecId, bool& AspectOnly,
int ReferenceFrames, bool ForceChange) override;
Expand Down
7 changes: 4 additions & 3 deletions mythtv/libs/libmythtv/mythvideoscantracker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ FrameScanType MythVideoScanTracker::GetScanTypeWithOverride() const
return m_scan;
}

void MythVideoScanTracker::CheckScanUpdate(MythVideoOutput* VideoOutput, int FrameInterval)
void MythVideoScanTracker::CheckScanUpdate(MythVideoOutput* VideoOutput, std::chrono::microseconds FrameInterval)
{
if (m_resetScan != kScan_Ignore)
SetScanType(m_resetScan, VideoOutput, FrameInterval);
Expand All @@ -119,7 +119,8 @@ QString MythVideoScanTracker::GetDeinterlacerName()
return MythVideoFrame::DeinterlacerName(m_lastDeinterlacer, m_lastDeinterlacer2x, m_lastFrameCodec);
}

void MythVideoScanTracker::SetScanType(FrameScanType Scan, MythVideoOutput* VideoOutput, int FrameInterval)
void MythVideoScanTracker::SetScanType(FrameScanType Scan, MythVideoOutput* VideoOutput,
std::chrono::microseconds FrameInterval)
{
if (!is_current_thread(m_mainThread))
{
Expand Down Expand Up @@ -174,7 +175,7 @@ void MythVideoScanTracker::SetScanType(FrameScanType Scan, MythVideoOutput* Vide
* material that is not otherwise flagged correctly.
*/
void MythVideoScanTracker::AutoDeint(MythVideoFrame* Frame, MythVideoOutput* VideoOutput,
int FrameInterval, bool AllowLock)
std::chrono::microseconds FrameInterval, bool AllowLock)
{
if (!Frame)
return;
Expand Down
10 changes: 6 additions & 4 deletions mythtv/libs/libmythtv/mythvideoscantracker.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@ class MTV_PUBLIC MythVideoScanTracker
void UnlockScan ();
void ResetTracker ();

void SetScanType (FrameScanType Scan, MythVideoOutput* VideoOutput, int FrameInterval);
void SetScanType (FrameScanType Scan, MythVideoOutput* VideoOutput,
std::chrono::microseconds FrameInterval);
FrameScanType GetScanForDisplay (MythVideoFrame* Frame, bool& SecondField);
FrameScanType GetScanType () const;
virtual void AutoDeint (MythVideoFrame* Frame, MythVideoOutput* VideoOutput,
int FrameInterval, bool AllowLock = true);
void CheckScanUpdate (MythVideoOutput* VideoOutput, int FrameInterval);
std::chrono::microseconds FrameInterval, bool AllowLock = true);
void CheckScanUpdate (MythVideoOutput* VideoOutput,
std::chrono::microseconds FrameInterval);
QString GetDeinterlacerName ();
FrameScanType DetectInterlace (FrameScanType NewScan, float Rate, int VideoHeight);

Expand All @@ -41,7 +43,7 @@ class MTV_PUBLIC MythVideoScanTracker
FrameScanType m_scanOverride { kScan_Detect };
bool m_scanLocked { false };
bool m_scanInitialized { false };
int m_lastFrameInterval { 0 };
std::chrono::microseconds m_lastFrameInterval { 0us };
bool m_lastDeinterlacer2x { false };
MythDeintType m_lastDeinterlacer { DEINT_NONE };
VideoFrameType m_lastFrameCodec { FMT_NONE };
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythtv/videoout_d3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ void VideoOutputD3D::StopEmbedding(void)
MythVideoOutput::StopEmbedding();
}

void VideoOutputD3D::UpdatePauseFrame(int64_t &disp_timecode, FrameScanType)
void VideoOutputD3D::UpdatePauseFrame(std::chrono::milliseconds &disp_timecode, FrameScanType)
{
QMutexLocker locker(&m_lock);
MythVideoFrame *used_frame = m_videoBuffers.Head(kVideoBuffer_used);
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythtv/videoout_d3d.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class VideoOutputD3D : public MythVideoOutput
MythCodecID av_codec_id,
bool &aspect_only,
MythMultiLocker *Locks) override; // VideoOutput
void UpdatePauseFrame(int64_t &disp_timecode, FrameScanType Scan = kScan_Progressive) override; // VideoOutput
void UpdatePauseFrame(std::chrono::milliseconds &disp_timecode, FrameScanType Scan = kScan_Progressive) override; // VideoOutput
void EmbedInWidget(const QRect &rect) override; // VideoOutput
void StopEmbedding(void) override; // VideoOutput
static QStringList GetAllowedRenderers(MythCodecID myth_codec_id,
Expand Down
6 changes: 3 additions & 3 deletions mythtv/libs/libmythui/mythdisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -770,11 +770,11 @@ double MythDisplay::GetRefreshRate() const
return m_refreshRate;
}

int MythDisplay::GetRefreshInterval(int Fallback) const
std::chrono::microseconds MythDisplay::GetRefreshInterval(std::chrono::microseconds Fallback) const
{
if (m_refreshRate > 20.0 && m_refreshRate < 200.0)
return static_cast<int>(lround(1000000.0 / m_refreshRate));
if (Fallback > 33000) // ~30Hz
return microsecondsFromFloat(1000000.0 / m_refreshRate);
if (Fallback > 33ms) // ~30Hz
Fallback /= 2;
return Fallback;
}
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythui/mythdisplay.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class MUI_PUBLIC MythDisplay : public QObject, public ReferenceCounter
QSize GetResolution ();
QSize GetPhysicalSize ();
double GetRefreshRate () const;
int GetRefreshInterval (int Fallback) const;
std::chrono::microseconds GetRefreshInterval (std::chrono::microseconds Fallback) const;
double GetAspectRatio (QString &Source, bool IgnoreModeOverride = false);
double EstimateVirtualAspectRatio();
MythEDID& GetEDID ();
Expand Down