8#ifndef __LIBDRAGON_SAMPLEBUFFER_H
9#define __LIBDRAGON_SAMPLEBUFFER_H
30#define SAMPLES_BPS_SHIFT(buf) ((buf)->ptr_and_flags & 3)
37#define SAMPLES_PTR(buf) (void*)((buf)->ptr_and_flags ^ SAMPLES_BPS_SHIFT(buf))
43#define SAMPLES_PTR_MAKE(ptr, bps) ((sample_ptr_t)(ptr) | (bps))
83typedef 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:419
void * samplebuffer_append(samplebuffer_t *buf, int wlen)
Append samples into the buffer (zero-copy).
Definition samplebuffer.c:149
int size
Definition samplebuffer.h:92
void samplebuffer_close(samplebuffer_t *buf)
Definition samplebuffer.c:63
bool samplebuffer_is_inited(samplebuffer_t *buf)
Return true if the samplebuffer is initialized.
Definition samplebuffer.c:58
sample_ptr_t ptr_and_flags
Definition samplebuffer.h:87
int wpos
Definition samplebuffer.h:99
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:70
int ridx
Definition samplebuffer.h:114
WaveformRead wv_read
Definition samplebuffer.h:127
void samplebuffer_set_bps(samplebuffer_t *buf, int bps)
Configure the bit width of the samples stored in the buffer.
Definition samplebuffer.c:41
int wnext
Definition samplebuffer.h:121
void samplebuffer_undo(samplebuffer_t *buf, int wlen)
Remove the a specified number of samples from the tail of the buffer.
Definition samplebuffer.c:186
void * wv_ctx
Definition samplebuffer.h:132
int widx
Definition samplebuffer.h:106
void samplebuffer_init(samplebuffer_t *buf, uint8_t *uncached_mem, int size)
Definition samplebuffer.c:27
void samplebuffer_set_waveform(samplebuffer_t *buf, WaveformRead read, void *ctx)
Definition samplebuffer.c:53
void samplebuffer_flush(samplebuffer_t *buf)
Definition samplebuffer.c:243
uint32_t sample_ptr_t
Definition samplebuffer.h:22
void samplebuffer_discard(samplebuffer_t *buf, int wpos)
Definition samplebuffer.c:191
Definition samplebuffer.h:83
int read(int fileno, char *ptr, int len)
Read data from a file.
Definition system.c:928