1919from cython .cimports .dlpack import DLManagedTensor , kDLCPU , kDLCUDA , kDLUInt
2020from cython .cimports .libc .stdint import int64_t , uint8_t
2121
22- import av ._hwdevice_registry as _hwreg
23-
2422
2523@cython .cclass
2624class CudaContext :
2725 def __cinit__ (self , device_id = 0 , primary_ctx = True ):
28- self .device_id = int (device_id )
29- self .primary_ctx = bool (primary_ctx )
26+ self ._device_id = int (device_id )
27+ self ._primary_ctx = bool (primary_ctx )
3028 self ._device_ref = cython .NULL
3129 self ._frames_cache = {}
3230
@@ -46,6 +44,14 @@ def __dealloc__(self):
4644 lib .av_buffer_unref (cython .address (ref ))
4745 self ._device_ref = cython .NULL
4846
47+ @property
48+ def device_id (self ) -> int :
49+ return self ._device_id
50+
51+ @property
52+ def primary_ctx (self ) -> bool :
53+ return self ._primary_ctx
54+
4955 @cython .cfunc
5056 def _get_device_ref (self ) -> cython .pointer [lib .AVBufferRef ]:
5157 device_ref : cython .pointer [lib .AVBufferRef ] = self ._device_ref
@@ -69,11 +75,6 @@ def _get_device_ref(self) -> cython.pointer[lib.AVBufferRef]:
6975 )
7076 )
7177
72- _hwreg .register_cuda_hwdevice_data_ptr (
73- cython .cast (cython .size_t , device_ref .data ),
74- self .device_id ,
75- )
76-
7778 self ._device_ref = device_ref
7879 return device_ref
7980
@@ -425,6 +426,10 @@ def __repr__(self):
425426 f"{ self .width } x{ self .height } at 0x{ id (self ):x} >"
426427 )
427428
429+ @property
430+ def device_id (self ) -> int :
431+ return self ._device_id
432+
428433 @property
429434 def planes (self ):
430435 """
0 commit comments