find_cuda_context doesn't find CUDA context
I am writing a CUDA kernel that processes video frames coming as OpenGL textures from glcolorconvert
. I understand that I must share CUDA context with GStreamer to achieve this goal. At least otherwise, a naive call to cudaGraphicsResourceGetMappedPointer
causes a seg fault.
I intercepted GST_MESSAGE_NEED_CONTEXT
posted on the bus and provided the context. However, I don't think it has any effect. When I look at find_cuda_context
from gstcudautils.cpp
it is supposed to use the context provided by the message handler, but I don't think it is correctly written. In particular,
find_cuda_context (GstElement * element, GstCudaContext ** cuda_ctx)
The found context is supposed to be returned in cuda_ctx
, but it's easy to see that *cuda_ctx
is not assigned any value in this function. Moreover, after posting the message, the code doesn't check if the context was assigned to GstElement
.