More recording

This commit is contained in:
2022-01-03 21:37:00 +01:00
parent 3ec41a1a19
commit d7b765fba5
5 changed files with 57 additions and 16 deletions
+18 -5
View File
@@ -43,6 +43,7 @@ XPLMDataRef roll;
XPLMDataRef quaternion;
data toSend;
Path p;
/*
* Callbacks
@@ -162,6 +163,12 @@ PLUGIN_API void XPluginStop(void)
wantsExit = true;
delete connector;
serverThread.join();
recordingThread.join();
std::ofstream out("Resources/plugins/GAConnector/flight.rec");
out.write(reinterpret_cast<const char *>(p.getBinaryData()),
(std::streamsize)p.getBinaryLength());
out.close();
}
PLUGIN_API void XPluginDisable(void) {}
@@ -240,7 +247,7 @@ void recordingWorker()
{
util::setThreadName("GARecordingWorker");
Path p;
PathSegment lastPath;
while (!wantsExit) {
data copy;
@@ -250,10 +257,16 @@ void recordingWorker()
memcpy(&copy, &toSend, sizeof(data));
}
p.addSegment({static_cast<std::uint16_t>(copy.alt),
static_cast<std::uint16_t>(copy.gs),
copy.lat,
copy.lon});
PathSegment currentPath(static_cast<std::uint16_t>(copy.alt),
static_cast<std::uint16_t>(copy.gs),
copy.lat,
copy.lon);
if (strcmp(copy.path, "") != 0 && copy.pause &&
lastPath != currentPath) {
p.addSegment(currentPath);
lastPath = currentPath;
}
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
}