#define SNDBUF_F_MANAGED 0x00000001
#define SNDBUF_NAMELEN 48
struct snd_dbuf {
u_int8_t *buf, *tmpbuf;
u_int8_t *shadbuf;
volatile int sl;
unsigned int bufsize, maxsize, allocsize;
volatile int dl;
volatile int rp;
volatile int rl;
volatile int hp;
volatile u_int64_t total, prev_total;
int dmachan;
u_int32_t fmt, spd, bps, align;
unsigned int blksz, blkcnt;
int xrun;
u_int32_t flags;
bus_dmamap_t dmamap;
bus_dma_tag_t dmatag;
bus_addr_t buf_addr;
int dmaflags;
struct selinfo sel;
struct pcm_channel *channel;
char name[SNDBUF_NAMELEN];
};
struct snd_dbuf *sndbuf_create(struct pcm_channel *channel, const char *desc);
void sndbuf_destroy(struct snd_dbuf *b);
int sndbuf_alloc(struct snd_dbuf *b, bus_dma_tag_t dmatag, int dmaflags, unsigned int size);
int sndbuf_setup(struct snd_dbuf *b, void *buf, unsigned int size);
void sndbuf_free(struct snd_dbuf *b);
int sndbuf_resize(struct snd_dbuf *b, unsigned int blkcnt, unsigned int blksz);
int sndbuf_remalloc(struct snd_dbuf *b, unsigned int blkcnt, unsigned int blksz);
void sndbuf_reset(struct snd_dbuf *b);
void sndbuf_clear(struct snd_dbuf *b, unsigned int length);
void sndbuf_fillsilence(struct snd_dbuf *b);
void sndbuf_fillsilence_rl(struct snd_dbuf *b, u_int rl);
void sndbuf_softreset(struct snd_dbuf *b);
void sndbuf_clearshadow(struct snd_dbuf *b);
int sndbuf_setfmt(struct snd_dbuf *b, u_int32_t fmt);
void sndbuf_setspd(struct snd_dbuf *b, unsigned int spd);
void *sndbuf_getbufofs(struct snd_dbuf *b, unsigned int ofs);
unsigned int sndbuf_runsz(struct snd_dbuf *b);
void sndbuf_setrun(struct snd_dbuf *b, int go);
void sndbuf_setxrun(struct snd_dbuf *b, unsigned int xrun);
unsigned int sndbuf_getfree(struct snd_dbuf *b);
unsigned int sndbuf_getfreeptr(struct snd_dbuf *b);
unsigned int sndbuf_getready(struct snd_dbuf *b);
unsigned int sndbuf_getreadyptr(struct snd_dbuf *b);
u_int64_t sndbuf_getblocks(struct snd_dbuf *b);
unsigned int sndbuf_xbytes(unsigned int v, struct snd_dbuf *from, struct snd_dbuf *to);
u_int8_t sndbuf_zerodata(u_int32_t fmt);
int sndbuf_acquire(struct snd_dbuf *b, u_int8_t *from, unsigned int count);
int sndbuf_dispose(struct snd_dbuf *b, u_int8_t *to, unsigned int count);
int sndbuf_feed(struct snd_dbuf *from, struct snd_dbuf *to, struct pcm_channel *channel, struct pcm_feeder *feeder, unsigned int count);
#ifdef OSSV4_EXPERIMENT
void sndbuf_getpeaks(struct snd_dbuf *b, int *lp, int *rp);
#endif
static inline u_int32_t
snd_xbytes(u_int32_t v, u_int32_t from, u_int32_t to)
{
if (from == to)
return (v);
if (from == 0)
return (0);
return ((u_int64_t)v * to / from);
}