version 1.78, 2012/04/04 11:16:24 |
version 1.79, 2012/04/11 06:05:43 |
|
|
int devctl_open(struct dev *, struct devctl *); |
int devctl_open(struct dev *, struct devctl *); |
|
|
struct dev *dev_list = NULL; |
struct dev *dev_list = NULL; |
unsigned dev_sndnum = 0, dev_thrnum = 0; |
unsigned int dev_sndnum = 0, dev_thrnum = 0; |
|
|
#ifdef DEBUG |
#ifdef DEBUG |
void |
void |
|
|
* Create a sndio device |
* Create a sndio device |
*/ |
*/ |
struct dev * |
struct dev * |
dev_new(char *path, unsigned mode, |
dev_new(char *path, unsigned int mode, unsigned int bufsz, unsigned int round, |
unsigned bufsz, unsigned round, unsigned hold, unsigned autovol) |
unsigned int hold, unsigned int autovol) |
{ |
{ |
struct dev *d; |
struct dev *d; |
unsigned *pnum, i; |
unsigned int *pnum, i; |
|
|
pnum = (mode & MODE_THRU) ? &dev_thrnum : &dev_sndnum; |
pnum = (mode & MODE_THRU) ? &dev_thrnum : &dev_sndnum; |
if (*pnum == DEV_NMAX) { |
if (*pnum == DEV_NMAX) { |
|
|
* adjust device parameters and mode |
* adjust device parameters and mode |
*/ |
*/ |
void |
void |
dev_adjpar(struct dev *d, unsigned mode, |
dev_adjpar(struct dev *d, unsigned int mode, |
struct aparams *ipar, struct aparams *opar) |
struct aparams *ipar, struct aparams *opar) |
{ |
{ |
d->reqmode |= (mode | MODE_MIDIMASK); |
d->reqmode |= (mode | MODE_MIDIMASK); |
|
|
* Add a MIDI port to the device |
* Add a MIDI port to the device |
*/ |
*/ |
int |
int |
devctl_add(struct dev *d, char *path, unsigned mode) |
devctl_add(struct dev *d, char *path, unsigned int mode) |
{ |
{ |
struct devctl *c; |
struct devctl *c; |
|
|
|
|
struct aparams par; |
struct aparams par; |
struct aproc *conv; |
struct aproc *conv; |
struct abuf *buf; |
struct abuf *buf; |
unsigned siomode, cmin, cmax, rate; |
unsigned int siomode, cmin, cmax, rate; |
|
|
d->mode = d->reqmode; |
d->mode = d->reqmode; |
d->round = d->reqround; |
d->round = d->reqround; |
|
|
void |
void |
dev_drain(struct dev *d) |
dev_drain(struct dev *d) |
{ |
{ |
unsigned i; |
unsigned int i; |
struct ctl_slot *s; |
struct ctl_slot *s; |
|
|
for (i = 0, s = d->slot; i < CTL_NSLOT; i++, s++) { |
for (i = 0, s = d->slot; i < CTL_NSLOT; i++, s++) { |
|
|
} |
} |
} |
} |
|
|
unsigned |
unsigned int |
dev_roundof(struct dev *d, unsigned newrate) |
dev_roundof(struct dev *d, unsigned int newrate) |
{ |
{ |
return (d->round * newrate + d->rate / 2) / d->rate; |
return (d->round * newrate + d->rate / 2) / d->rate; |
} |
} |
|
|
*/ |
*/ |
int |
int |
dev_getep(struct dev *d, |
dev_getep(struct dev *d, |
unsigned mode, struct abuf **sibuf, struct abuf **sobuf) |
unsigned int mode, struct abuf **sibuf, struct abuf **sobuf) |
{ |
{ |
struct abuf *ibuf, *obuf; |
struct abuf *ibuf, *obuf; |
|
|
|
|
* them underruns/overruns). |
* them underruns/overruns). |
*/ |
*/ |
void |
void |
dev_sync(struct dev *d, unsigned mode, struct abuf *ibuf, struct abuf *obuf) |
dev_sync(struct dev *d, unsigned int mode, |
|
struct abuf *ibuf, struct abuf *obuf) |
{ |
{ |
int delta, offs; |
int delta, offs; |
struct abuf *mbuf = NULL; |
struct abuf *mbuf = NULL; |
|
|
* return the current latency (in frames), ie the latency that |
* return the current latency (in frames), ie the latency that |
* a stream would have if dev_attach() is called on it. |
* a stream would have if dev_attach() is called on it. |
* |
* |
* XXX: return a "unsigned", since result is always positive, isn't it? |
* XXX: return a "unsigned int", since result is always positive, isn't it? |
*/ |
*/ |
int |
int |
dev_getpos(struct dev *d) |
dev_getpos(struct dev *d) |
|
|
* and rec. |
* and rec. |
*/ |
*/ |
void |
void |
dev_attach(struct dev *d, char *name, unsigned mode, |
dev_attach(struct dev *d, char *name, unsigned int mode, |
struct abuf *ibuf, struct aparams *sipar, unsigned inch, |
struct abuf *ibuf, struct aparams *sipar, unsigned int inch, |
struct abuf *obuf, struct aparams *sopar, unsigned onch, |
struct abuf *obuf, struct aparams *sopar, unsigned int onch, |
unsigned xrun, int vol) |
unsigned int xrun, int vol) |
{ |
{ |
struct aparams ipar, opar; |
struct aparams ipar, opar; |
struct aproc *conv; |
struct aproc *conv; |
unsigned round, nblk, nch; |
unsigned int round, nblk, nch; |
|
|
#ifdef DEBUG |
#ifdef DEBUG |
if ((!APROC_OK(d->mix) && (mode & MODE_PLAY)) || |
if ((!APROC_OK(d->mix) && (mode & MODE_PLAY)) || |
|
|
char *s; |
char *s; |
struct ctl_slot *slot; |
struct ctl_slot *slot; |
char name[CTL_NAMEMAX]; |
char name[CTL_NAMEMAX]; |
unsigned i, unit, umap = 0; |
unsigned int i, unit, umap = 0; |
unsigned ser, bestser, bestidx; |
unsigned int ser, bestser, bestidx; |
|
|
/* |
/* |
* create a ``valid'' control name (lowcase, remove [^a-z], trucate) |
* create a ``valid'' control name (lowcase, remove [^a-z], trucate) |
|
|
* can work because all streams have a slot |
* can work because all streams have a slot |
*/ |
*/ |
void |
void |
dev_slotvol(struct dev *d, int slot, unsigned vol) |
dev_slotvol(struct dev *d, int slot, unsigned int vol) |
{ |
{ |
#ifdef DEBUG |
#ifdef DEBUG |
if (debug_level >= 3) { |
if (debug_level >= 3) { |
|
|
int |
int |
dev_try(struct dev *d, int slot) |
dev_try(struct dev *d, int slot) |
{ |
{ |
unsigned i; |
unsigned int i; |
struct ctl_slot *s; |
struct ctl_slot *s; |
|
|
if (d->tstate != CTL_START) { |
if (d->tstate != CTL_START) { |
|
|
void |
void |
dev_mmcstop(struct dev *d) |
dev_mmcstop(struct dev *d) |
{ |
{ |
unsigned i; |
unsigned int i; |
struct ctl_slot *s; |
struct ctl_slot *s; |
|
|
switch (d->tstate) { |
switch (d->tstate) { |
|
|
* relocate all slots simultaneously |
* relocate all slots simultaneously |
*/ |
*/ |
void |
void |
dev_loc(struct dev *d, unsigned origin) |
dev_loc(struct dev *d, unsigned int origin) |
{ |
{ |
unsigned i; |
unsigned int i; |
struct ctl_slot *s; |
struct ctl_slot *s; |
|
|
#ifdef DEBUG |
#ifdef DEBUG |
|
|
} |
} |
|
|
void |
void |
dev_master(struct dev *d, unsigned master) |
dev_master(struct dev *d, unsigned int master) |
{ |
{ |
#ifdef DEBUG |
#ifdef DEBUG |
if (debug_level >= 3) { |
if (debug_level >= 3) { |