From 732ef894567bf1d98abd88594bd68b8ccf309d72 Mon Sep 17 00:00:00 2001 From: Bradley Conroy Date: Sat, 2 Aug 2014 11:49:30 -0500 Subject: mix.c - A very basic mixer. --- toys/pending/mix.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 toys/pending/mix.c (limited to 'toys/pending') diff --git a/toys/pending/mix.c b/toys/pending/mix.c new file mode 100644 index 00000000..4a51fb9e --- /dev/null +++ b/toys/pending/mix.c @@ -0,0 +1,64 @@ +/* mix.c - A very basic mixer. + * + * Copyright 2014 Brad Conroy, dedicated to the Public Domain. + * + +USE_MIX(NEWTOY(mix, "m:d:l#r#", TOYFLAG_USR|TOYFLAG_BIN)) +config MIX + bool "mix" + default n + help + usage: mix [-m mixer] [-d device] [-l level / left level] [-r right level] + + Lists/sets mixer devices/levels. +*/ + +#define FOR_mix +#include +#include "toys.h" + + +GLOBALS( + int right; + int level; + char *device; + char *mixer; +) + +void mix_main(void) +{ + const char *devices[SOUND_MIXER_NRDEVICES] = SOUND_DEVICE_NAMES; + char *mixer_name=(toys.optflags & FLAG_m)?TT.mixer:"/dev/mixer"; + int i, mask, device=-1, level, + mixer=xopen(mixer_name, O_RDWR|O_NONBLOCK); + + xioctl(mixer, SOUND_MIXER_READ_DEVMASK,&mask); + + if (!(toys.optflags & FLAG_d)){ + for (i = 0; i < SOUND_MIXER_NRDEVICES; ++i) + if (1<>8, level & 0xFF); + else printf("%s:%s = %d\n",mixer_name, devices[device], level); + return; + } + + level=TT.level; + if (!(toys.optflags & FLAG_r)) level = TT.right | (level<<8); + + xioctl(mixer, MIXER_WRITE(device),&level); + close(mixer); +} -- cgit v1.2.3