xtos_ spsc_ create
Creates a fixed-capacity single-producer, single-consumer sample-frame queue.
On this page
Declaration
#include <xtos/spsc.h>
struct xtos_spsc_queue *xtos_spsc_create(size_t capacity, uint32_t channels);Parameters
| Parameter | Type | Description |
|---|---|---|
| capacity | size_t | Number of complete frames the queue can store; greater than zero and not a byte count. |
| channels | uint32_t | Channels 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
| errno | Condition |
|---|---|
| EINVAL | capacity or channels is zero. |
| ENOMEM | Allocation 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.