vaapiencoder: Surface concurrency issues, failed to encode frame due to 'surface in use'
Submitted by Myles Inglis
Created attachment 373971
Add lock to gstvaapisurface patch
It seems that gstreamer-vaapi currently does not synchronise access to the vaapi surfaces correctly.
Attempting to use a VASurface while it is mapped (with vaMapBuffer) results in a surface is in use error from vaapi. This was causing an issue for us where one branch of the pipeline would map a GstBuffer and another branch of the pipeline would attempt to encode the buffer with the vaapiencoder while it is mapped. The result is that gstvaapiencoder fails to encode the buffer, and the whole pipeline is stopped.
I've attached the patch we have used to fix the issue. This adds a mutex to gstvaapisurface that is used to correctly synchronise access.
We're using a slightly older version of gstreamer but it doesn't seem like this has changed in the latest master.
Patch 373971, "Add lock to gstvaapisurface patch":