Fix: repair two quality-switch regressions (monitor jump, H264 stall)
Every quality change restarts the capturer on both sides, and two defects showed up along that path. Monitor jump: on a multi-monitor client the view moved to another monitor. switchScreen=false means "reuse the index", but index is the *next* monitor to switch to, not the one being shown. Track `current` and read it on the non-switch path; the switch path still advances. H264 stall: switching from RGB565/DIFF back to H264 froze the view for up to ten seconds. The client encoder kept its reference frames across the gap, so it emitted P frames the server could not decode until the next natural IDR. It is now rebuilt on the first H264 frame after an algorithm or tuning change. The rebuild is requested with an atomic dirty flag that the capture thread consumes in ensureEncoder(), because resetting the encoder from the network thread raced with encode(). On the server, ApplyQualityLevel() only sets m_bResolutionChanging when the client will really restart the capture: it compares the target maxWidth with the client's reported bitmap width (cached atomically on TOKEN_BITMAPINFO) and stays conservative while a previous resize is still in flight. The fallback timeout drops from 5s to 1s, flushes the decoder and asks the client for a keyframe (COMMAND_SCREEN_KEYFRAME_REQ). Verified: Debug client and server build clean; the 1920-wide High->Good switch no longer waits out the gate. Not yet retested on a live session. Co-Authored-By: deepseek-flash
This commit is contained in:
1 parent
d6b04a98f0
commit
6a51116873
4 files changed
+100
-19
No files matched your search
@@ -225,12 +225,19 @@ public:
|
||||
VOID SendNext(void);
|
||||
// 下发主控端「高级 → 远程桌面调优」的开关位(CMD_SCREEN_TUNING),主控端默认 0x7
|
||||
VOID SendScreenTuning(void);
|
||||
// 要求客户端下一帧强制 IDR(COMMAND_SCREEN_KEYFRAME_REQ)
|
||||
VOID RequestClientKeyFrame(void);
|
||||
VOID OnReceiveComplete();
|
||||
HDC m_hFullDC;
|
||||
HDC m_hFullMemDC;
|
||||
HBITMAP m_BitmapHandle;
|
||||
PVOID m_BitmapData_Full;
|
||||
LPBITMAPINFO m_BitmapInfor_Full;
|
||||
// 客户端当前发送位图宽度,TOKEN_BITMAPINFO 时更新。ApplyQualityLevel 在 UI 线程
|
||||
// 预判"客户端会不会重启截屏",不能直接解引用 m_BitmapInfor_Full——那个指针由
|
||||
// 接收线程在 TOKEN_BITMAPINFO 里 SAFE_DELETE + new,跨线程解引用有 UAF 风险。
|
||||
// 0 表示尚未收到位图信息(调用方按"可能重启"保守处理)。
|
||||
std::atomic<int> m_nClientBitmapWidth{0};
|
||||
VOID DrawFirstScreen(void);
|
||||
VOID DrawNextScreenDiff(bool keyFrame);
|
||||
VOID DrawScrollFrame(void);
|
||||
|
||||
Reference in new issue
Block a user