3
* This file is part of Open Sound System.
5
* Copyright (C) 4Front Technologies 1996-2008.
7
* This this source file is released under GPL v2 license (no other versions).
8
* See the COPYING file included in the main directory of this source
9
* distribution for the license terms and conditions.
18
#include <sys/soundcard.h>
19
#include <sys/libossmix.h>
22
event_callback(ossmix_callback_parm_t *parms)
26
case OSSMIX_EVENT_VALUE:
27
printf("Value change, mixer=%d, ctl=%d, value=0x%08x\n", parms->p1, parms->p2, parms->p3);
30
case OSSMIX_EVENT_NEWMIXER:
31
printf("Number of mixers increased to %d\n", parms->p1);
35
printf("Event callback %d, %d, %d, %d, %d\n", parms->event, parms->p1, parms->p2, parms->p3, parms->p4);
40
command_parser(char *line)
42
char *p = line + strlen(line)-1;
47
if (strcmp(line, "exit")==0 || strcmp(line, "q")==0)
52
interactive_mode(void)
54
int libfd=-1, maxdev, ndevs;
56
ossmix_select_poll_t pollfunc;
59
libfd=ossmix_get_fd(&pollfunc);
61
ossmix_set_callback(event_callback);
63
printf("libfd=%d, func=%p\n", libfd, pollfunc);
65
printf("> ");fflush(stdout);
70
tmout.tv_usec = 100000; /* 0.1 sec */
84
FD_SET (0, &readfds); // Stdin
86
FD_SET (libfd, &readfds);
92
select (maxdev + 1, &readfds, NULL, NULL, &tmout)) == -1)
102
tmout.tv_usec = 100000; /* 0.1 sec */
105
if (FD_ISSET (0, &readfds)) /* Stdio */
109
if (fgets(line, sizeof(line)-1, stdin) != NULL)
111
command_parser(line);
112
printf("> ");fflush(stdout);
117
if (FD_ISSET (libfd, &readfds))
123
print_enum_list(int mixnum, int ctl)
125
oss_mixer_enuminfo desc;
128
if (ossmix_get_enuminfo(mixnum, ctl, &desc)<0)
130
fprintf(stderr, "ossmix_get_enuminfo() failed\n");
134
for (i=0;i<desc.nvalues;i++)
136
if (i>0)printf(" | ");
137
printf("%s", desc.strings+desc.strindex[i]);
144
print_description(int mixnum, int ctl)
146
oss_mixer_enuminfo desc;
148
if (ossmix_get_description(mixnum, ctl, &desc)<0)
150
fprintf(stderr, "ossmix_get_description() failed\n");
154
printf("%s\n", desc.strings);
158
main(int argc, char *argv[])
164
extern int mixlib_trace;
169
while ((i = getopt(argc, argv, "ip:h:")) != EOF)
184
if ((err=ossmix_init())<0)
186
fprintf(stderr, "ossmix_init() failed, err=%d\n");
190
if ((err=ossmix_connect(host, port))<0)
192
fprintf(stderr, "ossmix_connect() failed, err=%d\n", err);
196
if ((nmixers=ossmix_get_nmixers())<0)
198
fprintf(stderr, "ossmix_get_nmixers() failed, err=%d\n", nmixers);
202
printf("Number of mixers=%d\n", nmixers);
204
for (i=0;i<nmixers;i++)
209
if (ossmix_get_mixerinfo(i, &mi)<0)
211
fprintf(stderr, "ossmix_get_mixerinfo(%d) failed\n", i);
215
printf("Mixer %2d: %s\n", i, mi.name);
217
if (ossmix_open_mixer(i)<0)
219
fprintf(stderr, "ossmix_open_mixer(%d) failed\n", i);
223
if ((n=ossmix_get_nrext(i))<0)
225
fprintf(stderr, "ossmix_get_nrext(%d) failed, err=\n", i, n);
229
printf("Mixer has %d nodes\n", n);
231
for (ctl=0;ctl<n;ctl++)
236
if (ossmix_get_nodeinfo(i, ctl, &node)<0)
238
fprintf(stderr, "ossmix_get_nodeinfo(%d, %d) failed\n",
244
if (node.type != MIXT_DEVROOT && node.type != MIXT_GROUP && node.type != MIXT_MARKER)
245
if ((value=ossmix_get_value(i, ctl, node.timestamp))<0)
247
fprintf(stderr, "ossmix_get_value(%d, %d, %d) failed, err=%d\n",
248
i, ctl, node.timestamp, value);
251
printf("%3d: %s = 0x%08x\n", ctl, node.extname, value);
253
if (node.type == MIXT_ENUM)
254
print_enum_list(i, ctl);
256
if (node.flags & MIXF_DESCR)
257
print_description(i, ctl);
262
ossmix_close_mixer(i);
268
printf("Disconnecting\n");