2
* Purpose: A sample program for play target selection
3
* Copyright (C) 4Front Technologies, 2002-2007. Released under GPLv2/CDDL.
6
* This program demonstrates the new ioctl call interface used to
7
* control the play target selection.
9
* The first command line argument is the audio device (/dev/dsp#). If there
10
* are no other arguments then the available choices will be printed. If the
11
* second argument is "-" then the current setting will be printed.
12
* Finally the source can be changed by giving it's name as the
15
* {!notice Please not that the change may stay in effect even after closing
16
* the device. However equally well it's possible that the device returns back
17
* to some default source. There is no way to predict how the device will
18
* behave and the application must not expect any particular behaviour.}
25
#include <soundcard.h>
29
main (int argc, char *argv[])
32
oss_mixer_enuminfo ei;
36
fprintf (stderr, "Usage: %s dspdev\n", argv[0]);
40
if ((fd = open (argv[1], O_WRONLY, 0)) == -1)
46
if (ioctl (fd, SNDCTL_DSP_GET_PLAYTGT_NAMES, &ei) == -1)
48
perror ("SNDCTL_DSP_GET_PLAYTGT_NAMES");
54
for (i = 0; i < ei.nvalues; i++)
55
printf ("Play target #%d = '%s'\n", i, ei.strings + ei.strindex[i]);
59
if (strcmp (argv[2], "?") == 0 || strcmp (argv[2], "-") == 0)
61
if (ioctl (fd, SNDCTL_DSP_GET_PLAYTGT, &src) == -1)
63
perror ("SNDCTL_DSP_GET_PLAYTGT");
67
printf ("Current play target is #%d\n", src);
68
printf ("Current play target is #%d (%s)\n",
69
src, ei.strings + ei.strindex[src]);
75
for (i = 0; i < ei.nvalues; i++)
77
if (strcmp (argv[2], ei.strings + ei.strindex[i]) == 0)
79
if (ioctl (fd, SNDCTL_DSP_SET_PLAYTGT, &src) == -1)
81
perror ("SNDCTL_DSP_SET_PLAYTGT");
91
fprintf (stderr, "What?\n");