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>

Collaboration diagram for MythTimer:
Collaboration graph
[legend]

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...
 
int 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 (int ms)
 Adds an offset to the last call to start() or restart(). More...
 
int elapsed (void)
 Returns milliseconds elapsed since last start() or restart() More...
 
int64_t 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
 
int m_offset {0}
 

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(), elapsed(), AnalogSignalMonitor::handleHDPVR(), MythTimer(), MythUITextEdit::MythUITextEdit(), AudioOutputOSS::OpenDevice(), FileRingBuffer::OpenFile(), MythPlayer::OpenFile(), PlayerContext::PlayerContext(), DeviceReadBuffer::Poll(), VBox::probeDevices(), DarwinFirewireDevice::ProcessNoDataMessage(), MPEGStreamData::ProcessPAT(), DTVRecorder::ProcessTSPacket(), RemoteFile::Read(), BufferedSocketDeviceRequest::ReadBlock(), ZMClient::readData(), RingBuffer::ReadDirect(), BufferedSocketDevice::ReadLine(), BufferedSocketDeviceRequest::ReadLine(), MythSocket::ReadStringListReal(), MythCommFlagPlayer::RebuildSeekTable(), DeviceReadBuffer::ReportStats(), restart(), MpegRecorder::run(), ExternalStreamHandler::run(), MythCCExtractorPlayer::run(), RingBuffer::run(), FirewireSignalMonitor::RunTableMonitor(), RecorderBase::SavePositionMap(), DecoderBase::SavePositionMapDelta(), DeviceReadBuffer::Setup(), LinuxFirewireDevice::SignalReset(), V4L2encSignalMonitor::StableResolution(), HTTPLiveStream::StartStream(), HTTPLiveStream::StopStream(), TV::UpdateOSDSignal(), FirewireSignalMonitor::UpdateValues(), MythContextPrivate::UPnPautoconf(), TVRec::WaitForEventThreadSleep(), DeviceReadBuffer::WaitForUsed(), and MythSocket::WriteStringListReal().

◆ restart()

int MythTimer::restart ( void  )

Returns milliseconds elapsed since last start() or restart() and resets the count.

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 62 of file mythtimer.cpp.

Referenced by DTVRecorder::BufferedWrite(), MythDVDPlayer::ChangeSpeed(), RecorderBase::CheckForRingBufferSwitch(), MythUSWCCopy::copy(), ThreadedFileWriter::DiskLoop(), RemoteFile::GetRealFileSize(), MythUITextEdit::keyPressEvent(), MythCommFlagPlayer::RebuildSeekTable(), MythDVDPlayer::ResetStillFrameTimer(), ExternalStreamHandler::run(), MythCCExtractorPlayer::run(), MythDVDPlayer::SetStillFrameTimeout(), and MythSocket::WriteStringListReal().

◆ 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 77 of file mythtimer.cpp.

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

◆ addMSecs()

void MythTimer::addMSecs ( int  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 145 of file mythtimer.cpp.

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

◆ elapsed()

int 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 90 of file mythtimer.cpp.

Referenced by TV::ActiveHandleAction(), MythDVDPlayer::ChangeSpeed(), PortChecker::checkPort(), GUIStartup::Close(), DVBStreamHandler::CycleFiltersByPriority(), MythContextPrivate::DefaultUPnP(), ThreadedFileWriter::DiskLoop(), RemoteFile::GetRealFileSize(), MythDVDPlayer::GetSecondsPlayed(), AnalogSignalMonitor::handleHDPVR(), FirewireSignalMonitor::HandlePAT(), AudioOutputOSS::OpenDevice(), FileRingBuffer::OpenFile(), MythPlayer::OpenFile(), DeviceReadBuffer::Poll(), VBox::probeDevices(), DarwinFirewireDevice::ProcessNoDataMessage(), MPEGStreamData::ProcessPAT(), DTVRecorder::ProcessTSPacket(), ExternalStreamHandler::ProcessVer1(), ExternalStreamHandler::ProcessVer2(), progress_string(), MythUITextEdit::Pulse(), RemoteFile::Read(), BufferedSocketDeviceRequest::ReadBlock(), ZMClient::readData(), RingBuffer::ReadDirect(), BufferedSocketDevice::ReadLine(), BufferedSocketDeviceRequest::ReadLine(), MythSocket::ReadStringListReal(), MythCommFlagPlayer::RebuildSeekTable(), DeviceReadBuffer::ReportStats(), MpegRecorder::run(), LinuxFirewireDevice::run(), ExternalStreamHandler::run(), MythCCExtractorPlayer::run(), RingBuffer::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(), TVRec::WaitForEventThreadSleep(), DeviceReadBuffer::WaitForUsed(), and MythSocket::WriteStringListReal().

◆ nsecsElapsed()

int64_t 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 118 of file mythtimer.cpp.

Referenced by MythUSWCCopy::copy().

◆ 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

int MythTimer::m_offset {0}
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: