MythTV  master
Public Types | Public Member Functions | Private Attributes | List of all members
MythTimer Class Reference

A QElapsedTimer based timer to replace use of QTime as a timer. More...

#include <mythtimer.h>

Public Types

enum  StartState { kStartRunning, kStartInactive }
 

Public Member Functions

 MythTimer (StartState state=kStartInactive)
 Creates a timer. More...
 
void start (void)
 starts measuring elapsed time. More...
 
std::chrono::milliseconds restart (void)
 Returns milliseconds elapsed since last start() or restart() and resets the count. More...
 
void stop (void)
 Stops timer, next call to isRunning() will return false and any calls to elapsed() or restart() will return 0 until after timer is restarted by a call to start() or restart(). More...
 
void addMSecs (std::chrono::milliseconds ms)
 Adds an offset to the last call to start() or restart(). More...
 
std::chrono::milliseconds elapsed (void)
 Returns milliseconds elapsed since last start() or restart() More...
 
std::chrono::nanoseconds nsecsElapsed (void) const
 Returns nanoseconds elapsed since last start() or restart() More...
 
bool isRunning (void) const
 Returns true if start() or restart() has been called at least once since construction and since any call to stop(). More...
 

Private Attributes

QElapsedTimer m_timer
 
std::chrono::milliseconds m_offset {0ms}
 

Detailed Description

A QElapsedTimer based timer to replace use of QTime as a timer.

This class is not thread-safe.

Definition at line 13 of file mythtimer.h.

Member Enumeration Documentation

◆ StartState

Enumerator
kStartRunning 
kStartInactive 

Definition at line 16 of file mythtimer.h.

Constructor & Destructor Documentation

◆ MythTimer()

MythTimer::MythTimer ( StartState  state = kStartInactive)
explicit

Creates a timer.

If a start state of kStartRunning is passed in the timer is started immediately as if start() had been called.

Definition at line 38 of file mythtimer.cpp.

Member Function Documentation

◆ start()

void MythTimer::start ( void  )

starts measuring elapsed time.

Definition at line 47 of file mythtimer.cpp.

Referenced by DTVRecorder::BufferedWrite(), GUIStartup::Close(), DVBStreamHandler::CycleFiltersByPriority(), MythContextPrivate::DefaultUPnP(), ThreadedFileWriter::DiskLoop(), TV::DoSeek(), elapsed(), FreeSpaceUpdater::FreeSpaceUpdater(), AnalogSignalMonitor::handleHDPVR(), MythTimer(), MythUITextEdit::MythUITextEdit(), AudioOutputOSS::OpenDevice(), MythFileBuffer::OpenFile(), MythPlayer::OpenFile(), PlayerContext::PlayerContext(), DeviceReadBuffer::Poll(), SatIP::probeDevices(), VBox::probeDevices(), DarwinFirewireDevice::ProcessNoDataMessage(), MPEGStreamData::ProcessPAT(), DTVRecorder::ProcessTSPacket(), RemoteFile::Read(), BufferedSocketDeviceRequest::ReadBlock(), ZMClient::readData(), MythMediaBuffer::ReadDirect(), BufferedSocketDevice::ReadLine(), BufferedSocketDeviceRequest::ReadLine(), MythSocket::ReadStringListReal(), MythCommFlagPlayer::RebuildSeekTable(), DeviceReadBuffer::ReportStats(), restart(), MpegRecorder::run(), EITScanner::run(), ExternalStreamHandler::run(), MythCCExtractorPlayer::run(), MythMediaBuffer::run(), FirewireSignalMonitor::RunTableMonitor(), RecorderBase::SavePositionMap(), DecoderBase::SavePositionMapDelta(), DeviceReadBuffer::Setup(), LinuxFirewireDevice::SignalReset(), V4L2encSignalMonitor::StableResolution(), HTTPLiveStream::StartStream(), HTTPLiveStream::StopStream(), TV::TV(), TV::UpdateOSDSignal(), FirewireSignalMonitor::UpdateValues(), MythContextPrivate::UPnPautoconf(), MythMediaBuffer::WaitForAvail(), TVRec::WaitForEventThreadSleep(), MythMediaBuffer::WaitForReadsAllowed(), DeviceReadBuffer::WaitForUsed(), and MythSocket::WriteStringListReal().

◆ restart()

std::chrono::milliseconds MythTimer::restart ( void  )

◆ stop()

void MythTimer::stop ( void  )

Stops timer, next call to isRunning() will return false and any calls to elapsed() or restart() will return 0 until after timer is restarted by a call to start() or restart().

Definition at line 78 of file mythtimer.cpp.

Referenced by GUIStartup::Close(), DTVRecorder::FindH2645Keyframes(), AnalogSignalMonitor::handleHDPVR(), MythTimer(), ExternalStreamHandler::run(), and V4L2encSignalMonitor::StableResolution().

◆ addMSecs()

void MythTimer::addMSecs ( std::chrono::milliseconds  ms)

Adds an offset to the last call to start() or restart().

This offset is removed if start() or restart() is called again. The offset may be positive or negative. This may be called multiple times to accrete various offsets.

Definition at line 146 of file mythtimer.cpp.

Referenced by MythDVDPlayer::ChangeSpeed(), GUIStartup::Close(), PlayerContext::PlayerContext(), and DTVRecorder::ProcessTSPacket().

◆ elapsed()

std::chrono::milliseconds MythTimer::elapsed ( void  )

Returns milliseconds elapsed since last start() or restart()

Note
If timer had not been started before this is called, this returns zero.
If addMSecs() has been called and the total offset applied is negative then this can return a negative number.

Definition at line 91 of file mythtimer.cpp.

Referenced by TV::ActiveHandleAction(), HEVCParser::addBytes(), MythDVDPlayer::ChangeSpeed(), PortChecker::checkPort(), GUIStartup::Close(), DVBStreamHandler::CycleFiltersByPriority(), MythContextPrivate::DefaultUPnP(), ThreadedFileWriter::DiskLoop(), TV::DoSeek(), DTVRecorder::FindH2645Keyframes(), RemoteEncoder::GetFramesWritten(), MythDVDPlayer::GetMillisecondsPlayed(), RemoteFile::GetRealFileSize(), AnalogSignalMonitor::handleHDPVR(), FirewireSignalMonitor::HandlePAT(), AudioOutputOSS::OpenDevice(), MythFileBuffer::OpenFile(), MythPlayer::OpenFile(), DeviceReadBuffer::Poll(), SatIP::probeDevices(), VBox::probeDevices(), DarwinFirewireDevice::ProcessNoDataMessage(), MPEGStreamData::ProcessPAT(), DTVRecorder::ProcessTSPacket(), ExternalStreamHandler::ProcessVer1(), ExternalStreamHandler::ProcessVer2(), progress_string(), MythUITextEdit::Pulse(), RemoteFile::Read(), BufferedSocketDeviceRequest::ReadBlock(), ZMClient::readData(), MythMediaBuffer::ReadDirect(), BufferedSocketDevice::ReadLine(), BufferedSocketDeviceRequest::ReadLine(), MythMediaBuffer::ReadPriv(), MythSocket::ReadStringListReal(), MythCommFlagPlayer::RebuildSeekTable(), DeviceReadBuffer::ReportStats(), MpegRecorder::run(), EITScanner::run(), LinuxFirewireDevice::run(), ExternalStreamHandler::run(), MythCCExtractorPlayer::run(), MythMediaBuffer::run(), FreeSpaceUpdater::run(), RecorderBase::SavePositionMap(), DecoderBase::SavePositionMapDelta(), AvFormatDecoder::SeekReset(), V4L2encSignalMonitor::StableResolution(), HTTPLiveStream::StartStream(), MythDVDPlayer::StillFrameCheck(), HTTPLiveStream::StopStream(), StreamHandler::UpdateFiltersFromStreamData(), TV::UpdateOSDSignal(), GUIStartup::updateProgress(), FirewireSignalMonitor::UpdateValues(), MythContextPrivate::UPnPautoconf(), MythMediaBuffer::WaitForAvail(), TVRec::WaitForEventThreadSleep(), MythMediaBuffer::WaitForReadsAllowed(), DeviceReadBuffer::WaitForUsed(), and MythSocket::WriteStringListReal().

◆ nsecsElapsed()

std::chrono::nanoseconds MythTimer::nsecsElapsed ( void  ) const

Returns nanoseconds elapsed since last start() or restart()

Note
If timer had not been started before this is called, this returns zero.
If addMSecs() has been called and the total offset applied is negative then this can return a negative number.

Definition at line 119 of file mythtimer.cpp.

◆ isRunning()

bool MythTimer::isRunning ( void  ) const

Member Data Documentation

◆ m_timer

QElapsedTimer MythTimer::m_timer
private

Definition at line 34 of file mythtimer.h.

Referenced by elapsed(), isRunning(), nsecsElapsed(), restart(), start(), and stop().

◆ m_offset

std::chrono::milliseconds MythTimer::m_offset {0ms}
private

Definition at line 35 of file mythtimer.h.

Referenced by addMSecs(), elapsed(), nsecsElapsed(), restart(), and start().


The documentation for this class was generated from the following files: