diff --git a/src/xpra/codecs/nvenc4/encoder.pyx b/src/xpra/codecs/nvenc4/encoder.pyx index daaf4ffe8d..84084434d2 100644 --- a/src/xpra/codecs/nvenc4/encoder.pyx +++ b/src/xpra/codecs/nvenc4/encoder.pyx @@ -2301,6 +2301,7 @@ cdef class Encoder: pstr = cstr[:sizeof(NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS)] if DEBUG_API: log("calling nvEncOpenEncodeSessionEx @ %#x", self.functionList.nvEncOpenEncodeSessionEx) + self.context = NULL with nogil: r = self.functionList.nvEncOpenEncodeSessionEx(¶ms, &self.context) if r==NV_ENC_ERR_UNSUPPORTED_DEVICE: @@ -2309,6 +2310,8 @@ cdef class Encoder: log(msg) raise TransientCodecException(msg) raiseNVENC(r, "opening session") + if self.context==NULL: + raise Exception("cannot open encoding session, context is NULL") context_counter.increase() context_gen_counter.increase() log("success, encoder context=%#x (%s context%s in use)", self.context, context_counter, engs(context_counter)) diff --git a/src/xpra/codecs/nvenc5/encoder.pyx b/src/xpra/codecs/nvenc5/encoder.pyx index b031ddcd8c..24e91c73e3 100644 --- a/src/xpra/codecs/nvenc5/encoder.pyx +++ b/src/xpra/codecs/nvenc5/encoder.pyx @@ -2337,6 +2337,7 @@ cdef class Encoder: pstr = cstr[:sizeof(NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS)] if DEBUG_API: log("calling nvEncOpenEncodeSessionEx @ %#x", self.functionList.nvEncOpenEncodeSessionEx) + self.context = NULL with nogil: r = self.functionList.nvEncOpenEncodeSessionEx(¶ms, &self.context) if r==NV_ENC_ERR_UNSUPPORTED_DEVICE: @@ -2344,6 +2345,8 @@ cdef class Encoder: msg = "NV_ENC_ERR_UNSUPPORTED_DEVICE: could not open encode session (out of resources / no more codec contexts?)" log(msg) raise TransientCodecException(msg) + if self.context==NULL: + raise Exception("cannot open encoding session, context is NULL") raiseNVENC(r, "opening session") context_counter.increase() context_gen_counter.increase() diff --git a/src/xpra/codecs/nvenc6/encoder.pyx b/src/xpra/codecs/nvenc6/encoder.pyx index e7fc0ede60..9efc911485 100644 --- a/src/xpra/codecs/nvenc6/encoder.pyx +++ b/src/xpra/codecs/nvenc6/encoder.pyx @@ -2378,6 +2378,7 @@ cdef class Encoder: pstr = cstr[:sizeof(NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS)] if DEBUG_API: log("calling nvEncOpenEncodeSessionEx @ %#x", self.functionList.nvEncOpenEncodeSessionEx) + self.context = NULL with nogil: r = self.functionList.nvEncOpenEncodeSessionEx(¶ms, &self.context) if r==NV_ENC_ERR_UNSUPPORTED_DEVICE: @@ -2385,6 +2386,8 @@ cdef class Encoder: msg = "NV_ENC_ERR_UNSUPPORTED_DEVICE: could not open encode session (out of resources / no more codec contexts?)" log(msg) raise TransientCodecException(msg) + if self.context==NULL: + raise Exception("cannot open encoding session, context is NULL") raiseNVENC(r, "opening session") context_counter.increase() context_gen_counter.increase()