diff --git a/tests/test_video_playback_device.py b/tests/test_video_playback_device.py index 62ba6d2..1ce7b8e 100644 --- a/tests/test_video_playback_device.py +++ b/tests/test_video_playback_device.py @@ -267,10 +267,10 @@ else: sample = sink.emit("pull-sample") if sample: buf = sample.get_buffer() - info = buf.map(Gst.MapFlags.READ) - if info.size > 0: + ok_m, map_info = buf.map(Gst.MapFlags.READ) + if ok_m and map_info.size > 0: live_frames += 1 - buf.unmap(info) + buf.unmap(map_info) return Gst.FlowReturn.OK vsink.connect("new-sample", _on_live_sample) @@ -593,7 +593,7 @@ else: print(" (close window with Escape or Q, or wait for timeout)\n") # ── SDL render loop (runs on main thread) ─────────────────────────── - WARMUP = 5 + WARMUP = 30 # skip ~1.25 s of frames to let DRM, network and texture init settle deadline8 = time.monotonic() + SDL8_SECONDS frame_n = 0 @@ -699,10 +699,13 @@ else: if not samples_us: print(f" {label:38s}: no samples") return - mn = statistics.mean(samples_us) - mx = max(samples_us) + mn = statistics.mean(samples_us) + mx = max(samples_us) pct = mn / budget * 100 - print(f" {label:38s}: mean {mn:6.0f} µs max {mx:6.0f} µs ({pct:.1f}% budget)") + # p95: sort and take the 95th-percentile value to filter outlier spikes + sorted_s = sorted(samples_us) + p95 = sorted_s[int(len(sorted_s) * 0.95)] + print(f" {label:38s}: mean {mn:6.0f} µs p95 {p95:6.0f} µs max {mx:6.0f} µs ({pct:.1f}% budget)") _stat("memmove (GStreamer thread)", fs.memmove_us[WARMUP:] if len(fs.memmove_us) > WARMUP else fs.memmove_us) _stat("SDL_UpdateNVTexture (main thread)", fs.upload_us)