From 15b2cd6565afd8613660f5d79ebe90b037904aa5 Mon Sep 17 00:00:00 2001 From: Seungha Yang Date: Thu, 22 Dec 2022 00:22:46 +0900 Subject: [PATCH] cudabasetransform: Update CUDA stream on context update CUDA stream must be associated with updated CUDA context Part-of: --- .../sys/nvcodec/gstcudabasetransform.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/subprojects/gst-plugins-bad/sys/nvcodec/gstcudabasetransform.c b/subprojects/gst-plugins-bad/sys/nvcodec/gstcudabasetransform.c index 1200d18a58..4161e4a28d 100644 --- a/subprojects/gst-plugins-bad/sys/nvcodec/gstcudabasetransform.c +++ b/subprojects/gst-plugins-bad/sys/nvcodec/gstcudabasetransform.c @@ -340,9 +340,20 @@ gst_cuda_base_transform_before_transform (GstBaseTransform * trans, GST_INFO_OBJECT (self, "Updating device %" GST_PTR_FORMAT " -> %" GST_PTR_FORMAT, self->context, cmem->context); + if (self->cuda_stream) { + gst_cuda_context_push (self->context); + CuStreamDestroy (self->cuda_stream); + gst_cuda_context_pop (NULL); + self->cuda_stream = NULL; + } + gst_object_unref (self->context); self->context = gst_object_ref (cmem->context); + gst_cuda_context_push (self->context); + CuStreamCreate (&self->cuda_stream, CU_STREAM_DEFAULT); + gst_cuda_context_pop (NULL); + /* subclass will update internal object. * Note that gst_base_transform_reconfigure() might not trigger this * unless caps was changed meanwhile */