mirror of
https://github.com/openbsd/src.git
synced 2025-01-10 06:47:55 -08:00
expose the volume knob in server mode too
This commit is contained in:
parent
2dae5de94b
commit
d4e1905928
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: amsg.h,v 1.1 2008/10/26 08:49:43 ratchov Exp $ */
|
||||
/* $OpenBSD: amsg.h,v 1.2 2008/11/11 19:21:20 ratchov Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
|
||||
*
|
||||
@ -34,6 +34,7 @@ struct amsg {
|
||||
#define AMSG_DATA 5 /* data block */
|
||||
#define AMSG_MOVE 6 /* position changed */
|
||||
#define AMSG_GETCAP 7 /* get capabilities */
|
||||
#define AMSG_SETVOL 8 /* set volume */
|
||||
uint32_t cmd;
|
||||
uint32_t __pad;
|
||||
union {
|
||||
@ -74,6 +75,9 @@ struct amsg {
|
||||
struct amsg_ts {
|
||||
int32_t delta;
|
||||
} ts;
|
||||
struct amsg_vol {
|
||||
uint32_t ctl;
|
||||
} vol;
|
||||
} u;
|
||||
};
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: dev.c,v 1.15 2008/11/11 12:56:02 ratchov Exp $ */
|
||||
/* $OpenBSD: dev.c,v 1.16 2008/11/11 19:21:20 ratchov Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
|
||||
*
|
||||
@ -501,10 +501,12 @@ dev_attach(char *name,
|
||||
void
|
||||
dev_setvol(struct abuf *ibuf, int vol)
|
||||
{
|
||||
if (!dev_getep(&ibuf, NULL))
|
||||
if (!dev_getep(&ibuf, NULL)) {
|
||||
DPRINTF("dev_setvol: not connected yet\n");
|
||||
return;
|
||||
fprintf(stderr, "vol = %d\n", vol);
|
||||
}
|
||||
ibuf->mixvol = vol;
|
||||
DPRINTF("dev_setvol: %d\n", vol);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: sock.c,v 1.2 2008/11/03 22:25:13 ratchov Exp $ */
|
||||
/* $OpenBSD: sock.c,v 1.3 2008/11/11 19:21:20 ratchov Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
|
||||
*
|
||||
@ -280,6 +280,7 @@ sock_new(struct fileops *ops, int fd, char *name)
|
||||
f->bufsz = 2 * dev_bufsz;
|
||||
f->round = dev_round;
|
||||
f->odelta = f->idelta = 0;
|
||||
f->vol = ADATA_UNIT;
|
||||
|
||||
wproc = aproc_new(&wsock_ops, name);
|
||||
wproc->u.io.file = &f->pipe.file;
|
||||
@ -343,6 +344,23 @@ sock_allocbuf(struct sock *f)
|
||||
(void)sock_attach(f, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
@ -370,7 +388,9 @@ sock_attach(struct sock *f, int force)
|
||||
dev_attach(f->pipe.file.name,
|
||||
(f->mode & AMSG_PLAY) ? rbuf : NULL, &f->rpar, 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
|
||||
*/
|
||||
@ -756,6 +776,24 @@ sock_execmsg(struct sock *f)
|
||||
f->rstate = SOCK_RRET;
|
||||
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;
|
||||
default:
|
||||
DPRINTF("sock_execmsg: %p bogus command\n", f);
|
||||
aproc_del(f->pipe.file.rproc);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: sock.h,v 1.1 2008/10/26 08:49:44 ratchov Exp $ */
|
||||
/* $OpenBSD: sock.h,v 1.2 2008/11/11 19:21:20 ratchov Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
|
||||
*
|
||||
@ -50,6 +50,7 @@ struct sock {
|
||||
unsigned bufsz; /* total buffer size */
|
||||
unsigned round; /* block size */
|
||||
unsigned xrun; /* one of AMSG_IGNORE, ... */
|
||||
unsigned vol;
|
||||
};
|
||||
|
||||
struct sock *sock_new(struct fileops *, int fd, char *);
|
||||
|
Loading…
Reference in New Issue
Block a user