diff options
author | Jason Sams <rjsams@android.com> | 2011-08-12 15:05:15 -0700 |
---|---|---|
committer | Jason Sams <rjsams@android.com> | 2011-08-12 15:05:15 -0700 |
commit | bfc7891bdd08f2c16e9ffa592fd9f4ea21ff220d (patch) | |
tree | b4a745fb02532bfb5e96e8fc807bb8415562dc23 /libs/rs/rsSignal.cpp | |
parent | 6e97ed2127bdda72fee739fe9d28011d52155b9c (diff) | |
download | frameworks_base-bfc7891bdd08f2c16e9ffa592fd9f4ea21ff220d.zip frameworks_base-bfc7891bdd08f2c16e9ffa592fd9f4ea21ff220d.tar.gz frameworks_base-bfc7891bdd08f2c16e9ffa592fd9f4ea21ff220d.tar.bz2 |
Fix the RS frame timeout.
Previous a slow app would block from receiving new
commands until the timer expired. This change will
expire the timer immediatly.
Change-Id: I42b949d21f98ee0f1d3156763cd723c3e9cabb67
Diffstat (limited to 'libs/rs/rsSignal.cpp')
-rw-r--r-- | libs/rs/rsSignal.cpp | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/libs/rs/rsSignal.cpp b/libs/rs/rsSignal.cpp index ccd20b9..413ac2b 100644 --- a/libs/rs/rsSignal.cpp +++ b/libs/rs/rsSignal.cpp @@ -68,26 +68,43 @@ void Signal::set() { } } -void Signal::wait() { +bool Signal::wait(uint64_t timeout) { int status; + bool ret = false; status = pthread_mutex_lock(&mMutex); if (status) { LOGE("LocklessCommandFifo: error %i locking for condition.", status); - return; + return false; } if (!mSet) { - status = pthread_cond_wait(&mCondition, &mMutex); - if (status) { - LOGE("LocklessCommandFifo: error %i waiting on condition.", status); + if (!timeout) { + status = pthread_cond_wait(&mCondition, &mMutex); + } else { +#if defined(HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE) + status = pthread_cond_timeout_np(&mCondition, &mMutex, timeout / 1000000); +#else + // This is safe it will just make things less reponsive + status = pthread_cond_wait(&mCondition, &mMutex); +#endif + } + } + + if (!status) { + mSet = false; + ret = true; + } else { + if (status != ETIMEDOUT) { + LOGE("LocklessCommandFifo: error %i waiting for condition.", status); } } - mSet = false; status = pthread_mutex_unlock(&mMutex); if (status) { LOGE("LocklessCommandFifo: error %i unlocking for condition.", status); } + + return ret; } |