diff options
author | Aleksandar Donchev <Aleksander.Donchev@partner.bmw.de> | 2017-10-12 13:02:09 +0200 |
---|---|---|
committer | Jacqueline Molz <Jacqueline.Molz@bmw.de> | 2018-02-13 12:48:35 +0100 |
commit | d8e5445dc4d7ca8267dcf97004f6baaead668eb7 (patch) | |
tree | 36bb6861a3180c4f75111f3194aceeee17a14bf5 /AudioManagerUtilities/src/CAmCommonAPIWrapper.cpp | |
parent | 6b6342f5381138aeecea93e153de021e42db8283 (diff) | |
download | audiomanager-d8e5445dc4d7ca8267dcf97004f6baaead668eb7.tar.gz |
Real time scheduler added, capi wrapper timeout return value considered in registerTimeout, only requested revent passed from within the camsockethandler instead of all
Signed-off-by: Christian Linke <christian.linke@bmw.de>
Change-Id: I2d9d2c424ac3fac62c76a66545a531c518edb2e8
Diffstat (limited to 'AudioManagerUtilities/src/CAmCommonAPIWrapper.cpp')
-rw-r--r-- | AudioManagerUtilities/src/CAmCommonAPIWrapper.cpp | 43 |
1 files changed, 31 insertions, 12 deletions
diff --git a/AudioManagerUtilities/src/CAmCommonAPIWrapper.cpp b/AudioManagerUtilities/src/CAmCommonAPIWrapper.cpp index 126b649..caa7aa8 100644 --- a/AudioManagerUtilities/src/CAmCommonAPIWrapper.cpp +++ b/AudioManagerUtilities/src/CAmCommonAPIWrapper.cpp @@ -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 *) |