Skip to content

Commit

Permalink
Add TODO to remove API-level data padding
Browse files Browse the repository at this point in the history
- The proposed specification changes that will remove this required
alignment step in oni_read_frame are here
open-ephys/ONI#3
  • Loading branch information
jonnew committed Jan 2, 2024
1 parent de82a1a commit c485f94
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion api/liboni/oni.c
Original file line number Diff line number Diff line change
Expand Up @@ -667,16 +667,19 @@ int oni_read_frame(const oni_ctx ctx, oni_frame_t **frame)
assert(iframe->private.f.data_sz > 0 && "Zero-sized frame");
assert(iframe->private.f.data_sz <= ctx->max_read_frame_size && "Invalid frame size");

// TODO: max_read_frame_size contains the header as well so the upper bound
// check is too relaxed.
if (iframe->private.f.data_sz == 0
|| iframe->private.f.data_sz > ctx->max_read_frame_size)
return ONI_EBADFRAME;

// Find read size (+ padding)
// TODO:https://github.com/open-ephys/ONI/issues/3
size_t rsize = iframe->private.f.data_sz;
rsize += rsize % sizeof(oni_fifo_dat_t);
total_size += rsize;

// Read data
// Direct frame data's view into the pre-collected buffer
rc = _oni_read_buffer(ctx, (void **)&iframe->private.f.data, rsize, 0);
if (rc) return rc;

Expand Down

0 comments on commit c485f94

Please sign in to comment.