GstVaapiEncode needs a mutex to protect the encoder and maybe more
I'm not exactly sure what is needed. I noticed, that gst_vaapiencode_destroy()
races with other access to encode->encoder
and maybe the input and output state as well.
I've had crashes when gst_vaapiencode_push_frame()
tried to access the the encoder. I think that only happens because the pad task is restarted (see !8 (merged)).
And gst_vaapiencode_get_caps()
has a the same problem. It checks if the encoder exists at the beginning, but without mutex it can be deleted at any time. I've seen crashes here by starting and immediately stopping a pipeline in a loop. Getting the timing right is a bit tricky.
I don't know what exactly needs to be done here, and especially how to avoid deadlocks.