XTOS / OPEN SOURCE REAL-TIME SYSTEMOPEN SOURCE · VERSION 0.9.0 · BUILD FROM SOURCE
libxtos-bcixtos_bci_get_mmap_buffer

xtos_bci_get_mmap_buffer

Estimates a mapping length from cached channels and rate, then returns a read-only shared mmap address.

On this page

Declaration

c
#include <xtos/bci.h>

void *xtos_bci_get_mmap_buffer(xtos_bci_session_t *session, size_t *size);

Parameters

ParameterTypeDescription
sessionxtos_bci_session_t *Non-NULL session handle; the session owns the mapping.
sizesize_t *May be NULL; when non-NULL, receives the mapping byte count on success.

Return value

Returns a borrowed mapping address on success; returns NULL with errno on failure. size is not guaranteed written on failure.

Errors

errnoCondition
EINVALsession is NULL, or cached information produces a mapping length of zero.
ENOMEM/EACCESmmap cannot establish the mapping or device permission is insufficient.
system errnoPreserves errno from mmap failure.

Notes

  • The first call estimates channels×sampling_rate×sizeof(float)×2; later calls return the cached address without recalculation. If GET_INFO failed, cached fields remain zero and the estimated length may be 0, causing mmap to fail; callers must verify cached info before requesting the mapping.
  • The public implementation performs several size_t multiplications without explicit overflow checks; callers should validate channel count, sampling rate, and the product range first.
  • The mapping uses PROT_READ|MAP_SHARED and is unmapped by destroy; callers must not free or munmap it.
  • The public interface provides no write/read position, stable snapshot, or consumer-advance protocol; a pointer alone is not complete zero-copy consumption.

Example

Source

This reference describes headers and implementation at OpenXTOS commit dd313955ad57542bcd2af8827157d1bbd0cf5e83.