AudioManager  7.6.6
Native Application Runtime Environment
am::CAmSocketHandler Class Reference

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

#include <CAmSocketHandler.h>

Public Member Functions

 CAmSocketHandler ()
 
 ~CAmSocketHandler ()
 
am_Error_e listenToSignals (const std::vector< uint8_t > &listSignals)
 install the signal fd More...
 
am_Error_e addFDPoll (const int fd, const short event, std::function< void(const sh_pollHandle_t handle, void *userData)> prepare, std::function< void(const pollfd pollfd, const sh_pollHandle_t handle, void *userData)> fired, std::function< bool(const sh_pollHandle_t handle, void *userData)> check, std::function< bool(const sh_pollHandle_t handle, void *userData)> dispatch, void *userData, sh_pollHandle_t &handle)
 Adds a filedescriptor to the polling loop. More...
 
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 addSignalHandler (std::function< void(const sh_pollHandle_t handle, const signalfd_siginfo &info, void *userData)> callback, sh_pollHandle_t &handle, void *userData)
 Adds a callback for any signals. More...
 
am_Error_e removeSignalHandler (const sh_pollHandle_t handle)
 removes a signal handler from the list More...
 
am_Error_e addTimer (const timespec &timeouts, IAmShTimerCallBack *callback, sh_timerHandle_t &handle, void *userData, const bool __attribute__((__unused__)) repeats=false)
 
am_Error_e addTimer (const timespec &timeouts, std::function< void(const sh_timerHandle_t handle, void *userData)> callback, sh_timerHandle_t &handle, void *userData, const bool __attribute__((__unused__)) repeats=false)
 
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 ()
 
bool fatalErrorOccurred ()
 

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 216 of file CAmSocketHandler.h.

Constructor & Destructor Documentation

am::CAmSocketHandler::CAmSocketHandler ( )

Definition at line 45 of file CAmSocketHandler.cpp.

am::CAmSocketHandler::~CAmSocketHandler ( )

Definition at line 81 of file CAmSocketHandler.cpp.

Member Function Documentation

am_Error_e am::CAmSocketHandler::addFDPoll ( const int  fd,
const short  event,
std::function< void(const sh_pollHandle_t handle, void *userData)>  prepare,
std::function< void(const pollfd pollfd, const sh_pollHandle_t handle, void *userData)>  fired,
std::function< bool(const sh_pollHandle_t handle, void *userData)>  check,
std::function< bool(const sh_pollHandle_t handle, void *userData)>  dispatch,
void *  userData,
sh_pollHandle_t handle 
)

Adds a filedescriptor to the polling loop.

Parameters
fdthe filedescriptor
eventthe event flags
preparea std::function that is called before the loop is entered
fireda std::function that is called when the filedescriptor needs to be read
checka std::function that is called to check if further actions are neccessary
dispatcha std::function 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 353 of file CAmSocketHandler.cpp.

am::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 399 of file CAmSocketHandler.cpp.

am_Error_e am::CAmSocketHandler::addSignalHandler ( std::function< void(const sh_pollHandle_t handle, const signalfd_siginfo &info, void *userData)>  callback,
sh_pollHandle_t handle,
void *  userData 
)

Adds a callback for any signals.

Parameters
callback
handlethe handle of this poll
userDataa pointer to userdata that is always passed around
Returns
E_OK if the descriptor was added, E_NON_EXISTENT if the fd is not valid

Definition at line 448 of file CAmSocketHandler.cpp.

am_Error_e am::CAmSocketHandler::addTimer ( const timespec &  timeouts,
IAmShTimerCallBack callback,
sh_timerHandle_t handle,
void *  userData,
const bool __attribute__((__unused__))  repeats = false 
)
am_Error_e am::CAmSocketHandler::addTimer ( const timespec &  timeouts,
std::function< void(const sh_timerHandle_t handle, void *userData)>  callback,
sh_timerHandle_t handle,
void *  userData,
const bool __attribute__((__unused__))  repeats = false 
)
void am::CAmSocketHandler::exit_mainloop ( )

Definition at line 214 of file CAmSocketHandler.cpp.

bool am::CAmSocketHandler::fatalErrorOccurred ( )

Definition at line 224 of file CAmSocketHandler.cpp.

am_Error_e am::CAmSocketHandler::listenToSignals ( const std::vector< uint8_t > &  listSignals)

install the signal fd

Adds a signal handler filedescriptor to the polling loop.

Definition at line 247 of file CAmSocketHandler.cpp.

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

removes a filedescriptor from the poll loop

Parameters
handle
Returns

Definition at line 424 of file CAmSocketHandler.cpp.

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

removes a signal handler from the list

Parameters
handleis signal handler id
Returns
E_OK in case of success, E_UNKNOWN if the handler was not found.

Definition at line 470 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 596 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 720 of file CAmSocketHandler.cpp.

void am::CAmSocketHandler::start_listenting ( )

start the block listening for filedescriptors.

This is the mainloop.

<the polling array for ppoll

Definition at line 95 of file CAmSocketHandler.cpp.

void am::CAmSocketHandler::stop_listening ( )

exits the loop

Definition at line 198 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 798 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 841 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 636 of file CAmSocketHandler.cpp.


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