available method
Frames currently readable, given a write cursor read atomically by the caller. Unsigned wrap-safe: both cursors are monotonic frame counts, so their difference stays correct across a 2^32 wrap and there is no ambiguous full-vs-empty state to disambiguate with a loop flag.
Implementation
int available(int writeCursor) {
final r = header[MirrorHeader.readCursor];
final used = (writeCursor - r) & 0xFFFFFFFF;
// A producer that lapped us cannot hand back more than the ring holds.
return used > capacityFrames ? capacityFrames : used;
}