7#ifndef __LIBDRAGON_SAMPLEBUFFER_H
8#define __LIBDRAGON_SAMPLEBUFFER_H
29#define SAMPLES_BPS_SHIFT(buf) ((buf)->ptr_and_flags & 3)
36#define SAMPLES_PTR(buf) (void*)((buf)->ptr_and_flags ^ SAMPLES_BPS_SHIFT(buf))
42#define SAMPLES_PTR_MAKE(ptr, bps) ((sample_ptr_t)(ptr) | (bps))
82typedef struct samplebuffer_s {
void(* WaveformRead)(void *ctx, samplebuffer_t *sbuf, int wpos, int wlen, bool seeking)
Waveform callback function invoked by the mixer to read/generate samples.
Definition mixer.h:418
void * samplebuffer_append(samplebuffer_t *buf, int wlen)
Append samples into the buffer (zero-copy).
Definition samplebuffer.c:140
int size
Definition samplebuffer.h:91
void samplebuffer_close(samplebuffer_t *buf)
Definition samplebuffer.c:57
sample_ptr_t ptr_and_flags
Definition samplebuffer.h:86
int wpos
Definition samplebuffer.h:98
void * samplebuffer_get(samplebuffer_t *buf, int wpos, int *wlen)
Get a pointer to specific set of samples in the buffer (zero-copy).
Definition samplebuffer.c:61
int ridx
Definition samplebuffer.h:113
WaveformRead wv_read
Definition samplebuffer.h:126
void samplebuffer_set_bps(samplebuffer_t *buf, int bps)
Configure the bit width of the samples stored in the buffer.
Definition samplebuffer.c:40
int wnext
Definition samplebuffer.h:120
void * wv_ctx
Definition samplebuffer.h:131
int widx
Definition samplebuffer.h:105
void samplebuffer_init(samplebuffer_t *buf, uint8_t *uncached_mem, int size)
Definition samplebuffer.c:26
void samplebuffer_set_waveform(samplebuffer_t *buf, WaveformRead read, void *ctx)
Definition samplebuffer.c:52
void samplebuffer_flush(samplebuffer_t *buf)
Definition samplebuffer.c:229
uint32_t sample_ptr_t
Definition samplebuffer.h:21
void samplebuffer_discard(samplebuffer_t *buf, int wpos)
Definition samplebuffer.c:177
Definition samplebuffer.h:82
int read(int fileno, char *ptr, int len)
Read data from a file.
Definition system.c:927