version 1.24, 2009/08/21 16:48:03 |
version 1.25, 2009/08/26 06:10:15 |
|
|
f->round = dev_round; |
f->round = dev_round; |
f->delta = 0; |
f->delta = 0; |
f->tickpending = 0; |
f->tickpending = 0; |
f->vol = ADATA_UNIT; |
f->vol = f->lastvol = MIDI_MAXCTL; |
f->slot = -1; |
f->slot = -1; |
|
|
wproc = aproc_new(&wsock_ops, f->pipe.file.name); |
wproc = aproc_new(&wsock_ops, f->pipe.file.name); |
|
|
} |
} |
|
|
/* |
/* |
* Set volume. |
* Set volume. Callback invoked when volume is modified externally |
*/ |
*/ |
void |
void |
sock_setvol(struct sock *f, int vol) |
sock_setvol(void *arg, unsigned vol) |
{ |
{ |
|
struct sock *f = (struct sock *)arg; |
struct abuf *rbuf; |
struct abuf *rbuf; |
|
|
f->vol = vol; |
f->vol = vol; |
|
if (f->pstate <= SOCK_START) |
|
f->lastvol = f->vol; |
rbuf = LIST_FIRST(&f->pipe.file.rproc->obuflist); |
rbuf = LIST_FIRST(&f->pipe.file.rproc->obuflist); |
if (!rbuf) { |
if (!rbuf) { |
DPRINTF("sock_setvol: no read buffer yet\n"); |
DPRINTF("sock_setvol: no read buffer yet\n"); |
return; |
return; |
} |
} |
dev_setvol(rbuf, vol); |
dev_setvol(rbuf, MIDI_TO_ADATA(vol)); |
} |
} |
|
|
/* |
/* |
|
|
(f->mode & AMSG_REC) ? wbuf : NULL, &f->wpar, f->xrun, |
(f->mode & AMSG_REC) ? wbuf : NULL, &f->wpar, f->xrun, |
f->opt->maxweight); |
f->opt->maxweight); |
if (f->mode & AMSG_PLAY) |
if (f->mode & AMSG_PLAY) |
dev_setvol(rbuf, f->vol); |
dev_setvol(rbuf, MIDI_TO_ADATA(f->vol)); |
|
|
/* |
/* |
* Send the initial position, if needed. |
* Send the initial position, if needed. |
|
|
f->mode |= AMSG_REC; |
f->mode |= AMSG_REC; |
} |
} |
if (dev_midi) { |
if (dev_midi) { |
f->slot = ctl_slotnew(dev_midi, p->who, f->pipe.file.rproc); |
f->slot = ctl_slotnew(dev_midi, p->who, sock_setvol, f); |
if (f->slot < 0) { |
if (f->slot < 0) { |
DPRINTF("sock_hello: out of mixer slots\n"); |
DPRINTF("sock_hello: out of mixer slots\n"); |
return 0; |
return 0; |
|
|
return 0; |
return 0; |
} |
} |
DPRINTF("sock_execmsg: SETVOL %u\n", m->u.vol.ctl); |
DPRINTF("sock_execmsg: SETVOL %u\n", m->u.vol.ctl); |
sock_setvol(f, MIDI_TO_ADATA(m->u.vol.ctl)); |
sock_setvol(f, m->u.vol.ctl); |
if (dev_midi && f->slot >= 0) |
if (dev_midi && f->slot >= 0) |
ctl_slotvol(dev_midi, f->slot, m->u.vol.ctl); |
ctl_slotvol(dev_midi, f->slot, m->u.vol.ctl); |
f->rtodo = sizeof(struct amsg); |
f->rtodo = sizeof(struct amsg); |
|
|
f->wstate = SOCK_WMSG; |
f->wstate = SOCK_WMSG; |
f->delta = 0; |
f->delta = 0; |
f->tickpending = 0; |
f->tickpending = 0; |
|
return 1; |
|
} |
|
|
|
/* |
|
* if volume changed build a SETVOL message |
|
*/ |
|
if (f->vol != f->lastvol) { |
|
DPRINTFN(4, "sock_buildmsg: %p: SETVOL: %d\n", f, f->vol); |
|
AMSG_INIT(&f->wmsg); |
|
f->wmsg.cmd = AMSG_SETVOL; |
|
f->wmsg.u.vol.ctl = f->vol; |
|
f->wtodo = sizeof(struct amsg); |
|
f->wstate = SOCK_WMSG; |
|
f->lastvol = f->vol; |
return 1; |
return 1; |
} |
} |
|
|