1 /**
2 * playSimul - plays multiple files simultaneously
3 *
4 * usage: playSimul [-v <volume in percent>] file1 file2 file3 ...
5 *
6 * Demonstrates AuSoundPlayFromFile()
7 *
8 * $NCDId: @(#)playSimul.c,v 1.2 1994/05/04 17:30:58 greg Exp $
9 */
10
11 #include <stdio.h>
12 #include <stdlib.h>
13 #include <audio/audiolib.h>
14 #include <audio/soundlib.h>
15
16 static void
doneCB(AuServer * aud,AuEventHandlerRec * handler,AuEvent * ev,AuPointer data)17 doneCB(AuServer *aud, AuEventHandlerRec *handler, AuEvent *ev, AuPointer data)
18 {
19 int *count = (int *) data;
20
21 (*count)--;
22 }
23
24 int
main(int argc,char ** argv)25 main(int argc, char **argv)
26 {
27 AuServer *aud;
28 AuEvent ev;
29 int volume = 100,
30 count = 0;
31 char **arg = &argv[1];
32
33 if (!(aud = AuOpenServer(NULL, 0, NULL, 0, NULL, NULL)))
34 exit(1);
35
36 argc--;
37
38 while (argc--)
39 {
40 if (arg[0][0] == '-' && arg[0][1] == 'v')
41 {
42 if (argc)
43 {
44 arg++;
45 argc--;
46 volume = atoi(*arg);
47 }
48 }
49 else if (AuSoundPlayFromFile(aud, *arg, AuNone,
50 AuFixedPointFromFraction(volume, 100),
51 doneCB, (AuPointer) &count, NULL, NULL,
52 NULL, NULL))
53 count++;
54
55 arg++;
56 }
57
58 while (count)
59 {
60 AuNextEvent(aud, AuTrue, &ev);
61 AuDispatchEvent(aud, &ev);
62 }
63
64 AuCloseServer(aud);
65 return 0;
66 }
67