afile
struct afile *fp, *list, *listp = NULL;
struct afile single;
list = calloc(entries, sizeof(struct afile));
qsort((char *)list, entries, sizeof(struct afile), fcmp);
mkentry(char *name, struct direct *dp, struct afile *fp)
formatf(struct afile *list, int nentry)
struct afile *fp, *endlist;
return (strcmp(((struct afile *)f1)->fname,
((struct afile *)f2)->fname));
static void formatf(struct afile *, int);
static void mkentry(char *, struct direct *, struct afile *);
afile_readhdr(struct afile *f, void *addr, size_t size)
afile_writehdr(struct afile *f, void *addr, size_t size)
afile_checkpar(struct afile *f)
afile_wav_readfmt(struct afile *f, unsigned int csize)
afile_wav_readhdr(struct afile *f)
afile_wav_writehdr(struct afile *f)
afile_aiff_readcomm(struct afile *f, unsigned int csize,
afile_aiff_readdata(struct afile *f, unsigned int csize, unsigned int *roffs)
afile_aiff_readhdr(struct afile *f)
afile_aiff_writehdr(struct afile *f)
afile_au_readhdr(struct afile *f)
afile_au_writehdr(struct afile *f)
afile_read(struct afile *f, void *data, size_t count)
afile_write(struct afile *f, void *data, size_t count)
afile_seek(struct afile *f, off_t pos)
afile_close(struct afile *f)
afile_open(struct afile *f, char *path, int hdr, int flags,
int afile_open(struct afile *, char *, int, int, struct aparams *, int, int);
size_t afile_read(struct afile *, void *, size_t);
size_t afile_write(struct afile *, void *, size_t);
int afile_seek(struct afile *, off_t);
void afile_close(struct afile *);
switch (s->afile.fmt) {
aparams_enctostr(&s->afile.par, enc);
s->afile.nch, s->imin, s->imax, s->omin, s->omax,
s->afile.rate, enc);
if (s->afile.endpos >= 0) {
(long long)s->afile.startpos,
(long long)s->afile.endpos);
n = afile_write(&s->afile, data, count);
logx(1, "%s: can't write, disabled", s->afile.path);
n = afile_read(&s->afile, data, count);
logx(3, "%s: eof reached, stopping", s->afile.path);
if (!afile_open(&s->afile, path, hdr,
s->imax = (imax != -1) ? imax : s->imin + s->afile.nch - 1;
s->omax = (omax != -1) ? omax : s->omin + s->afile.nch - 1;
logx(2, "%s: %s", s->afile.path, (slot_fmt(str, sizeof(str), s), str));
logx(1, "%s: slot_init: wrong state", s->afile.path);
s->bpf = s->afile.par.bps * s->afile.nch;
s->round = ((long long)dev_round * s->afile.rate +
logx(3, "%s: allocated %u frame buffer", s->afile.path, bufsz);
0, s->afile.nch - 1, s->imin, s->imax,
if (s->afile.fmt != AFILE_FMT_PCM ||
!aparams_native(&s->afile.par)) {
dec_init(&s->conv, &s->afile.par, s->afile.nch);
s->convbuf = allocbuf(s->round, s->afile.nch, sizeof(adata_t));
if (s->afile.rate != dev_rate) {
resamp_init(&s->resamp, s->afile.rate, dev_rate,
s->afile.nch);
s->resampbuf = allocbuf(dev_round, s->afile.nch, sizeof(adata_t));
0, s->afile.nch - 1, s->omin, s->omax, s->dup);
if (s->afile.rate != dev_rate) {
resamp_init(&s->resamp, dev_rate, s->afile.rate,
s->afile.nch);
s->resampbuf = allocbuf(dev_round, s->afile.nch, sizeof(adata_t));
if (!aparams_native(&s->afile.par)) {
enc_init(&s->conv, &s->afile.par, s->afile.nch);
s->convbuf = allocbuf(s->round, s->afile.nch, sizeof(adata_t));
dev_round * s->afile.nch * sizeof(adata_t));
s->round * s->afile.nch * sizeof(adata_t));
bufsz * s->afile.nch * sizeof(adata_t));
logx(3, "%s: chain initialized", s->afile.path);
logx(1, "%s: slot_start: wrong state", s->afile.path);
pos = pos * s->afile.rate / dev_rate;
if (!afile_seek(&s->afile, pos * s->bpf)) {
logx(2, "%s: started", s->afile.path);
logx(2, "%s: stopped", s->afile.path);
afile_close(&s->afile);
logx(3, "%s: closed", s->afile.path);
switch (s->afile.fmt) {
if (s->afile.rate > rate)
rate = s->afile.rate;
logx(3, "%s: volume set to %u", s->afile.path, val);
logx(3, "%s: drained, done", s->afile.path);
struct afile afile; /* file desc & friends */
if (s->afile.rate > rate)
rate = s->afile.rate;