visionipc: get arbitrary buffers from server (#633)

This commit is contained in:
Adeeb Shihadeh 2024-10-12 11:01:41 -07:00 committed by GitHub
parent b4f0692c1a
commit 3e17f865bb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 3 deletions

View File

@ -160,11 +160,17 @@ void VisionIpcServer::listener(){
VisionBuf * VisionIpcServer::get_buffer(VisionStreamType type){
VisionBuf * VisionIpcServer::get_buffer(VisionStreamType type, int idx){
// Do we want to keep track if the buffer has been sent out yet and warn user?
assert(buffers.count(type));
auto b = buffers[type];
return b[cur_idx[type]++ % b.size()];
if (idx < 0) {
idx = cur_idx[type]++ % b.size();
} else {
assert(idx < b.size() && idx >= 0);
cur_idx[type] = idx;
}
return b[idx];
}
void VisionIpcServer::send(VisionBuf * buf, VisionIpcBufExtra * extra, bool sync){

View File

@ -33,7 +33,7 @@ class VisionIpcServer {
VisionIpcServer(std::string name, cl_device_id device_id=nullptr, cl_context ctx=nullptr);
~VisionIpcServer();
VisionBuf * get_buffer(VisionStreamType type);
VisionBuf * get_buffer(VisionStreamType type, int idx = -1);
void create_buffers(VisionStreamType type, size_t num_buffers, size_t width, size_t height);
void create_buffers_with_sizes(VisionStreamType type, size_t num_buffers, size_t width, size_t height, size_t size, size_t stride, size_t uv_offset);