#include <dlt/dlt.h>
#include <signal.h>
+
+#include <iostream>
//todo: implement time correction if timer was interrupted by call
DLT_IMPORT_CONTEXT(AudioManager)
mLastInsertedHandle(0),
mLastInsertedPollHandle(0),
mRecreatePollfds(true),
- mTimeout(),
- mTimeoutPointer(NULL)
+ mTimeout()
{
- mTimeout.tv_nsec=0;
- mTimeout.tv_sec=0;
+ mTimeout.tv_nsec=-1;
+ mTimeout.tv_sec=-1;
+ gDispatchDone=0;
}
SocketHandler::~SocketHandler()
//block until something is on a filedescriptor
#ifdef WITH_PPOLL
- if((pollStatus=ppoll(&mfdPollingArray.front(),mfdPollingArray.size(),mTimeoutPointer,&sigmask))<0)
+
+ timespec buffertime;
+ if((pollStatus=ppoll(&mfdPollingArray.front(),mfdPollingArray.size(),insertTime(buffertime),&sigmask))<0)
{
if(errno==EINTR)
{
}
#else
- sigprocmask (SIG_SETMASK, &mask, &oldmask);
+ //sigprocmask (SIG_SETMASK, &mask, &oldmask);
if((pollStatus=poll(&mfdPollingArray.front(),mfdPollingArray.size(),timespec2ms(mTimeout)))<0)
{
DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("SocketHandler::start_listenting poll returned with error"),DLT_INT(errno));
exit(0);
}
- sigprocmask (SIG_SETMASK, &oldmask, NULL);
+ //sigprocmask (SIG_SETMASK, &oldmask, NULL);
#endif
if (pollStatus!=0) //only check filedescriptors if there was a change
if (!mListActiveTimer.empty())
{
mTimeout=mListActiveTimer.front().countdown;
- mTimeoutPointer=&mTimeout;
}
else
{
- mTimeout.tv_nsec=0;
- mTimeout.tv_sec=0;
- mTimeoutPointer=NULL;
+ mTimeout.tv_nsec=-1;
+ mTimeout.tv_sec=-1;
}
return E_OK;
}
//substract the old value from all timers in the list
std::for_each(mListActiveTimer.begin(),mListActiveTimer.end(),SubstractTime(mTimeout));
mTimeout=mListActiveTimer.front().countdown;
- mTimeoutPointer=&mTimeout;
}
else
{
- mTimeout.tv_nsec=0;
- mTimeout.tv_sec=0;
- mTimeoutPointer=NULL;
+ mTimeout.tv_nsec=-1;
+ mTimeout.tv_sec=-1;
}
}
if(!mListActiveTimer.empty())
{
mTimeout=mListActiveTimer.front().countdown;
- mTimeoutPointer=&mTimeout;
}
else
{
- mTimeout.tv_nsec=0;
- mTimeout.tv_sec=0;
- mTimeoutPointer=NULL;
+ mTimeout.tv_nsec=-1;
+ mTimeout.tv_sec=-1;
}
}
*/
inline int SocketHandler::timespec2ms(const timespec & time)
{
- return (time.tv_nsec == 0 && time.tv_sec == 0) ? -1 : time.tv_sec * 1000 + time.tv_nsec / 1000000;
+ return (time.tv_nsec == -1 && time.tv_sec == -1) ? -1 : time.tv_sec * 1000 + time.tv_nsec / 1000000;
+}
+
+inline timespec* am::SocketHandler::insertTime(timespec& buffertime)
+{
+ buffertime.tv_nsec=mTimeout.tv_nsec;
+ buffertime.tv_sec=mTimeout.tv_sec;
+ return (mTimeout.tv_nsec == -1 && mTimeout.tv_sec == -1) ? NULL : &buffertime;
}
/**
}
+
+
+
+