mirror of
https://github.com/commaai/msgq.git
synced 2026-06-08 05:54:44 +08:00
fix that
This commit is contained in:
@@ -53,7 +53,7 @@ cdef extern from "msgq/visionipc/visionipc_client.h":
|
||||
cdef cppclass VisionIpcClient:
|
||||
int num_buffers
|
||||
VisionBuf buffers[1]
|
||||
VisionIpcClient(string, VisionStreamType, bool)
|
||||
VisionIpcClient(string, VisionStreamType, bool, cl_device_id, cl_context)
|
||||
VisionBuf * recv(VisionIpcBufExtra *, int)
|
||||
bool connect(bool)
|
||||
bool is_connected()
|
||||
|
||||
@@ -22,7 +22,7 @@ static int connect_to_vipc_server(const std::string &name, bool blocking) {
|
||||
return socket_fd;
|
||||
}
|
||||
|
||||
VisionIpcClient::VisionIpcClient(std::string name_, VisionStreamType type_, bool conflate) : name(name_), type(type_) {
|
||||
VisionIpcClient::VisionIpcClient(std::string name_, VisionStreamType type_, bool conflate, cl_device_id device_id, cl_context ctx) : name(name_), type(type_), device_id(device_id), ctx(ctx) {
|
||||
msg_ctx = Context::create();
|
||||
sock = SubSocket::create(msg_ctx, get_endpoint_name(name, type), "127.0.0.1", conflate, false);
|
||||
|
||||
@@ -71,6 +71,8 @@ bool VisionIpcClient::connect(bool blocking) {
|
||||
buffers[i].fd = fds[i];
|
||||
buffers[i].import();
|
||||
buffers[i].init_yuv(buffers[i].width, buffers[i].height, buffers[i].stride, buffers[i].uv_offset);
|
||||
|
||||
if (device_id) buffers[i].init_cl(device_id, ctx);
|
||||
}
|
||||
|
||||
close(socket_fd);
|
||||
|
||||
@@ -19,7 +19,9 @@ public:
|
||||
VisionStreamType type;
|
||||
int num_buffers = 0;
|
||||
VisionBuf buffers[VISIONIPC_MAX_FDS];
|
||||
VisionIpcClient(std::string name, VisionStreamType type, bool conflate);
|
||||
cl_device_id device_id = nullptr;
|
||||
cl_context ctx = nullptr;
|
||||
VisionIpcClient(std::string name, VisionStreamType type, bool conflate, cl_device_id device_id=nullptr, cl_context ctx=nullptr);
|
||||
~VisionIpcClient();
|
||||
VisionBuf * recv(VisionIpcBufExtra * extra=nullptr, const int timeout_ms=100);
|
||||
bool connect(bool blocking=true);
|
||||
|
||||
@@ -15,6 +15,7 @@ from .visionipc cimport VisionIpcClient as cppVisionIpcClient
|
||||
from .visionipc cimport VisionBuf as cppVisionBuf
|
||||
from .visionipc cimport VisionIpcBufExtra
|
||||
from .visionipc cimport get_endpoint_name as cpp_get_endpoint_name
|
||||
from .visionipc cimport cl_device_id, cl_context
|
||||
|
||||
|
||||
def get_endpoint_name(string name, VisionStreamType stream):
|
||||
@@ -64,6 +65,10 @@ cdef class VisionBuf:
|
||||
return self.buf.fd
|
||||
|
||||
|
||||
cdef class CLContext:
|
||||
pass
|
||||
|
||||
|
||||
cdef class VisionIpcServer:
|
||||
cdef cppVisionIpcServer * server
|
||||
|
||||
@@ -102,8 +107,11 @@ cdef class VisionIpcClient:
|
||||
cdef cppVisionIpcClient * client
|
||||
cdef VisionIpcBufExtra extra
|
||||
|
||||
def __cinit__(self, string name, VisionStreamType stream, bool conflate):
|
||||
self.client = new cppVisionIpcClient(name, stream, conflate)
|
||||
def __cinit__(self, string name, VisionStreamType stream, bool conflate, CLContext context=None):
|
||||
if context is not None:
|
||||
self.client = new cppVisionIpcClient(name, stream, conflate, context.device_id, context.context)
|
||||
else:
|
||||
self.client = new cppVisionIpcClient(name, stream, conflate, NULL, NULL)
|
||||
|
||||
def __dealloc__(self):
|
||||
del self.client
|
||||
|
||||
Reference in New Issue
Block a user