iter5 Track E: move LAST_OUTPUT_WIDTH/HEIGHT from process-global to per-driver-data

Sonnet review 7.3 / 9.6 from iter1 + carried iter2/3/4 substrate.
Two libva driver_data instances in the same process (e.g. Firefox
playing two tabs at different resolutions, or Firefox + mpv via the
same dlopened backend) would race on the static cache.

Move to struct request_data.last_output_width/height. The V4L2
device fd is already per-driver_data, so this is the correct binding
unit (one fd, one current OUTPUT format).

Verified: two concurrent mpv processes (2s stagger) both decode
300 frames cleanly with no cross-corruption. Same-instant init still
hits kernel-level fd contention on /dev/video1 (hantro is a
single-instance device); cross-process serialization is out of scope
for a libva backend.

Resolves the surface_reset_format_cache() callsite: now takes
driver_data parameter (was zero-arg).

Also drops the 'rc' unused-variable warning in v4l2_ioctl_controls
that the iter5 sweep left behind.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-05 15:05:41 +00:00
parent 843febc174
commit b993355507
5 changed files with 52 additions and 32 deletions
+19
View File
@@ -80,6 +80,25 @@ struct request_data {
* visible stutter on mpv vaapi --vo=gpu.
*/
struct cap_pool capture_pool;
/*
* Per-driver-data cache of the OUTPUT format we've set on the
* V4L2 device (iter5 Track E: was process-global static
* LAST_OUTPUT_WIDTH/HEIGHT, which would race when two libva
* driver_data instances share a process — e.g. Firefox playing
* one tab while Chromium plays another, or two mpv processes
* via the same dlopened backend). Kept per-driver_data because
* the V4L2 device fd is per-driver_data; one fd, one current
* format. Process-global was always wrong, just didn't surface
* until iter5's audit.
*
* See surface.c::CreateSurfaces2 for the consumer pattern (mpv
* probes with small surfaces then re-allocates at real
* resolution; we re-set the OUTPUT format whenever this pair
* changes).
*/
unsigned int last_output_width;
unsigned int last_output_height;
};
VAStatus VA_DRIVER_INIT_FUNC(VADriverContextP context);