mirror of
https://github.com/yuanyuanxiang/SimpleRemoter.git
synced 2026-01-21 23:13:08 +08:00
Fix #281: Check if CPU has SSE2 to avoid client crash
This commit is contained in:
@@ -17,6 +17,15 @@
|
||||
#include "X264Encoder.h"
|
||||
#include "common/file_upload.h"
|
||||
|
||||
inline bool HasSSE2() {
|
||||
#ifdef _DEBUG
|
||||
return false;
|
||||
#else
|
||||
auto static has = IsProcessorFeaturePresent(PF_XMMI64_INSTRUCTIONS_AVAILABLE);
|
||||
return has;
|
||||
#endif
|
||||
}
|
||||
|
||||
class ThreadPool
|
||||
{
|
||||
public:
|
||||
@@ -304,7 +313,7 @@ public:
|
||||
virtual ULONG CompareBitmap(LPBYTE CompareSourData, LPBYTE CompareDestData, LPBYTE szBuffer,
|
||||
DWORD ulCompareLength, BYTE algo, int startPostion = 0)
|
||||
{
|
||||
if (UsingDXGI())
|
||||
if (UsingDXGI() || !HasSSE2())
|
||||
return CompareBitmapDXGI(CompareSourData, CompareDestData, szBuffer, ulCompareLength, algo, startPostion);
|
||||
|
||||
LPBYTE p = szBuffer;
|
||||
|
||||
@@ -110,7 +110,7 @@ public:
|
||||
// 9. 初始化 BITMAPINFO
|
||||
m_BitmapInfor_Full = ConstructBitmapInfo(32, m_ulFullWidth, m_ulFullHeight);
|
||||
iniFile cfg(CLIENT_PATH);
|
||||
int strategy = cfg.GetInt("settings", "ScreenStrategy", 0);
|
||||
int strategy = HasSSE2() ? cfg.GetInt("settings", "ScreenStrategy", 0) : 1;
|
||||
switch (strategy) {
|
||||
case 1:
|
||||
break;
|
||||
|
||||
@@ -332,6 +332,11 @@ BOOL IsRunningAsSystem()
|
||||
|
||||
BOOL CScreenManager::OnReconnect()
|
||||
{
|
||||
auto duration = GetTickCount64() - m_nReconnectTime;
|
||||
if (duration <= 3000)
|
||||
Sleep(3000 - duration);
|
||||
m_nReconnectTime = GetTickCount64();
|
||||
|
||||
m_SendFirst = FALSE;
|
||||
BOOL r = m_ClientObject ? m_ClientObject->Reconnect(this) : FALSE;
|
||||
Mprintf("CScreenManager OnReconnect '%s'\n", r ? "succeed" : "failed");
|
||||
|
||||
@@ -75,6 +75,7 @@ public:
|
||||
bool SwitchScreen();
|
||||
bool RestartScreen();
|
||||
virtual BOOL OnReconnect();
|
||||
uint64_t m_nReconnectTime = 0; // 重连开始时间
|
||||
uint64_t m_DlgID = 0;
|
||||
BOOL m_SendFirst = FALSE;
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ CScreenSpy::CScreenSpy(ULONG ulbiBitCount, BYTE algo, BOOL vDesk, int gop, BOOL
|
||||
m_BitmapInfor_Full = ConstructBitmapInfo(ulbiBitCount, m_ulFullWidth, m_ulFullHeight);
|
||||
|
||||
iniFile cfg(CLIENT_PATH);
|
||||
int strategy = cfg.GetInt("settings", "ScreenStrategy", 0);
|
||||
int strategy = HasSSE2() ? cfg.GetInt("settings", "ScreenStrategy", 0) : 1;
|
||||
m_BitmapInfor_Send = new BITMAPINFO(*m_BitmapInfor_Full);
|
||||
switch (strategy) {
|
||||
case 1: // 1 - Original size
|
||||
|
||||
Reference in New Issue
Block a user