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
 
 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< float >
 
using floatmsecs = std::chrono::duration< float, std::milli >
 
using floatusecs = std::chrono::duration< float, 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, float f)
 Multiply a duration by a float, returning a duration. More...
 
template<typename T >
static constexpr T chronodivide (T duration, float 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<float>

Definition at line 39 of file mythchrono.h.

◆ floatmsecs

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

Definition at line 40 of file mythchrono.h.

◆ floatusecs

using floatusecs = std::chrono::duration<float, 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)

◆ 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.

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.

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.

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.

Definition at line 160 of file mythchrono.h.

◆ nowAsDuration()

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

Get the currenttime as a duration.

Definition at line 183 of file mythchrono.h.

◆ chronomult()

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

Multiply a duration by a float, returning a duration.

Definition at line 199 of file mythchrono.h.

Referenced by PeriodicHouseKeeperTask::CalculateWindow().

◆ chronodivide()

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

Divide a duration by a float, returning a duration.

Definition at line 205 of file mythchrono.h.