Skip to content

Commit

Permalink
visionipc: get arbitrary buffers from server (commaai#633)
Browse files Browse the repository at this point in the history
  • Loading branch information
adeebshihadeh authored Oct 12, 2024
1 parent b4f0692 commit 3e17f86
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions msgq/visionipc/visionipc_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand Down
2 changes: 1 addition & 1 deletion msgq/visionipc/visionipc_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 3e17f86

Please sign in to comment.