From 545071e998806235442edda5f575ee61e836abe9 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 3 Jan 2019 00:09:09 +0100 Subject: cruft --- proto-udp/ftnoir_protocol_ftn.cpp | 6 +++++- proto-udp/ftnoir_protocol_ftn.h | 5 ++++- 2 files changed, 9 insertions(+), 2 deletions(-) (limited to 'proto-udp') diff --git a/proto-udp/ftnoir_protocol_ftn.cpp b/proto-udp/ftnoir_protocol_ftn.cpp index 0eb79954..def3ebb1 100644 --- a/proto-udp/ftnoir_protocol_ftn.cpp +++ b/proto-udp/ftnoir_protocol_ftn.cpp @@ -18,15 +18,19 @@ udp::udp() QObject::connect(s.b.get(), &bundle_::changed, this, &udp::set_dest_address, - Qt::QueuedConnection); + Qt::DirectConnection); } void udp::pose(const double *headpose) { + spinlock_guard l(spl); + outSocket.writeDatagram((const char *) headpose, sizeof(double[6]), dest_ip, dest_port); } void udp::set_dest_address() { + spinlock_guard l(spl); + dest_port = (unsigned short)s.port; dest_ip = QHostAddress((s.ip1.to() & 0xff) << 24 | (s.ip2.to() & 0xff) << 16 | diff --git a/proto-udp/ftnoir_protocol_ftn.h b/proto-udp/ftnoir_protocol_ftn.h index 8bc581bf..a7c90f5b 100644 --- a/proto-udp/ftnoir_protocol_ftn.h +++ b/proto-udp/ftnoir_protocol_ftn.h @@ -11,10 +11,11 @@ #pragma once #include "ui_ftnoir_ftncontrols.h" -#include #include "api/plugin-api.hpp" +#include "compat/spinlock.hpp" #include "options/options.hpp" using namespace options; +#include struct settings : opts { value ip1, ip2, ip3, ip4, port; @@ -41,6 +42,8 @@ private: QUdpSocket outSocket; settings s; + mutable std::atomic_flag spl = ATOMIC_FLAG_INIT; + QHostAddress dest_ip { 127u << 24 | 1u }; unsigned short dest_port = 65535; -- cgit v1.2.3