4 changes: 2 additions & 2 deletions mythtv/libs/libmyth/netutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,12 +327,12 @@ bool markTreeUpdated(GrabberScript* script, const QDateTime& curTime)
return (query.numRowsAffected() > 0);
}

bool needsUpdate(GrabberScript* script, uint updateFreq)
bool needsUpdate(GrabberScript* script, std::chrono::hours updateFreq)
{
QDateTime now = MythDate::current();
QDateTime then = lastUpdate(script);

return then.addSecs(updateFreq * 60 * 60) < now;
return then.addSecs(duration_cast<std::chrono::seconds>(updateFreq).count()) < now;
}

QDateTime lastUpdate(GrabberScript* script)
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmyth/netutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ MPUBLIC bool findSearchGrabberInDB(const QString &commandline, ArticleType type)
MPUBLIC GrabberScript* findSearchGrabberByCommand(const QString &url, ArticleType type);
MPUBLIC GrabberScript::scriptList findAllDBSearchGrabbers(ArticleType type);
MPUBLIC bool markTreeUpdated(GrabberScript *script, const QDateTime& curTime);
MPUBLIC bool needsUpdate(GrabberScript *script, uint updateFreq);
MPUBLIC bool needsUpdate(GrabberScript *script, std::chrono::hours updateFreq);
MPUBLIC QDateTime lastUpdate(GrabberScript* script);

MPUBLIC bool clearTreeItems(const QString &feedcommand);
Expand Down
5 changes: 3 additions & 2 deletions mythtv/libs/libmyth/output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,16 @@ void OutputListeners::removeVisual(MythTV::Visual *v)
}

void OutputListeners::dispatchVisual(uchar *buffer, unsigned long b_len,
unsigned long written, int chan, int prec)
std::chrono::milliseconds timecode,
int chan, int prec)
{
if (! buffer)
return;

for (auto & visual : m_visuals)
{
QMutexLocker locker(visual->mutex());
visual->add(buffer, b_len, written, chan, prec);
visual->add(buffer, b_len, timecode, chan, prec);
}
}

Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmyth/output.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class MPUBLIC OutputListeners : public MythObservable
protected:
void error(const QString &e);
void dispatchVisual(uchar *b, unsigned long b_len,
unsigned long written, int chan, int prec);
std::chrono::milliseconds timecode, int chan, int prec);
void prepareVisuals();

private:
Expand Down
3 changes: 2 additions & 1 deletion mythtv/libs/libmyth/visual.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ class Visual
Visual() { ; }
virtual ~Visual() { ; }

virtual void add(const void *b, unsigned long b_len, unsigned long w, int c, int p) = 0;
virtual void add(const void *b, unsigned long b_len,
std::chrono::milliseconds timecode, int c, int p) = 0;
virtual void prepare() = 0;

QMutex *mutex() { return &m_mtx; }
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythtv/deletemap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ void DeleteMap::UpdateOSD(uint64_t frame, double frame_rate, OSD *osd)
m_cachedTotalForOSD = total;
}

void DeleteMap::UpdateOSD(int64_t timecode, OSD *osd)
void DeleteMap::UpdateOSD(std::chrono::milliseconds timecode, OSD *osd)
{
osd->SetGraph(OSD_WIN_PROGEDIT, "audiograph", timecode);
}
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythtv/deletemap.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class MTV_PUBLIC DeleteMap
void SetSeekAmount(float amount) { m_seekamount = amount; }

void UpdateOSD(uint64_t frame, double frame_rate, OSD *osd);
static void UpdateOSD(int64_t timecode, OSD *osd);
static void UpdateOSD(std::chrono::milliseconds timecode, OSD *osd);

bool IsEditing(void) const { return m_editing; }
void SetEditing(bool edit, OSD *osd = nullptr);
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythtv/mythplayerui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ void MythPlayerUI::RefreshPauseFrame()
if (m_deleteMap.IsEditing())
{
m_osdLock.lock();
DeleteMap::UpdateOSD(m_latestVideoTimecode, &m_osd);
DeleteMap::UpdateOSD(std::chrono::milliseconds(m_latestVideoTimecode), &m_osd);
m_osdLock.unlock();
}
}
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythtv/osd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ void OSD::SetRegions(const QString &Window, frm_dir_map_t &Map, long long Total)
bar->Display();
}

void OSD::SetGraph(const QString &Window, const QString &Graph, int64_t Timecode)
void OSD::SetGraph(const QString &Window, const QString &Graph, std::chrono::milliseconds Timecode)
{
MythScreenType *win = GetWindow(Window);
if (!win)
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythtv/osd.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class OSD : public MythMediaOverlay
void SetValues(const QString &Window, const QHash<QString,int> &Map, OSDTimeout Timeout);
void SetValues(const QString &Window, const QHash<QString,float> &Map, OSDTimeout Timeout);
void SetRegions(const QString &Window, frm_dir_map_t &Map, long long Total);
void SetGraph(const QString &Window, const QString &Graph, int64_t Timecode);
void SetGraph(const QString &Window, const QString &Graph, std::chrono::milliseconds Timecode);
bool IsWindowVisible(const QString &Window);

bool DialogVisible(const QString& Window = QString());
Expand Down
13 changes: 7 additions & 6 deletions mythtv/libs/libmythtv/visualisations/videovisual.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ VideoVisual::~VideoVisual()
mutex()->unlock();
}

int64_t VideoVisual::SetLastUpdate(void)
std::chrono::milliseconds VideoVisual::SetLastUpdate(void)
{
QDateTime now = QDateTime::currentDateTimeUtc();
int64_t result = m_lastUpdate.time().msecsTo(now.time());
auto result = std::chrono::milliseconds(m_lastUpdate.time().msecsTo(now.time()));
m_lastUpdate = now;
return result;
}
Expand All @@ -81,7 +81,7 @@ void VideoVisual::prepare()
// caller holds lock
VisualNode* VideoVisual::GetNode(void)
{
int64_t timestamp = m_audio->GetAudioTime().count();
std::chrono::milliseconds timestamp = m_audio->GetAudioTime();
while (m_nodes.size() > 1)
{
if (m_nodes.front()->m_offset > timestamp)
Expand Down Expand Up @@ -118,8 +118,9 @@ static inline void mono16_from_monofloat32(
}

// caller holds lock
void VideoVisual::add(const void *b, unsigned long b_len, unsigned long w, int c,
int p)
void VideoVisual::add(const void *b, unsigned long b_len,
std::chrono::milliseconds timecode,
int c, int p)
{
if (!m_disabled && m_nodes.size() > 500)
{
Expand Down Expand Up @@ -174,5 +175,5 @@ void VideoVisual::add(const void *b, unsigned long b_len, unsigned long w, int c
else
len = 0;

m_nodes.append(new VisualNode(l, r, len, w));
m_nodes.append(new VisualNode(l, r, len, timecode));
}
14 changes: 9 additions & 5 deletions mythtv/libs/libmythtv/visualisations/videovisual.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#include "mythpainter.h"
#include "videovisualdefs.h"

using namespace std::chrono_literals;

#define DESC QString("Visualiser: ")

class MythRender;
Expand All @@ -22,8 +24,8 @@ class AudioPlayer;
class VisualNode
{
public:
VisualNode(short *l, short *r, unsigned long n, unsigned long o)
: m_left(l), m_right(r), m_length(n), m_offset(o) { }
VisualNode(short *l, short *r, unsigned long n, std::chrono::milliseconds timecode)
: m_left(l), m_right(r), m_length(n), m_offset(timecode) { }

~VisualNode()
{
Expand All @@ -34,7 +36,7 @@ class VisualNode
short *m_left {nullptr};
short *m_right {nullptr};
long m_length;
long m_offset;
std::chrono::milliseconds m_offset;
};

class MTV_PUBLIC VideoVisual : public MythTV::Visual
Expand All @@ -53,13 +55,15 @@ class MTV_PUBLIC VideoVisual : public MythTV::Visual
QPaintDevice* device) = 0;
virtual QString Name(void) = 0;

void add(const void *b, unsigned long b_len, unsigned long w, int c, int p) override; // Visual
void add(const void *b, unsigned long b_len,
std::chrono::milliseconds timecode,
int c, int p) override; // Visual
void prepare() override; // Visual

protected:
VisualNode* GetNode(void);
void DeleteNodes(void);
int64_t SetLastUpdate(void);
std::chrono::milliseconds SetLastUpdate(void);

AudioPlayer *m_audio { nullptr };
bool m_needsPrepare { false };
Expand Down
6 changes: 3 additions & 3 deletions mythtv/libs/libmythtv/visualisations/videovisualmonoscope.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ void VideoVisualMonoScope::InitCommon(QRect Area)
m_hue = 0.0;
m_area = Area;
m_rate = 1.0;
m_lastTime = QDateTime::currentMSecsSinceEpoch();
m_lastTime = nowAsDuration<std::chrono::milliseconds>();
m_lineWidth = qMax(1.0F, m_area.height() * 0.004F);
}

Expand Down Expand Up @@ -71,8 +71,8 @@ bool VideoVisualMonoScope::UpdateVertices(float* Buffer)
void VideoVisualMonoScope::UpdateTime()
{
// try and give a similar rate of transitions for different playback speeds
auto timenow = QDateTime::currentMSecsSinceEpoch();
m_rate = (timenow - m_lastTime);
auto timenow = nowAsDuration<std::chrono::milliseconds>();
m_rate = (timenow - m_lastTime).count();
m_lastTime = timenow;
m_hue += m_rate / 7200.0F;
if (m_hue > 1.0F)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class VideoVisualMonoScope : public VideoVisual
bool UpdateVertices (float* Buffer);
void UpdateTime ();

int64_t m_lastTime { 0 };
std::chrono::milliseconds m_lastTime { 0ms };
float m_hue { 0.0 };
float m_rate { 1.0 };
float m_lineWidth { 1.0 };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ void VideoVisualSpectrum::Draw(const QRect Area, MythPainter* Painter, QPaintDev
fftw_execute(m_lplan);
fftw_execute(m_rplan);

double falloff = std::clamp(((static_cast<double>(SetLastUpdate())) / 40.0) * m_falloff, 0.0, 2048.0);
double falloff = std::clamp(((static_cast<double>(SetLastUpdate().count())) / 40.0) * m_falloff, 0.0, 2048.0);
for (int l = 0, r = m_scale.range(); l < m_scale.range(); l++, r++)
{
int index = m_scale[l];
Expand Down