diff --git a/src/surface.c b/src/surface.c index 88a0b7a..37155d6 100644 --- a/src/surface.c +++ b/src/surface.c @@ -461,11 +461,19 @@ VAStatus RequestSyncSurface(VADriverContextP context, VASurfaceID surface_id) goto error; } - rc = media_request_reinit(request_fd); - if (rc < 0) { - status = VA_STATUS_ERROR_OPERATION_FAILED; - goto error; - } + /* + * iter4: instead of REINITing for reuse, close the request_fd here + * and force the next BeginPicture to allocate a fresh one. The cached + * request_fd path was hitting EINVAL on S_EXT_CTRLS for some surface + * recycle patterns (4 individual TRY_EXT_CTRLS on the same fd all + * fail with EINVAL — the fd state is bad even though queue+wait+reinit + * appeared successful). Allocating fresh per frame is unambiguous and + * sidesteps any state-lifecycle issue. Tradeoff: ~one extra ioctl per + * frame (MEDIA_IOC_REQUEST_ALLOC + close), negligible cost. + */ + close(request_fd); + surface_object->request_fd = -1; + (void)0; /* placeholder for the now-removed reinit error path */ rc = v4l2_dequeue_buffer(driver_data->video_fd, -1, output_type, surface_object->source_index, 1);