fix: FPS limiter never passes frames when input > target rate

The old FpsLimit compared timestamps between CONSECUTIVE frames.
When PipeWire delivers at 60fps (16ms intervals) and target is 30fps
(33ms min_interval), the gap between consecutive frames is always
16ms < 33ms, so EVERY frame was rejected after the first.

Fix: track last_output_time and compare against that instead of the
previous frame's timestamp. Now frames pass when enough time has
elapsed since the last OUTPUT, not since the last INPUT.

Also adds PipeWire process callback counter logging and frame
diagnostic STATS in state_portal.rs for debugging.
This commit is contained in:
dailz
2026-05-29 22:09:35 +08:00
parent d80b34f44f
commit a83d146ed3
2 changed files with 50 additions and 22 deletions
+7
View File
@@ -405,7 +405,14 @@ fn pipewire_thread(ctx: PwThreadCtx) {
let format_info = format_info.clone();
let frame_tx = frame_tx.clone();
let dropped = dropped;
let process_count = Rc::new(Cell::new(0u64));
let process_count_clone = process_count.clone();
move |stream, _| {
let count = process_count_clone.get() + 1;
process_count_clone.set(count);
if count <= 5 || count % 60 == 0 {
tracing::info!("PipeWire process callback #{count}");
}
// 从流中出队原始 buffer(包含帧数据的元信息)
let raw_buf = unsafe { stream.dequeue_raw_buffer() };
if raw_buf.is_null() {