You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
1.1 KiB

#ifndef MUSUBI_AUDIO_RING_H
#define MUSUBI_AUDIO_RING_H
#include <stdint.h>
/// Lock-free single-producer/single-consumer ring of interleaved float frames.
/// Safe to use from a real-time audio thread: no locks, no allocation after creation.
typedef struct MusubiRing MusubiRing;
MusubiRing *_Nullable musubi_ring_create(uint32_t capacityFrames, uint32_t channels);
void musubi_ring_destroy(MusubiRing *_Nullable ring);
uint32_t musubi_ring_channels(const MusubiRing *_Nonnull ring);
uint32_t musubi_ring_capacity(const MusubiRing *_Nonnull ring);
/// Producer side. Writes up to `frames` frames, returns how many fit.
uint32_t musubi_ring_write(MusubiRing *_Nonnull ring, const float *_Nonnull interleaved, uint32_t frames);
/// Consumer side. Reads up to `frames` frames, returns how many were read.
uint32_t musubi_ring_read(MusubiRing *_Nonnull ring, float *_Nonnull interleaved, uint32_t frames);
/// Consumer side. Drops up to `frames` frames, returns how many were dropped.
uint32_t musubi_ring_skip(MusubiRing *_Nonnull ring, uint32_t frames);
/// Frames ready to read (either side).
uint32_t musubi_ring_available(const MusubiRing *_Nonnull ring);
#endif

Powered by TurnKey Linux.