时间线:
14:47:55.119
First frame processed, encoder initialized, transitioning to Streaming
14:47:56.178
encoded_fps=29.7 sent_fps=0.0
14:48:01.892
14:48:01.917
6 秒内编码器产出 ~180 帧但无处可去(彼时还没有 WebRTC client,也没开 --output)。
src/state_portal.rs:706-713 维护 paused 标志:
src/state_portal.rs:706-713
paused
let now_paused = !connected; if was_paused && !now_paused { tracing::info!("WebRTC client connected, resuming encoding"); } paused.store(now_paused, Ordering::Relaxed);
paused 初始值默认是 true(语义上"未连接即暂停"),但:
true
encode_cpu_frame
src/avhw.rs:1116-1120
self.webrtc_paused: Option<Arc<AtomicBool>>
None
webrtc_paused
SwEncImport::new_webrtc()
--output
--port
StatePortal::new()
paused = true
SwEncEncode::webrtc_paused
Some(...)
wl-webrtc --port 56666 -v # 注意日志 14:47:55 到客户端连接之间的 stats 行 # 关注 encoded_fps > 0 且 sent_fps = 0 的窗口
No dependencies set.
The note is not visible to the blocked user.
现象
时间线:
14:47:55.11914:47:55.119First frame processed, encoder initialized, transitioning to Streaming14:47:56.178encoded_fps=29.7 sent_fps=0.0← 空转开始可见14:48:01.89214:48:01.9176 秒内编码器产出 ~180 帧但无处可去(彼时还没有 WebRTC client,也没开 --output)。
根因(怀疑)
src/state_portal.rs:706-713维护paused标志:paused初始值默认是true(语义上"未连接即暂停"),但:encode_cpu_frame的 paused 检查(src/avhw.rs:1116-1120)依赖self.webrtc_paused: Option<Arc<AtomicBool>>——若该字段为None则永不暂停webrtc_paused是否在SwEncImport::new_webrtc()路径正确传递影响
期望行为
--output未指定 + 无 WebRTC client:编码器完全不应启动,或启动后立即进入 paused--output模式:编码器应运行(写文件)--port模式:编码器在 WebRTC client connect 之前不应运行修复方向
StatePortal::new()阶段,WebRTC 模式下显式初始化paused = trueSwEncEncode::webrtc_paused字段在 encode 线程 spawn 前已Some(...)复现