Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion msgq/visionipc/visionipc_pyx.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ cdef class CLContext:

cdef class VisionBuf:
cdef cppVisionBuf * buf
cdef object _owner

@staticmethod
cdef create(cppVisionBuf*)
cdef create(cppVisionBuf*, object)
8 changes: 6 additions & 2 deletions msgq/visionipc/visionipc_pyx.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,15 @@ cpdef enum VisionStreamType:

cdef class VisionBuf:
@staticmethod
cdef create(cppVisionBuf * cbuf):
cdef create(cppVisionBuf * cbuf, object owner):
buf = VisionBuf()
buf.buf = cbuf
buf._owner = owner # Keep a reference to the owner to manage lifetime
return buf

def __dealloc__(self):
self._owner = None # Explicitly release the reference

@property
def data(self):
return np.asarray(<cnp.uint8_t[:self.buf.len]> self.buf.addr)
Expand Down Expand Up @@ -155,7 +159,7 @@ cdef class VisionIpcClient:
buf = self.client.recv(&self.extra, timeout_ms)
if not buf:
return None
return VisionBuf.create(buf)
return VisionBuf.create(buf, self)

def connect(self, bool blocking):
return self.client.connect(blocking)
Expand Down
Loading