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
diff --git a/rsThreadIO.cpp b/rsThreadIO.cpp
index 1c8b89c..fe2c52e 100644
--- a/rsThreadIO.cpp
+++ b/rsThreadIO.cpp
@@ -113,8 +113,10 @@
}
-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 @@
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) {