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/rsThreadIO.cpp | |
parent | 6e97ed2127bdda72fee739fe9d28011d52155b9c (diff) |
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/rsThreadIO.cpp')
-rw-r--r-- | libs/rs/rsThreadIO.cpp | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/libs/rs/rsThreadIO.cpp b/libs/rs/rsThreadIO.cpp index 1c8b89c25d55..fe2c52ea4662 100644 --- a/libs/rs/rsThreadIO.cpp +++ b/libs/rs/rsThreadIO.cpp @@ -113,8 +113,10 @@ void ThreadIO::coreGetReturn(void *data, size_t dataLen) { } -bool ThreadIO::playCoreCommands(Context *con, bool waitForCommand) { +bool ThreadIO::playCoreCommands(Context *con, bool waitForCommand, uint64_t timeToWait) { bool ret = false; + uint64_t startTime = con->getTime(); + while (!mToCore.isEmpty() || waitForCommand) { uint32_t cmdID = 0; uint32_t cmdSize = 0; @@ -122,9 +124,17 @@ bool ThreadIO::playCoreCommands(Context *con, bool waitForCommand) { if (con->props.mLogTimes) { con->timerSet(Context::RS_TIMER_IDLE); } - const void * data = mToCore.get(&cmdID, &cmdSize); + + uint64_t delay = 0; + if (waitForCommand) { + delay = timeToWait - (con->getTime() - startTime); + if (delay > timeToWait) { + delay = 0; + } + } + const void * data = mToCore.get(&cmdID, &cmdSize, delay); if (!cmdSize) { - // exception occured, probably shutdown. + // exception or timeout occurred. return false; } if (con->props.mLogTimes) { |