mirror of
https://github.com/kunkundi/crossdesk.git
synced 2025-10-27 04:35:34 +08:00
Use one thread to process render and mouse/key events
This commit is contained in:
@@ -9,57 +9,7 @@
|
||||
#include "ikcp.h"
|
||||
#include "log.h"
|
||||
|
||||
#if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
|
||||
#include <windows.h>
|
||||
#elif !defined(__unix)
|
||||
#define __unix
|
||||
#endif
|
||||
|
||||
#ifdef __unix
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
using nlohmann::json;
|
||||
static int count = 1;
|
||||
|
||||
static inline void itimeofday(long *sec, long *usec) {
|
||||
#if defined(__unix)
|
||||
struct timeval time;
|
||||
gettimeofday(&time, NULL);
|
||||
if (sec) *sec = time.tv_sec;
|
||||
if (usec) *usec = time.tv_usec;
|
||||
#else
|
||||
static long mode = 0, addsec = 0;
|
||||
BOOL retval;
|
||||
static IINT64 freq = 1;
|
||||
IINT64 qpc;
|
||||
if (mode == 0) {
|
||||
retval = QueryPerformanceFrequency((LARGE_INTEGER *)&freq);
|
||||
freq = (freq == 0) ? 1 : freq;
|
||||
retval = QueryPerformanceCounter((LARGE_INTEGER *)&qpc);
|
||||
addsec = (long)time(NULL);
|
||||
addsec = addsec - (long)((qpc / freq) & 0x7fffffff);
|
||||
mode = 1;
|
||||
}
|
||||
retval = QueryPerformanceCounter((LARGE_INTEGER *)&qpc);
|
||||
retval = retval * 2;
|
||||
if (sec) *sec = (long)(qpc / freq) + addsec;
|
||||
if (usec) *usec = (long)((qpc % freq) * 1000000 / freq);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline IINT64 iclock64(void) {
|
||||
long s, u;
|
||||
IINT64 value;
|
||||
itimeofday(&s, &u);
|
||||
value = ((IINT64)s) * 1000 + (u / 1000);
|
||||
return value;
|
||||
}
|
||||
|
||||
static inline IUINT32 iclock() { return (IUINT32)(iclock64() & 0xfffffffful); }
|
||||
|
||||
const std::vector<std::string> ice_status = {
|
||||
"JUICE_STATE_DISCONNECTED", "JUICE_STATE_GATHERING",
|
||||
@@ -102,9 +52,9 @@ int IceTransmission::InitIceTransmission(std::string &ip, int port) {
|
||||
static_cast<IceTransmission *>(user);
|
||||
return ice_transmission_obj->ice_agent_->Send(buf, len);
|
||||
});
|
||||
ikcp_wndsize(kcp, 1024, 1280);
|
||||
ikcp_wndsize(kcp, 2048, 2048);
|
||||
ikcp_nodelay(kcp, 1, 20, 2, 1);
|
||||
// ikcp_setmtu(kcp_, 4000);
|
||||
// ikcp_setmtu(kcp, 4000);
|
||||
// kcp_->rx_minrto = 10;
|
||||
// kcp_->fastresend = 1;
|
||||
|
||||
@@ -147,7 +97,7 @@ int IceTransmission::InitIceTransmission(std::string &ip, int port) {
|
||||
}
|
||||
}
|
||||
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
||||
// std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
||||
}
|
||||
|
||||
ikcp_release(kcp);
|
||||
|
||||
Reference in New Issue
Block a user