summaryrefslogtreecommitdiffstats
path: root/libs/rs/rsThreadIO.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libs/rs/rsThreadIO.cpp')
-rw-r--r--libs/rs/rsThreadIO.cpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/libs/rs/rsThreadIO.cpp b/libs/rs/rsThreadIO.cpp
index 1c8b89c..fe2c52e 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) {