From 83eb8e7ab64949f1c039e9b73abf2ae11698148a Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Tue, 9 Aug 2011 08:35:47 +0100 Subject: RECORDER: Implement time compensation for playback --- common/EventRecorder.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'common/EventRecorder.cpp') diff --git a/common/EventRecorder.cpp b/common/EventRecorder.cpp index cf3c8b391f..73832482f2 100644 --- a/common/EventRecorder.cpp +++ b/common/EventRecorder.cpp @@ -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; } -- cgit v1.2.3 From 00d25a77a9d8297fdc356c7a10f9dc2d94903a5f Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Tue, 9 Aug 2011 15:04:26 +0200 Subject: RECORDER: Defer mutex deletion to destructor. Since we now call deinit after a game has been run, otherwise RTL would be broken. See bug report #3388982 "valgrind errors when doing multiple RTL". --- common/EventRecorder.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'common/EventRecorder.cpp') diff --git a/common/EventRecorder.cpp b/common/EventRecorder.cpp index 73832482f2..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) { -- cgit v1.2.3