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

xtos_spsc_create

Creates a fixed-capacity single-producer, single-consumer sample-frame queue.

On this page

Declaration

c
#include <xtos/spsc.h>

struct xtos_spsc_queue *xtos_spsc_create(size_t capacity, uint32_t channels);

Parameters

ParameterTypeDescription
capacitysize_tNumber of complete frames the queue can store; greater than zero and not a byte count.
channelsuint32_tChannels per frame, greater than zero; each slot allocates this many int32 samples.

Return value

Returns an opaque queue pointer on success, or NULL with errno on failure. The caller destroys the queue.

Errors

errnoCondition
EINVALcapacity or channels is zero.
ENOMEMAllocation failed for the queue, slots, or slot samples.

Notes

  • Creation and destruction allocate or free heap memory; push/pop do not allocate during operation. The public implementation has no explicit overflow limit for capacity×slot storage or channels×sizeof(int32_t); applications should use validated, reasonable capacities and channel counts.
  • Exactly one producer must call push and one consumer must call pop; both endpoints must stop before destruction.

Example

Source

This reference describes headers and implementation at OpenXTOS commit dd313955ad57542bcd2af8827157d1bbd0cf5e83.