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.

[1] https://cs.chromium.org/chromium/src/media/gpu/vaapi/vaapi_video_decode_accelerator.cc?type=cs&q=picture-%3EAllocate%5C(+file:%5Esrc/media/gpu/vaapi/+package:%5Echromium$&g=0&l=657
[2] https://cs.chromium.org/search/?q=picture-%3EImportGpuMemoryBufferHandle%5C(+file:%5Esrc/media/gpu/vaapi/+package:%5Echromium$&type=cs

Test: v_d_a_unittests h264/vp8/vp9 on nocturne.
Bug: 920058
Change-Id: I117298008b1b689e61663a30f8653f1942d7d4de
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1620509
Commit-Queue: Miguel Casas <mcasas@chromium.org>
Reviewed-by: Andres Calderon Jaramillo <andrescj@chromium.org>
Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#661895}
1 file changed