Skip to content

Commit 58d1a60

Browse files
committed
sndiod: Rename and move dev_midi_{vol,slotdesc,dump}() to opt.c
No behavior change.
1 parent a89c75a commit 58d1a60

File tree

4 files changed

+70
-74
lines changed

4 files changed

+70
-74
lines changed

usr.bin/sndiod/dev.c

Lines changed: 3 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $OpenBSD: dev.c,v 1.123 2025/06/19 20:16:34 ratchov Exp $ */
1+
/* $OpenBSD: dev.c,v 1.124 2025/06/20 07:14:38 ratchov Exp $ */
22
/*
33
* Copyright (c) 2008-2012 Alexandre Ratchov <[email protected]>
44
*
@@ -274,22 +274,6 @@ mtc_midi_full(struct mtc *mtc)
274274
dev_midi_send(mtc->dev, (unsigned char *)&x, SYSEX_SIZE(full));
275275
}
276276

277-
/*
278-
* send a volume change MIDI message
279-
*
280-
* XXX: rename to opt_midi_vol() and move to opt.c
281-
*/
282-
void
283-
dev_midi_vol(struct opt *o, struct app *a)
284-
{
285-
unsigned char msg[3];
286-
287-
msg[0] = MIDI_CTL | (a - o->app_array);
288-
msg[1] = MIDI_CTL_VOL;
289-
msg[2] = a->vol;
290-
midi_send(o->midi, msg, sizeof(msg));
291-
}
292-
293277
/*
294278
* send a master volume MIDI message
295279
*/
@@ -330,52 +314,6 @@ dev_midi_master(struct dev *d)
330314
dev_midi_send(d, (unsigned char *)&x, SYSEX_SIZE(master));
331315
}
332316

333-
/*
334-
* send a sndiod-specific slot description MIDI message
335-
*
336-
* XXX: rename to opt_midi_appdesc() and move to opt.c
337-
*/
338-
void
339-
dev_midi_slotdesc(struct opt *o, struct app *a)
340-
{
341-
struct sysex x;
342-
343-
memset(&x, 0, sizeof(struct sysex));
344-
x.start = SYSEX_START;
345-
x.type = SYSEX_TYPE_EDU;
346-
x.dev = SYSEX_DEV_ANY;
347-
x.id0 = SYSEX_AUCAT;
348-
x.id1 = SYSEX_AUCAT_SLOTDESC;
349-
strlcpy(x.u.slotdesc.name, a->name, SYSEX_NAMELEN);
350-
x.u.slotdesc.chan = (a - o->app_array);
351-
x.u.slotdesc.end = SYSEX_END;
352-
midi_send(o->midi, (unsigned char *)&x, SYSEX_SIZE(slotdesc));
353-
}
354-
355-
/*
356-
* XXX: rename to opt_midi_dump() and move to opt.c
357-
*/
358-
void
359-
dev_midi_dump(struct opt *o)
360-
{
361-
struct sysex x;
362-
struct app *a;
363-
int i;
364-
365-
dev_midi_master(o->dev);
366-
for (i = 0, a = o->app_array; i < OPT_NAPP; i++, a++) {
367-
dev_midi_slotdesc(o, a);
368-
dev_midi_vol(o, a);
369-
}
370-
x.start = SYSEX_START;
371-
x.type = SYSEX_TYPE_EDU;
372-
x.dev = SYSEX_DEV_ANY;
373-
x.id0 = SYSEX_AUCAT;
374-
x.id1 = SYSEX_AUCAT_DUMPEND;
375-
x.u.dumpend.end = SYSEX_END;
376-
midi_send(o->midi, (unsigned char *)&x, SYSEX_SIZE(dumpend));
377-
}
378-
379317
int
380318
slot_skip(struct slot *s)
381319
{
@@ -1585,7 +1523,7 @@ slot_setvol(struct slot *s, unsigned int vol)
15851523
#endif
15861524
if (a->vol != vol) {
15871525
opt_appvol(o, a, vol);
1588-
dev_midi_vol(o, a);
1526+
opt_midi_vol(o, a);
15891527
ctl_onval(CTL_APP_LEVEL, o, a, vol);
15901528
}
15911529
}
@@ -2077,7 +2015,7 @@ ctl_setval(struct ctl *c, int val)
20772015
return 1;
20782016
case CTL_APP_LEVEL:
20792017
opt_appvol(c->u.app_level.opt, c->u.app_level.app, val);
2080-
dev_midi_vol(c->u.app_level.opt, c->u.app_level.app);
2018+
opt_midi_vol(c->u.app_level.opt, c->u.app_level.app);
20812019
c->val_mask = ~0U;
20822020
c->curval = val;
20832021
return 1;

usr.bin/sndiod/dev.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $OpenBSD: dev.h,v 1.48 2025/06/19 20:16:34 ratchov Exp $ */
1+
/* $OpenBSD: dev.h,v 1.49 2025/06/20 07:14:38 ratchov Exp $ */
22
/*
33
* Copyright (c) 2008-2012 Alexandre Ratchov <[email protected]>
44
*
@@ -307,10 +307,7 @@ void dev_cycle(struct dev *);
307307
*/
308308
void dev_master(struct dev *, unsigned int);
309309
void dev_midi_send(struct dev *, void *, int);
310-
void dev_midi_vol(struct opt *, struct app *);
311310
void dev_midi_master(struct dev *);
312-
void dev_midi_slotdesc(struct opt *o, struct app *a);
313-
void dev_midi_dump(struct opt *o);
314311

315312
void mtc_midi_qfr(struct mtc *, int);
316313
void mtc_midi_full(struct mtc *);

usr.bin/sndiod/opt.c

Lines changed: 62 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $OpenBSD: opt.c,v 1.14 2025/06/19 20:16:34 ratchov Exp $ */
1+
/* $OpenBSD: opt.c,v 1.15 2025/06/20 07:14:38 ratchov Exp $ */
22
/*
33
* Copyright (c) 2008-2011 Alexandre Ratchov <[email protected]>
44
*
@@ -109,8 +109,8 @@ opt_mkapp(struct opt *o, char *who)
109109
ctl_new(CTL_APP_LEVEL, o, a,
110110
CTL_NUM, "", "app", a->name, -1, "level",
111111
NULL, -1, 127, a->vol);
112-
dev_midi_slotdesc(o, a);
113-
dev_midi_vol(o, a);
112+
opt_midi_appdesc(o, a);
113+
opt_midi_vol(o, a);
114114

115115
return a;
116116
}
@@ -232,7 +232,7 @@ opt_midi_omsg(void *arg, unsigned char *msg, int len)
232232
return;
233233
if (len != SYSEX_SIZE(dumpreq))
234234
return;
235-
dev_midi_dump(o);
235+
opt_midi_dump(o);
236236
break;
237237
}
238238
}
@@ -251,6 +251,64 @@ opt_midi_exit(void *arg)
251251
logx(1, "%s: midi end point died", o->name);
252252
}
253253

254+
/*
255+
* send a volume change MIDI message
256+
*/
257+
void
258+
opt_midi_vol(struct opt *o, struct app *a)
259+
{
260+
unsigned char msg[3];
261+
262+
msg[0] = MIDI_CTL | (a - o->app_array);
263+
msg[1] = MIDI_CTL_VOL;
264+
msg[2] = a->vol;
265+
midi_send(o->midi, msg, sizeof(msg));
266+
}
267+
268+
/*
269+
* send a sndiod-specific slot description MIDI message
270+
*/
271+
void
272+
opt_midi_appdesc(struct opt *o, struct app *a)
273+
{
274+
struct sysex x;
275+
276+
memset(&x, 0, sizeof(struct sysex));
277+
x.start = SYSEX_START;
278+
x.type = SYSEX_TYPE_EDU;
279+
x.dev = SYSEX_DEV_ANY;
280+
x.id0 = SYSEX_AUCAT;
281+
x.id1 = SYSEX_AUCAT_SLOTDESC;
282+
strlcpy(x.u.slotdesc.name, a->name, SYSEX_NAMELEN);
283+
x.u.slotdesc.chan = (a - o->app_array);
284+
x.u.slotdesc.end = SYSEX_END;
285+
midi_send(o->midi, (unsigned char *)&x, SYSEX_SIZE(slotdesc));
286+
}
287+
288+
/*
289+
* send a MIDI dump: master volume, state of MIDI channels
290+
*/
291+
void
292+
opt_midi_dump(struct opt *o)
293+
{
294+
struct sysex x;
295+
struct app *a;
296+
int i;
297+
298+
dev_midi_master(o->dev);
299+
for (i = 0, a = o->app_array; i < OPT_NAPP; i++, a++) {
300+
opt_midi_appdesc(o, a);
301+
opt_midi_vol(o, a);
302+
}
303+
x.start = SYSEX_START;
304+
x.type = SYSEX_TYPE_EDU;
305+
x.dev = SYSEX_DEV_ANY;
306+
x.id0 = SYSEX_AUCAT;
307+
x.id1 = SYSEX_AUCAT_DUMPEND;
308+
x.u.dumpend.end = SYSEX_END;
309+
midi_send(o->midi, (unsigned char *)&x, SYSEX_SIZE(dumpend));
310+
}
311+
254312
/*
255313
* create a new audio sub-device "configuration"
256314
*/

usr.bin/sndiod/opt.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $OpenBSD: opt.h,v 1.9 2025/06/19 20:16:34 ratchov Exp $ */
1+
/* $OpenBSD: opt.h,v 1.10 2025/06/20 07:14:38 ratchov Exp $ */
22
/*
33
* Copyright (c) 2008-2012 Alexandre Ratchov <[email protected]>
44
*
@@ -53,6 +53,9 @@ extern struct opt *opt_list;
5353

5454
struct app *opt_mkapp(struct opt *o, char *who);
5555
void opt_appvol(struct opt *o, struct app *a, int vol);
56+
void opt_midi_vol(struct opt *, struct app *);
57+
void opt_midi_appdesc(struct opt *o, struct app *a);
58+
void opt_midi_dump(struct opt *o);
5659
struct opt *opt_new(struct dev *, char *, int, int, int, int,
5760
int, int, int, unsigned int);
5861
void opt_del(struct opt *);

0 commit comments

Comments
 (0)