diff options
author | GENIVI Audio Manager Maintainer <genivi-maint-audiomanager@smtp1.genivi.org> | 2018-06-20 13:25:05 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-20 13:25:05 +0200 |
commit | 55771e6c5749dd874e06f5dcc51b7b446bf58a5f (patch) | |
tree | de6c86d62087e27f318f5a9e97d8972b6c40154e /AudioManagerUtilities/src/CAmCommonAPIWrapper.cpp | |
parent | 87377bc3247cea1c72f1b8b19ee6753bc983876b (diff) | |
parent | fc50c62104b3019ff4de9e4fcc5b6f04b74a664a (diff) | |
download | audiomanager-55771e6c5749dd874e06f5dcc51b7b446bf58a5f.tar.gz |
Merge pull request #32 from JensLorenz/clean_pr26_utility_updates
Clean pr26 utility updates
Diffstat (limited to 'AudioManagerUtilities/src/CAmCommonAPIWrapper.cpp')
-rw-r--r-- | AudioManagerUtilities/src/CAmCommonAPIWrapper.cpp | 45 |
1 files changed, 32 insertions, 13 deletions
diff --git a/AudioManagerUtilities/src/CAmCommonAPIWrapper.cpp b/AudioManagerUtilities/src/CAmCommonAPIWrapper.cpp index 2aa8370..caa7aa8 100644 --- a/AudioManagerUtilities/src/CAmCommonAPIWrapper.cpp +++ b/AudioManagerUtilities/src/CAmCommonAPIWrapper.cpp @@ -156,7 +156,7 @@ void CAmCommonAPIWrapper::commonFireCallback(const pollfd pollfd, const sh_pollH return; } - mWatchToCheck->dispatch(pollfd.events); + mWatchToCheck->dispatch(pollfd.revents); } void CAmCommonAPIWrapper::commonPrepareCallback(const sh_pollHandle_t, void*) @@ -207,20 +207,37 @@ void CAmCommonAPIWrapper::registerTimeout(CommonAPI::Timeout* timeout, const Com { timespec pollTimeout; int64_t localTimeout = timeout->getTimeoutInterval(); - - pollTimeout.tv_sec = localTimeout / 1000; - pollTimeout.tv_nsec = (localTimeout % 1000) * 1000000; + + if(CommonAPI::TIMEOUT_INFINITE==localTimeout)//dispatch never + { + pollTimeout.tv_sec = localTimeout; + pollTimeout.tv_nsec = 0; + } + else if(CommonAPI::TIMEOUT_NONE==localTimeout)//dispatch immediately + { + pollTimeout.tv_sec = 0; + pollTimeout.tv_nsec = 1000000; + } + else + { + pollTimeout.tv_sec = localTimeout / 1000; + pollTimeout.tv_nsec = (localTimeout % 1000) * 1000000; + } //prepare handle and callback. new is eval, but there is no other choice because we need the pointer! sh_timerHandle_t handle; //add the timer to the pollLoop - mpSocketHandler->addTimer(pollTimeout, &pCommonTimerCallback, handle, timeout); - - timerHandles myHandle({handle,timeout}); - mpListTimerhandles.push_back(myHandle); - - return; + am_Error_e error = mpSocketHandler->addTimer(pollTimeout, &pCommonTimerCallback, handle, timeout); + if (error != am_Error_e::E_OK || handle == 0) + { + logError(__func__,"adding timer failed"); + } + else + { + timerHandles myHandle({handle,timeout}); + mpListTimerhandles.push_back(myHandle); + } } void CAmCommonAPIWrapper::deregisterTimeout(CommonAPI::Timeout* timeout) @@ -243,10 +260,12 @@ void CAmCommonAPIWrapper::registerWatch(CommonAPI::Watch* watch, const CommonAPI am_Error_e error = mpSocketHandler->addFDPoll(pollfd_.fd, pollfd_.events, &pCommonPrepareCallback, &pCommonFireCallback, &pCommonCheckCallback, &pCommonDispatchCallback, watch, handle); //if everything is alright, add the watch and the handle to our map so we know this relationship - if (error == !am_Error_e::E_OK || handle == 0) + if (error != am_Error_e::E_OK || handle == 0) + { logError(__func__,"entering watch failed"); - - mMapWatches.insert(std::make_pair(pollfd_.fd,watch)); + } + else + mMapWatches.insert(std::make_pair(pollfd_.fd,watch)); } void CAmCommonAPIWrapper::commonTimerCallback(sh_timerHandle_t handle, void *) |