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
@@ -105,16 +105,25 @@ public:
|
||||
if (!dxgiAdapter)break;
|
||||
|
||||
// 4. 获取 DXGI 输出(屏幕)
|
||||
// screen = 下一次切屏要用的输出索引(沿用原语义:切屏时自增)
|
||||
// current = 当前正在用的输出。重建截屏对象(质量/分辨率变化)必须沿用它:
|
||||
// 读 screen 会跳到下一个输出,多显示器下表现为"调个质量就换屏",
|
||||
// 单显示器下 EnumOutputs(1) 不存在,会让 DXGI 初始化失败降级成 GDI。
|
||||
static UINT screen = 0;
|
||||
UINT outIndex = switchScreen ? screen++ : screen;
|
||||
static UINT current = 0;
|
||||
UINT outIndex = switchScreen ? screen++ : current;
|
||||
HRESULT r = dxgiAdapter->EnumOutputs(outIndex, &dxgiOutput);
|
||||
if (r == DXGI_ERROR_NOT_FOUND && all) {
|
||||
// 索引在当前适配器上不存在(拔掉外接屏等):回到主输出再试,
|
||||
// 避免拿一个无效索引去遍历适配器,最后降级成 GDI。
|
||||
screen = 0;
|
||||
current = 0;
|
||||
idx ++;
|
||||
dxgiAdapter->Release();
|
||||
dxgiAdapter = nullptr;
|
||||
continue;
|
||||
}
|
||||
current = outIndex;
|
||||
if (!dxgiOutput)break;
|
||||
|
||||
// 4.1 获取屏幕位置(多显示器支持)
|
||||
|
||||
Reference in new issue
Block a user