version 1.2, 2008/11/03 22:25:13 |
version 1.3, 2008/11/11 19:21:20 |
|
|
f->bufsz = 2 * dev_bufsz; |
f->bufsz = 2 * dev_bufsz; |
f->round = dev_round; |
f->round = dev_round; |
f->odelta = f->idelta = 0; |
f->odelta = f->idelta = 0; |
|
f->vol = ADATA_UNIT; |
|
|
wproc = aproc_new(&wsock_ops, name); |
wproc = aproc_new(&wsock_ops, name); |
wproc->u.io.file = &f->pipe.file; |
wproc->u.io.file = &f->pipe.file; |
|
|
} |
} |
|
|
/* |
/* |
|
* free buffers |
|
*/ |
|
void |
|
sock_setvol(struct sock *f, int vol) |
|
{ |
|
struct abuf *rbuf; |
|
|
|
f->vol = vol; |
|
rbuf = LIST_FIRST(&f->pipe.file.rproc->obuflist); |
|
if (!rbuf) { |
|
DPRINTF("sock_setvol: no read buffer yet\n"); |
|
return; |
|
} |
|
dev_setvol(rbuf, vol); |
|
} |
|
|
|
/* |
* attach play and/or record buffers to dev_mix and/or dev_sub |
* attach play and/or record buffers to dev_mix and/or dev_sub |
*/ |
*/ |
int |
int |
|
|
dev_attach(f->pipe.file.name, |
dev_attach(f->pipe.file.name, |
(f->mode & AMSG_PLAY) ? rbuf : NULL, &f->rpar, f->xrun, |
(f->mode & AMSG_PLAY) ? rbuf : NULL, &f->rpar, f->xrun, |
(f->mode & AMSG_REC) ? wbuf : NULL, &f->wpar, f->xrun); |
(f->mode & AMSG_REC) ? wbuf : NULL, &f->wpar, f->xrun); |
|
if (f->mode & AMSG_PLAY) |
|
dev_setvol(rbuf, f->vol); |
|
|
/* |
/* |
* send the initial position, if needed |
* send the initial position, if needed |
*/ |
*/ |
|
|
m->u.cap.bps = sizeof(short); |
m->u.cap.bps = sizeof(short); |
f->rstate = SOCK_RRET; |
f->rstate = SOCK_RRET; |
f->rtodo = sizeof(struct amsg); |
f->rtodo = sizeof(struct amsg); |
|
break; |
|
case AMSG_SETVOL: |
|
DPRINTFN(2, "sock_execmsg: %p: SETVOL\n", f); |
|
if (f->pstate != SOCK_RUN && |
|
f->pstate != SOCK_START && f->pstate != SOCK_INIT) { |
|
DPRINTF("sock_execmsg: %p: SETVOL, bad state\n", f); |
|
aproc_del(f->pipe.file.rproc); |
|
return 0; |
|
} |
|
if (m->u.vol.ctl > MIDI_MAXCTL) { |
|
DPRINTF("sock_execmsg: %p: SETVOL, out of range\n", f); |
|
aproc_del(f->pipe.file.rproc); |
|
return 0; |
|
} |
|
DPRINTF("sock_execmsg: SETVOL %u\n", m->u.vol.ctl); |
|
sock_setvol(f, MIDI_TO_ADATA(m->u.vol.ctl)); |
|
f->rtodo = sizeof(struct amsg); |
|
f->rstate = SOCK_RMSG; |
break; |
break; |
default: |
default: |
DPRINTF("sock_execmsg: %p bogus command\n", f); |
DPRINTF("sock_execmsg: %p bogus command\n", f); |