I’m trying to write and read slices from the std.RingBuffer but I’m not understanding exactly how to do this and can’t find any examples.
This is the write side (thread 1)
var slice = iq[0 … num_smpls * defs.BYTES_PER_SAMPLE];
// Copy the IQ data into the ring buffer
rb.writeSlice(slice) catch |err| {
if (err == error.Full) {
std.debug.print(“IQ ring buffer full!\n”, .{});
}
};
and the read side (thread 2)
var rb_slice: std.RingBuffer.Slice = try rb.sliceAt(rb.read_index, sz);
iq_data = rb_slice.first + rb_slice.second;
The write side compiles but the read side gives this error.
error: expected error union type, found ‘RingBuffer.Slice’
I’m pretty sure this is way off correct as I don’t understand how to use the start_unmasked parameters.