diff --git a/video.c b/video.c index 96aa8eb..875b03b 100644 --- a/video.c +++ b/video.c @@ -1764,12 +1764,13 @@ static void CuvidDestroySurfaces(CuvidDecoder * decoder) glXMakeCurrent(XlibDisplay, VideoWindow, GlxContext); GlxCheck(); - - for (i=0;iSurfacesNeeded;i++) { - for (j=0;j<2;j++) { - if (decoder->cu_res[i][j]) { - checkCudaErrors(cuGraphicsUnregisterResource(decoder->cu_res[i][j])); - decoder->cu_res[i][j] = 0; + if (decoder->cuda_ctx) { + for (i=0;iSurfacesNeeded;i++) { + for (j=0;j<2;j++) { + if (decoder->cu_res[i][j]) { + checkCudaErrors(cuGraphicsUnregisterResource(decoder->cu_res[i][j])); + decoder->cu_res[i][j] = 0; + } } } }