MythTV  master
Namespaces | Typedefs | Functions
mythchrono.h File Reference
#include <cmath>
#include <sys/time.h>
#include <QMetaType>
#include <chrono>
Include dependency graph for mythchrono.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

 std::chrono
 
 mpeg
 
 mpeg::chrono
 
 mpeg::chrono_literals
 

Typedefs

using CHRONO_TYPE = std::chrono::seconds::rep
 
using std::chrono::days = duration< CHRONO_TYPE, ratio< 86400 > >
 
using std::chrono::weeks = duration< CHRONO_TYPE, ratio< 604800 > >
 
using std::chrono::months = duration< CHRONO_TYPE, ratio< 2629746 > >
 
using std::chrono::years = duration< CHRONO_TYPE, ratio< 31556952 > >
 
using floatsecs = std::chrono::duration< double >
 
using floatmsecs = std::chrono::duration< double, std::milli >
 
using floatusecs = std::chrono::duration< double, std::micro >
 
using mpeg::chrono::pts = std::chrono::duration< CHRONO_TYPE, std::ratio< 1, 90000 > >
 
using SystemClock = std::chrono::system_clock
 
using SystemTime = std::chrono::time_point< SystemClock >
 

Functions

 Q_DECLARE_METATYPE (std::chrono::seconds)
 
 Q_DECLARE_METATYPE (std::chrono::milliseconds)
 
 Q_DECLARE_METATYPE (std::chrono::microseconds)
 
constexpr mpeg::chrono::pts mpeg::chrono_literals::operator""_pts (unsigned long long v)
 
template<typename T >
std::enable_if_t< std::is_floating_point_v< T >, std::chrono::seconds > secondsFromFloat (T value)
 Helper function for convert a floating point number to a duration. More...
 
template<typename T >
std::enable_if_t< std::is_floating_point_v< T >, std::chrono::milliseconds > millisecondsFromFloat (T value)
 Helper function for convert a floating point number to a duration. More...
 
template<typename T >
std::enable_if_t< std::is_floating_point_v< T >, std::chrono::microseconds > microsecondsFromFloat (T value)
 Helper function for convert a floating point number to a duration. More...
 
static constexpr std::chrono::milliseconds millisecondsFromParts (int hours, int minutes=0, int seconds=0, int milliseconds=0)
 Build a duration from separate minutes, seconds, etc. More...
 
template<typename T >
constexpr T durationFromTimeval (timeval t)
 Convert a timeval to a duration. More...
 
template<typename T >
constexpr T durationFromTimevalDelta (timeval a, timeval b)
 Compute delta between timevals and convert to a duration. More...
 
template<typename T >
constexpr T durationFromTimespec (struct timespec time)
 Convert a timespec to a duration. More...
 
template<typename T >
nowAsDuration (bool adjustForTZ=false)
 Get the currenttime as a duration. More...
 
template<typename T >
static constexpr T chronomult (T duration, double f)
 Multiply a duration by a float, returning a duration. More...
 
template<typename T >
static constexpr T chronodivide (T duration, double f)
 Divide a duration by a float, returning a duration. More...
 

Typedef Documentation

◆ CHRONO_TYPE

using CHRONO_TYPE = std::chrono::seconds::rep

Definition at line 19 of file mythchrono.h.

◆ floatsecs

using floatsecs = std::chrono::duration<double>

Definition at line 39 of file mythchrono.h.

◆ floatmsecs

using floatmsecs = std::chrono::duration<double, std::milli>

Definition at line 40 of file mythchrono.h.

◆ floatusecs

using floatusecs = std::chrono::duration<double, std::micro>

Definition at line 41 of file mythchrono.h.

◆ SystemClock

using SystemClock = std::chrono::system_clock

Definition at line 66 of file mythchrono.h.

◆ SystemTime

using SystemTime = std::chrono::time_point<SystemClock>

Definition at line 67 of file mythchrono.h.

Function Documentation

◆ Q_DECLARE_METATYPE() [1/3]

Q_DECLARE_METATYPE ( std::chrono::seconds  )

◆ Q_DECLARE_METATYPE() [2/3]

Q_DECLARE_METATYPE ( std::chrono::milliseconds  )

◆ Q_DECLARE_METATYPE() [3/3]

Q_DECLARE_METATYPE ( std::chrono::microseconds  )

◆ secondsFromFloat()

template<typename T >
std::enable_if_t<std::is_floating_point_v<T>, std::chrono::seconds> secondsFromFloat ( value)

Helper function for convert a floating point number to a duration.

Parameters
valueA floating point number that represents a time in seconds.
Returns
The same number of seconds as a std::chrono::seconds.

Definition at line 80 of file mythchrono.h.

Referenced by MythPlayer::CalcMaxFFTime(), MythPlayer::CalcRWTime(), CalcTrackLength(), MythCCExtractorPlayer::OnGotNewFrame(), AvFormatDecoder::OpenFile(), HLSRingBuffer::SeekInternal(), MythDVDPlayer::StillFrameCheck(), and DecoderBase::SyncPositionMap().

◆ millisecondsFromFloat()

template<typename T >
std::enable_if_t<std::is_floating_point_v<T>, std::chrono::milliseconds> millisecondsFromFloat ( value)

◆ microsecondsFromFloat()

template<typename T >
std::enable_if_t<std::is_floating_point_v<T>, std::chrono::microseconds> microsecondsFromFloat ( value)

Helper function for convert a floating point number to a duration.

Parameters
valueA floating point number that represents a time in microseconds.
Returns
The same number of seconds as a std::chrono::microseconds.

Definition at line 102 of file mythchrono.h.

Referenced by MythPlayerAVSync::AVSync(), AvFormatDecoder::GetFrame(), MythDisplay::GetRefreshInterval(), MythPlayer::SetFrameInterval(), and MythPlayer::UpdateFFRewSkip().

◆ millisecondsFromParts()

static constexpr std::chrono::milliseconds millisecondsFromParts ( int  hours,
int  minutes = 0,
int  seconds = 0,
int  milliseconds = 0 
)
staticconstexpr

Build a duration from separate minutes, seconds, etc.

Definition at line 109 of file mythchrono.h.

Referenced by LyricsData::setLyrics().

◆ durationFromTimeval()

template<typename T >
constexpr T durationFromTimeval ( timeval  t)
constexpr

Convert a timeval to a duration.

Always specify the desired precision when calling this function. I.E. Always call in the form: durationFromTimeval<std::chrono::milliseconds>(t);

Timevals can support a precision as small as microseconds.

Definition at line 126 of file mythchrono.h.

◆ durationFromTimevalDelta()

template<typename T >
constexpr T durationFromTimevalDelta ( timeval  a,
timeval  b 
)
constexpr

Compute delta between timevals and convert to a duration.

Always specify the desired precision when calling this function. I.E. Always call in the form: durationFromTimevalDelta<std::chrono::milliseconds>(t);

Timevals can support a precision as small as microseconds.

Definition at line 143 of file mythchrono.h.

◆ durationFromTimespec()

template<typename T >
constexpr T durationFromTimespec ( struct timespec  time)
constexpr

Convert a timespec to a duration.

Always specify the desired precision when calling this function. I.E. Always call in the form: durationFromTimespec<std::chrono::milliseconds>(t);

Timevals can support a precision as small as nanoseconds.

Definition at line 160 of file mythchrono.h.

◆ nowAsDuration()

template<typename T >
T nowAsDuration ( bool  adjustForTZ = false)

Get the currenttime as a duration.

Always specify the desired precision when calling this function. I.E. Always call in the form: nowAsDuration<std::chrono::milliseconds>(t);

This function is based upon the gettimeoday function, so can return precisions as small as microseconds.

Definition at line 183 of file mythchrono.h.

◆ chronomult()

template<typename T >
static constexpr T chronomult ( duration,
double  f 
)
staticconstexpr

Multiply a duration by a float, returning a duration.

Definition at line 199 of file mythchrono.h.

Referenced by PeriodicHouseKeeperTask::CalculateWindow(), and MythPlayer::UpdateFFRewSkip().

◆ chronodivide()

template<typename T >
static constexpr T chronodivide ( duration,
double  f 
)
staticconstexpr

Divide a duration by a float, returning a duration.

Definition at line 205 of file mythchrono.h.