sipxmedialib  Version 3.3
Public Types | Protected Member Functions | Protected Attributes | List of all members
MpMMTimer Class Referenceabstract

High-precision periodic timer (MultiMedia timer) base class. More...

#include <MpMMTimer.h>

Inheritance diagram for MpMMTimer:
Inheritance graph
[legend]

Public Types

enum  MMTimerType { Linear = 0, Notification = 1 }
 

Public Member Functions

Manipulators
virtual OsStatus setNotification (OsNotification *notification)
 Set notification for the OsNotification timer type. More...
 
virtual OsStatus run (unsigned usecPeriodic)=0
 Start periodical firing. More...
 
virtual OsStatus stop ()=0
 Stop periodical firing. More...
 
virtual OsStatus waitForNextTick ()
 
Accessors
virtual OsStatus getResolution (unsigned &resolution)
 Get resolution of timer in microseconds. More...
 
virtual OsStatus getPeriodRange (unsigned *pMinUSecs, unsigned *pMaxUSecs=NULL)
 Get the range of timer periods that can be generated. More...
 
MMTimerType getTimerType () const
 Get the type of timer fire. More...
 

Protected Member Functions

 MpMMTimer (MMTimerType type)
 protected constructor, as this is an abstract class. More...
 

Protected Attributes

MMTimerType mTimerType
 

Creators

static MpMMTimercreate (MMTimerType type, const UtlString &name="")
 Factory method to create timer class instance of the given type. More...
 
virtual ~MpMMTimer ()
 Destructor. More...
 

Detailed Description

High-precision periodic timer (MultiMedia timer) base class.

This class is not supposed to be a generic purpose timer. You MUST read documentation for specific implementation of the timer and clearly understand what you're doing before using this. Media timers are very sensitive to incorrect usage and may cause deadlocks and crashes easily when used incorrectly. Main purpose of these timers is to provide ticks for MpMediaTask when there are no enabled sound card.

Use create() static method to get an instantiate of a timer.

Member Enumeration Documentation

Enumerator
Linear 

For use with waitForNextTick()

Notification 

For use with setNotification()

Constructor & Destructor Documentation

~MpMMTimer ( )
virtual

Destructor.

MpMMTimer ( MMTimerType  type)
inlineprotected

protected constructor, as this is an abstract class.

Member Function Documentation

MpMMTimer * create ( MMTimerType  type,
const UtlString &  name = "" 
)
static

Factory method to create timer class instance of the given type.

Parameters
[in]type= Do we want linear timer or notifications timer?
[in]name- type of a timer to create. Empty string means default timer for this platform. To date we support "Windows Multimedia" timers on Windows and "Posix" timers on Linux.
OsStatus setNotification ( OsNotification *  notification)
virtual

Set notification for the OsNotification timer type.

Signals will be sent to this notification when the timer ticks. Pointer to this timer instance will be set in eventData member.

Parameters
[in]notification- object to notify when timer fires/ticks.
Return values
OS_SUCCESSReturned when notification is set.
OS_INVALID_STATEReturned when calling this function for non-Notification timer type.
OS_FAILEDReturned when mandatory initialization failed (maybe in the constructor) and later calls will fail for this instance also.

Reimplemented in MpMMTimerPosix, and MpMMTimerWnt.

virtual OsStatus run ( unsigned  usecPeriodic)
pure virtual

Start periodical firing.

Start periodical firing with given period and fire type.

Parameters
[in]usecPeriodictimer period in microseconds.
Return values
OS_SUCCESSReturns when timer has been created and ran.
OS_INVALID_ARGUMENTReturns when either value of uAlgorithm doesn't support in current realization or running OS couldn't create timer with specified usecPeriodic, but with another value of it, it could.
OS_INVALID_STATEReturns when timer has already been started or if the timer type is not supported.
OS_LIMIT_REACHEDReturns when timer couldn't run due the resource limitation.
OS_FAILEDReturns when mandatories initializations failed (maybe in constructor) and later calls will also fail for this instance.

Implemented in MpMMTimerPosix, and MpMMTimerWnt.

virtual OsStatus stop ( )
pure virtual

Stop periodical firing.

Stop periodical timer.

Return values
OS_SUCCESSReturns when timer has been stopped.
OS_FAILEDReturns when mandatory initialization failed (maybe in constructor) and later calls for this instance will fail.
OS_INVALID_STATEReturns when timer has not been started.

Implemented in MpMMTimerPosix, and MpMMTimerWnt.

OsStatus waitForNextTick ( )
virtual

Block this thread until the next tick occurs

Return values
OS_SUCCESSReturns when next tick period occurs.
OS_INVALID_STATEReturns when calling this function for non-Linear timer type.
OS_FAILEDReturns when mandatory initialization failed (maybe in constructor) and later calls for this instance will fail too.

Reimplemented in MpMMTimerPosix, and MpMMTimerWnt.

OsStatus getResolution ( unsigned &  resolution)
virtual

Get resolution of timer in microseconds.

Parameters
[out]resolution- set to the finest resolution timer we can generate.
Return values
OS_SUCCESS- the resolution was able to be retrieved.
OS_FAILED- the resolution wasn't able to be retrieved.

Reimplemented in MpMMTimerPosix, and MpMMTimerWnt.

OsStatus getPeriodRange ( unsigned *  pMinUSecs,
unsigned *  pMaxUSecs = NULL 
)
virtual

Get the range of timer periods that can be generated.

Parameters
[out]pMinUSecs- set to the smallest period we can generate.
[out]pMaxUSecs- set to the largest period we can generate.
Return values
OS_SUCCESS- the min and max periods were able to be retrieved.
OS_FAILED- the min and max periods weren't able to be retrieved.

Reimplemented in MpMMTimerPosix, and MpMMTimerWnt.

MpMMTimer::MMTimerType getTimerType ( ) const
inline

Get the type of timer fire.

Member Data Documentation

MMTimerType mTimerType
protected