aboutsummaryrefslogtreecommitdiff
path: root/common/EventRecorder.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'common/EventRecorder.cpp')
-rw-r--r--common/EventRecorder.cpp26
1 files changed, 23 insertions, 3 deletions
diff --git a/common/EventRecorder.cpp b/common/EventRecorder.cpp
index cf3c8b391f..3be3161203 100644
--- a/common/EventRecorder.cpp
+++ b/common/EventRecorder.cpp
@@ -133,6 +133,9 @@ EventRecorder::EventRecorder() {
EventRecorder::~EventRecorder() {
deinit();
+
+ g_system->deleteMutex(_timeMutex);
+ g_system->deleteMutex(_recorderMutex);
}
void EventRecorder::init() {
@@ -282,9 +285,6 @@ void EventRecorder::deinit() {
//TODO: remove recordTempFileName'ed file
}
-
- g_system->deleteMutex(_timeMutex);
- g_system->deleteMutex(_recorderMutex);
}
void EventRecorder::registerRandomSource(RandomSource &rnd, const String &name) {
@@ -324,6 +324,13 @@ void EventRecorder::processMillis(uint32 &millis) {
if (_recordTimeCount > _playbackTimeCount) {
d = readTime(_playbackTimeFile);
+ while ((_lastMillis + d > millis) && (_lastMillis + d - millis > 50)) {
+ _recordMode = kPassthrough;
+ g_system->delayMillis(50);
+ millis = g_system->getMillis();
+ _recordMode = kRecorderPlayback;
+ }
+
millis = _lastMillis + d;
_playbackTimeCount++;
}
@@ -334,6 +341,19 @@ void EventRecorder::processMillis(uint32 &millis) {
}
bool EventRecorder::processDelayMillis(uint &msecs) {
+ if (_recordMode == kRecorderPlayback) {
+ _recordMode = kPassthrough;
+
+ uint32 millis = g_system->getMillis();
+
+ _recordMode = kRecorderPlayback;
+
+ if (_lastMillis > millis) {
+ // Skip delay if we're getting late
+ return true;
+ }
+ }
+
return false;
}