Fix: React to slow-frame congestion and keep remote audio recoverable

The adaptive quality controller counted only complete frames per second, so when
a single frame took several seconds to arrive the sample was 0 fps and the
throughput criterion abstained forever: Ultra and High kept flipping while a
foreground video played. The audio watchdog had the opposite problem: it rebuilt
the WASAPI capture every three seconds on an idle endpoint, and its sleep
detector measured the whole loop including a blocking send.

Sample the last ten seconds in a ring buffer and feed the criterion a windowed
rate, guarded so a scroll burst, a stale window or a few KB clock patch is not
mistaken for congestion. Apply the same per-frame floor to the one-second
fallback and to the post-downgrade local-bottleneck probe. Normalize delayed
timer ticks by real elapsed milliseconds, and make the 40 second
upgrade-failure window outlast the resolution cooldown it has to cross.

On the client, rebuild only when an audio session is actually rendering, and
rebuild immediately when the captured endpoint is no longer the default output;
refresh the sleep timestamps on failed as well as successful init.

Tests cover the window and fallback helpers directly; the full suite passes
845/845, and both the Debug server and Debug client build.

Co-Authored-By: deepseek-flash
This commit was merged in pull request #6.
This commit is contained in:
yuanyuanxianganddeepseek-flash committed 2026-11-08 11:45:19 +01:00
1 parent 2a97471b51
commit 5f40f3726c
6 files changed
+688 -31

No files matched your search

+8
View File
@@ -331,6 +331,14 @@ if(WIN32)
target_compile_definitions(quality_load_test PRIVATE _WIN32)
endif()
if(MSVC)
# CMake 默认给所有目标加 /D_WINDOWS,commands.h 见到它就 include <afxwin.h>;
# 测试用 /MD 又没定义 _AFXDLL,于是直接编译失败(这个目标因此一直没在 Windows
# 上跑起来)。判据本身不需要 MFC,去掉它不是二选一:commands.h 会退回 windows.h。
# 只对 MSVC 生效:MinGW/GCC 不认 /U_WINDOWS。
target_compile_options(quality_load_test PRIVATE /U_WINDOWS)
endif()
if(UNIX)
target_link_libraries(quality_load_test Threads::Threads)
endif()