Skip to content

Commit a3b51b3

Browse files
committed
visionipc: get arbitrary buffers from server
1 parent b4f0692 commit a3b51b3

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

msgq/visionipc/visionipc_server.cc

+8-2
Original file line numberDiff line numberDiff line change
@@ -160,11 +160,17 @@ void VisionIpcServer::listener(){
160160

161161

162162

163-
VisionBuf * VisionIpcServer::get_buffer(VisionStreamType type){
163+
VisionBuf * VisionIpcServer::get_buffer(VisionStreamType type, int idx){
164164
// Do we want to keep track if the buffer has been sent out yet and warn user?
165165
assert(buffers.count(type));
166166
auto b = buffers[type];
167-
return b[cur_idx[type]++ % b.size()];
167+
if (idx < 0) {
168+
idx = cur_idx[type]++ % b.size();
169+
} else {
170+
assert(idx < b.size() && idx >= 0);
171+
cur_idx[type] = idx;
172+
}
173+
return b[idx];
168174
}
169175

170176
void VisionIpcServer::send(VisionBuf * buf, VisionIpcBufExtra * extra, bool sync){

msgq/visionipc/visionipc_server.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class VisionIpcServer {
3333
VisionIpcServer(std::string name, cl_device_id device_id=nullptr, cl_context ctx=nullptr);
3434
~VisionIpcServer();
3535

36-
VisionBuf * get_buffer(VisionStreamType type);
36+
VisionBuf * get_buffer(VisionStreamType type, int idx = -1);
3737

3838
void create_buffers(VisionStreamType type, size_t num_buffers, size_t width, size_t height);
3939
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);

0 commit comments

Comments
 (0)