AudioManager  7.5.11
Native Application Runtime Environment
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
am::CAmSocketHandler Class Reference

The am::CAmSocketHandler implements a mainloop for the AudioManager. More...

#include <CAmSocketHandler.h>

Classes

class  TAmShPollCheck
 
class  TAmShPollFired
 

Public Member Functions

 CAmSocketHandler ()
 
 ~CAmSocketHandler ()
 
am_Error_e addFDPoll (const int fd, const short event, IAmShPollPrepare *prepare, IAmShPollFired *fired, IAmShPollCheck *check, IAmShPollDispatch *dispatch, void *userData, sh_pollHandle_t &handle)
 Adds a filedescriptor to the polling loop. More...
 
am_Error_e removeFDPoll (const sh_pollHandle_t handle)
 removes a filedescriptor from the poll loop More...
 
am_Error_e updateEventFlags (const sh_pollHandle_t handle, const short events)
 updates the eventFlags of a poll More...
 
am_Error_e addTimer (const timespec timeouts, IAmShTimerCallBack *callback, sh_timerHandle_t &handle, void *userData)
 adds a timer to the list of timers. More...
 
am_Error_e removeTimer (const sh_timerHandle_t handle)
 removes a timer from the list of timers More...
 
am_Error_e restartTimer (const sh_timerHandle_t handle)
 restarts a timer with the original value More...
 
am_Error_e updateTimer (const sh_timerHandle_t handle, const timespec timeouts)
 restarts a timer and updates with a new interva More...
 
am_Error_e stopTimer (const sh_timerHandle_t handle)
 stops a timer More...
 
void start_listenting ()
 start the block listening for filedescriptors. More...
 
void stop_listening ()
 exits the loop More...
 
void exit_mainloop ()
 
void receiverCallback (const pollfd pollfd, const sh_pollHandle_t handle, void *userData)
 
bool checkerCallback (const sh_pollHandle_t handle, void *userData)
 

Public Attributes

TAmShPollFired< CAmSocketHandlerreceiverCallbackT
 
TAmShPollCheck< CAmSocketHandlercheckerCallbackT
 

Detailed Description

The am::CAmSocketHandler implements a mainloop for the AudioManager.

Plugins and different parts of the AudioManager add their filedescriptors to the handler to get called on communication of the filedescriptors.
More information can be found here : Mainloop concept

Definition at line 94 of file CAmSocketHandler.h.

Constructor & Destructor Documentation

am::CAmSocketHandler::CAmSocketHandler ( )

Definition at line 39 of file CAmSocketHandler.cpp.

am::CAmSocketHandler::~CAmSocketHandler ( )

Definition at line 64 of file CAmSocketHandler.cpp.

Member Function Documentation

am_Error_e am::CAmSocketHandler::addFDPoll ( const int  fd,
const short  event,
IAmShPollPrepare prepare,
IAmShPollFired fired,
IAmShPollCheck check,
IAmShPollDispatch dispatch,
void *  userData,
sh_pollHandle_t handle 
)

Adds a filedescriptor to the polling loop.

Parameters
fdthe filedescriptor
eventthe event flags
preparea callback that is called before the loop is entered
fireda callback that is called when the filedescriptor needs to be read
checka callback that is called to check if further actions are neccessary
dispatcha callback that is called to dispatch the received data
userDataa pointer to userdata that is always passed around
handlethe handle of this poll
Returns
E_OK if the descriptor was added, E_NON_EXISTENT if the fd is not valid

Definition at line 195 of file CAmSocketHandler.cpp.

am_Error_e am::CAmSocketHandler::addTimer ( const timespec  timeouts,
IAmShTimerCallBack callback,
sh_timerHandle_t handle,
void *  userData 
)

adds a timer to the list of timers.

The callback will be fired when the timer is up. This is not a high precise timer, it is very coarse. It is meant to be used for timeouts when waiting for an answer via a filedescriptor. One time timer. If you need again a timer, you need to add a new timer in the callback of the old one.

Parameters
timeoutstimeouts time until the callback is fired
callbackcallback the callback
handlehandle the handle that is created for the timer is returned. Can be used to remove the timer
userDatapointer always passed with the call
Returns
E_OK in case of success

Definition at line 272 of file CAmSocketHandler.cpp.

bool am::CAmSocketHandler::checkerCallback ( const sh_pollHandle_t  handle,
void *  userData 
)
inline

Definition at line 151 of file CAmSocketHandler.h.

void am::CAmSocketHandler::exit_mainloop ( )

Definition at line 558 of file CAmSocketHandler.cpp.

void am::CAmSocketHandler::receiverCallback ( const pollfd  pollfd,
const sh_pollHandle_t  handle,
void *  userData 
)
inline

Definition at line 145 of file CAmSocketHandler.h.

am_Error_e am::CAmSocketHandler::removeFDPoll ( const sh_pollHandle_t  handle)

removes a filedescriptor from the poll loop

Parameters
handle
Returns

Definition at line 244 of file CAmSocketHandler.cpp.

am_Error_e am::CAmSocketHandler::removeTimer ( const sh_timerHandle_t  handle)

removes a timer from the list of timers

Parameters
handlethe handle to the timer
Returns
E_OK in case of success, E_UNKNOWN if timer was not found.

Definition at line 321 of file CAmSocketHandler.cpp.

am_Error_e am::CAmSocketHandler::restartTimer ( const sh_timerHandle_t  handle)

restarts a timer with the original value

Parameters
handle
Returns
E_OK on success, E_NON_EXISTENT if the handle was not found

<the original timer value

Definition at line 399 of file CAmSocketHandler.cpp.

void am::CAmSocketHandler::start_listenting ( )

start the block listening for filedescriptors.

This is the mainloop.

Definition at line 74 of file CAmSocketHandler.cpp.

void am::CAmSocketHandler::stop_listening ( )

exits the loop

Definition at line 168 of file CAmSocketHandler.cpp.

am_Error_e am::CAmSocketHandler::stopTimer ( const sh_timerHandle_t  handle)

stops a timer

Parameters
handle
Returns
E_OK on success, E_NON_EXISTENT if the handle was not found

Definition at line 451 of file CAmSocketHandler.cpp.

am_Error_e am::CAmSocketHandler::updateEventFlags ( const sh_pollHandle_t  handle,
const short  events 
)

updates the eventFlags of a poll

Parameters
handle
events
Returns
E_OK on succsess, E_NON_EXISTENT if fd was not found

Definition at line 472 of file CAmSocketHandler.cpp.

am_Error_e am::CAmSocketHandler::updateTimer ( const sh_timerHandle_t  handle,
const timespec  timeouts 
)

restarts a timer and updates with a new interva

Parameters
handlehandle to the timer
timeoutsnew timout time
Returns
E_OK on success, E_NON_EXISTENT if the handle was not found

Definition at line 347 of file CAmSocketHandler.cpp.

Member Data Documentation

TAmShPollCheck<CAmSocketHandler> am::CAmSocketHandler::checkerCallbackT

Definition at line 159 of file CAmSocketHandler.h.

TAmShPollFired<CAmSocketHandler> am::CAmSocketHandler::receiverCallbackT

Definition at line 156 of file CAmSocketHandler.h.


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