media/gpu/vaapi: do not use Unretained(VaapiWrapper) for VASurface dtor

CreateVASurfaceForPixmap() is used to import a DmaBuf (via a
NativePixmap description) into VA-API, creating a VASurface to
represent it. This VASurface binds a DestroySurface as destructor;
if this is invoked after VaapiWrapper has been destroyed, we get
an error and a GPU crash. To avoid that, this CL binds VaapiWrapper
not as an unretained, but holding a ref to it, preventing it from
going out of scope too early and the crash.  This kind of late
destruction happens when we have VideoFrames in flight that are
released after e.g. VaapiVDA and its VaapiWrapper are destroyed.

Create...() is called from VaapiPictureNativePixmapOzone's
Allocate() and ImportGpuMemoryBufferHandle(), callsites [1] and [2].

Also a bit of a cleanup:
- Removes unused variable |fds|
- Uses designated initialization for |va_attrib_extbuf|, which also
 avoids a memset() and also initializes other fields to their default
 values (== zero for integer variables), which allows for DCHECK()ing
 instead of assignment.


Test: v_d_a_unittests h264/vp8/vp9 on nocturne.
Bug: 920058
Change-Id: I117298008b1b689e61663a30f8653f1942d7d4de
Commit-Queue: Miguel Casas <>
Reviewed-by: Andres Calderon Jaramillo <>
Reviewed-by: Hirokazu Honda <>
Cr-Commit-Position: refs/heads/master@{#661895}
1 file changed