mirror of https://github.com/commaai/cereal.git
visionipc: get arbitrary buffers from server (#633)
This commit is contained in:
parent
b4f0692c1a
commit
3e17f865bb
|
@ -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){
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue