File: playFile.c

package info (click to toggle)
nas 1.9.4-9.2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 8,644 kB
  • sloc: ansic: 52,144; makefile: 31,377; sh: 8,077; perl: 1,104; yacc: 252; cpp: 216; lex: 68
file content (39 lines) | stat: -rw-r--r-- 798 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/**
 * playFile - a simple Network Audio System audio file player
 *
 * usage: playFile [-v <volume in percent>] file
 *
 * Demonstrates AuSoundPlaySynchronousFromFile()
 *
 * $NCDId: @(#)playFile.c,v 1.1 1994/04/28 23:00:21 greg Exp $
 */

#include <stdio.h>
#include <stdlib.h>
#include <audio/audiolib.h>
#include <audio/soundlib.h>

int main(int argc, char **argv)
{
    char           *file = argv[1];
    int             volume = 100;
    AuServer       *aud;

    if (argc == 4)
    {
	if (argv[1][0] == '-' && argv[1][1] == 'v')
	{
	    volume = atoi(argv[2]);
	    file = argv[3];
	}
	else
	    exit(1);
    }
    else if (argc != 2)
	exit(1);

    if (!(aud = AuOpenServer(NULL, 0, NULL, 0, NULL, NULL)))
	exit(1);

    return AuSoundPlaySynchronousFromFile(aud, file, volume) ? 0 : 1;
}