MythTV  0.27pre
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
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.
void start (void)
 starts measuring elapsed time.
int restart (void)
 Returns milliseconds elapsed since last start() or restart() and resets the count.
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().
void addMSecs (int ms)
 Adds an offset to the last call to start() or restart().
int elapsed (void) const
 Returns milliseconds elapsed since last start() or restart()
bool isRunning (void) const
 Returns true if start() or restart() has been called at least once since construction and since any call to stop().

Private Attributes

QElapsedTimer m_timer
int m_offset

Detailed Description

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

This class is not thread-safe.

Definition at line 12 of file mythtimer.h.

Member Enumeration Documentation

Enumerator:
kStartRunning 
kStartInactive 

Definition at line 15 of file mythtimer.h.

Constructor & Destructor Documentation

MythTimer::MythTimer ( StartState  state = kStartInactive)

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

Member Function Documentation

void MythTimer::start ( void  )

starts measuring elapsed time.

Definition at line 45 of file mythtimer.cpp.

Referenced by TestMythTimer::AddMSecsIsResetOnStart(), TestMythTimer::AddMSecsWorks(), DTVRecorder::BufferedWrite(), MThread::Cleanup(), DVBStreamHandler::CycleFiltersByPriority(), MythContextPrivate::DefaultUPnP(), ThreadedFileWriter::DiskLoop(), TV::DoSeek(), elapsed(), AnalogSignalMonitor::handleHDPVR(), MythPlayer::IsPlaying(), MythTimer(), MythUITextEdit::MythUITextEdit(), AudioOutputOSS::OpenDevice(), FileRingBuffer::OpenFile(), MythPlayer::OpenFile(), PlayerContext::PlayerContext(), DeviceReadBuffer::Poll(), DarwinFirewireDevice::ProcessNoDataMessage(), MPEGStreamData::ProcessPAT(), RemoteFile::Read(), ZMClient::readData(), RingBuffer::ReadDirect(), BufferedSocketDevice::ReadLine(), MythSocket::ReadReal(), MythSocket::ReadStringListReal(), MythCommFlagPlayer::RebuildSeekTable(), DeviceReadBuffer::ReportStats(), restart(), MpegRecorder::run(), EITScanner::run(), MPoolThread::run(), SignalMonitor::run(), MythCCExtractorPlayer::run(), RingBuffer::run(), FreeSpaceUpdater::run(), FirewireSignalMonitor::RunTableMonitor(), RecorderBase::SavePositionMap(), DecoderBase::SavePositionMapDelta(), DeviceReadBuffer::Setup(), LinuxFirewireDevice::SignalReset(), PlayerContext::StartPlaying(), TV::StartRecorder(), MThreadPool::startReserved(), TestMythTimer::StartsOnStart(), HTTPLiveStream::StartStream(), HTTPLiveStream::StopStream(), TestMythTimer::TimeElapsesAfterStart(), TestMythTimer::TimeElapsesContinually(), TestMythTimer::TimeResetsOnRestart(), TV::TV(), TV::UpdateOSDSignal(), FirewireSignalMonitor::UpdateValues(), MythContextPrivate::UPnPautoconf(), RingBuffer::WaitForAvail(), TVRec::WaitForEventThreadSleep(), RingBuffer::WaitForPause(), RecorderBase::WaitForPause(), RingBuffer::WaitForReadsAllowed(), DeviceReadBuffer::WaitForUsed(), and MythSocket::WriteStringListReal().

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

Referenced by TestMythTimer::AddMSecsIsResetOnRestart(), DTVRecorder::BufferedWrite(), GLSingleView::EffectKenBurns(), MythUITextEdit::keyPressEvent(), MythCommFlagPlayer::RebuildSeekTable(), MythDVDPlayer::ResetStillFrameTimer(), MythCCExtractorPlayer::run(), MythDVDPlayer::SetStillFrameTimeout(), GLSingleView::SlideTimeout(), TestMythTimer::TimeElapsesAfterRestart(), TestMythTimer::TimeResetsOnRestart(), and MythSocket::WriteStringListReal().

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

Referenced by AnalogSignalMonitor::handleHDPVR(), and MythTimer().

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

Referenced by TestMythTimer::AddMSecsIsResetOnRestart(), TestMythTimer::AddMSecsIsResetOnStart(), TestMythTimer::AddMSecsWorks(), and PlayerContext::PlayerContext().

int MythTimer::elapsed ( void  ) const

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

Referenced by TV::ActiveHandleAction(), TestMythTimer::AddMSecsIsResetOnRestart(), TestMythTimer::AddMSecsIsResetOnStart(), TestMythTimer::AddMSecsWorks(), MThread::Cleanup(), DVBStreamHandler::CycleFiltersByPriority(), MythContextPrivate::DefaultUPnP(), ThreadedFileWriter::DiskLoop(), TV::DoSeek(), GLSingleView::EffectBend(), GLSingleView::EffectBlend(), GLSingleView::EffectCube(), GLSingleView::EffectFade(), GLSingleView::EffectFlutter(), GLSingleView::EffectInOut(), GLSingleView::EffectKenBurns(), GLSingleView::EffectRotate(), GLSingleView::EffectSlide(), GLSingleView::EffectZoomBlend(), MythDVDPlayer::GetSecondsPlayed(), AnalogSignalMonitor::handleHDPVR(), FirewireSignalMonitor::HandlePAT(), MythPlayer::IsPlaying(), AudioOutputOSS::OpenDevice(), FileRingBuffer::OpenFile(), MythPlayer::OpenFile(), DeviceReadBuffer::Poll(), DarwinFirewireDevice::ProcessNoDataMessage(), MPEGStreamData::ProcessPAT(), progress_string(), MythUITextEdit::Pulse(), RemoteFile::Read(), ZMClient::readData(), RingBuffer::ReadDirect(), BufferedSocketDevice::ReadLine(), MythSocket::ReadReal(), MythSocket::ReadStringListReal(), MythCommFlagPlayer::RebuildSeekTable(), DeviceReadBuffer::ReportStats(), MpegRecorder::run(), EITScanner::run(), LinuxFirewireDevice::run(), MythCCExtractorPlayer::run(), RingBuffer::run(), FreeSpaceUpdater::run(), RecorderBase::SavePositionMap(), DecoderBase::SavePositionMapDelta(), PlayerContext::StartPlaying(), TV::StartRecorder(), MThreadPool::startReserved(), HTTPLiveStream::StartStream(), MythDVDPlayer::StillFrameCheck(), HTTPLiveStream::StopStream(), TestMythTimer::TimeDoesNotElapseImmediatelyAfterConstructionByDefault(), TestMythTimer::TimeDoesNotElapsesImmediatelyAfterContructionIfIntended(), TestMythTimer::TimeElapsesAfterRestart(), TestMythTimer::TimeElapsesAfterStart(), TestMythTimer::TimeElapsesContinually(), TestMythTimer::TimeResetsOnRestart(), StreamHandler::UpdateFiltersFromStreamData(), TV::UpdateOSDSignal(), AnalogSignalMonitor::UpdateValues(), ASISignalMonitor::UpdateValues(), HDHRSignalMonitor::UpdateValues(), IPTVSignalMonitor::UpdateValues(), CetonSignalMonitor::UpdateValues(), DVBSignalMonitor::UpdateValues(), FirewireSignalMonitor::UpdateValues(), MythContextPrivate::UPnPautoconf(), RingBuffer::WaitForAvail(), TVRec::WaitForEventThreadSleep(), RingBuffer::WaitForPause(), RecorderBase::WaitForPause(), RingBuffer::WaitForReadsAllowed(), DeviceReadBuffer::WaitForUsed(), and MythSocket::WriteStringListReal().

bool MythTimer::isRunning ( void  ) const

Returns true if start() or restart() has been called at least once since construction and since any call to stop().

Definition at line 111 of file mythtimer.cpp.

Referenced by AnalogSignalMonitor::handleHDPVR(), RecorderBase::SavePositionMap(), TestMythTimer::StartsNotRunning(), TestMythTimer::StartsOnStart(), StreamHandler::UpdateFiltersFromStreamData(), and TV::UpdateOSDSignal().

Member Data Documentation

QElapsedTimer MythTimer::m_timer
private

Definition at line 32 of file mythtimer.h.

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

int MythTimer::m_offset
private

Definition at line 33 of file mythtimer.h.

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


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