1 | //roarcatplay.c: |
---|
2 | |
---|
3 | /* |
---|
4 | * Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2012 |
---|
5 | * |
---|
6 | * This file is part of roarclients a part of RoarAudio, |
---|
7 | * a cross-platform sound system for both, home and professional use. |
---|
8 | * See README for details. |
---|
9 | * |
---|
10 | * This file is free software; you can redistribute it and/or modify |
---|
11 | * it under the terms of the GNU General Public License version 3 |
---|
12 | * as published by the Free Software Foundation. |
---|
13 | * |
---|
14 | * RoarAudio is distributed in the hope that it will be useful, |
---|
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
17 | * GNU General Public License for more details. |
---|
18 | * |
---|
19 | * You should have received a copy of the GNU General Public License |
---|
20 | * along with this software; see the file COPYING. If not, write to |
---|
21 | * the Free Software Foundation, 51 Franklin Street, Fifth Floor, |
---|
22 | * Boston, MA 02110-1301, USA. |
---|
23 | * |
---|
24 | */ |
---|
25 | |
---|
26 | #include <roaraudio.h> |
---|
27 | |
---|
28 | #define BUFSIZE 1024 |
---|
29 | |
---|
30 | void usage (void) { |
---|
31 | printf("roarcatplay [OPTIONS]... [FILE]\n"); |
---|
32 | |
---|
33 | printf("\nOptions:\n\n"); |
---|
34 | |
---|
35 | printf(" --server SERVER - Set server hostname\n" |
---|
36 | " --simple - Use the simple interface (default)\n" |
---|
37 | " --verbose - Use verbose output\n" |
---|
38 | " --help - Show this help\n" |
---|
39 | ); |
---|
40 | |
---|
41 | } |
---|
42 | |
---|
43 | int main (int argc, char * argv[]) { |
---|
44 | char * server = NULL; |
---|
45 | char * k; |
---|
46 | int i; |
---|
47 | char * file = NULL; |
---|
48 | int verbose = 0; |
---|
49 | roar_vs_t * vss; |
---|
50 | int err; |
---|
51 | |
---|
52 | for (i = 1; i < argc; i++) { |
---|
53 | k = argv[i]; |
---|
54 | |
---|
55 | if ( strcmp(k, "--server") == 0 || strcmp(k, "-s") == 0 ) { |
---|
56 | server = argv[++i]; |
---|
57 | } else if ( strcmp(k, "--simple") == 0 ) { |
---|
58 | /* no op */ |
---|
59 | } else if ( strcmp(k, "--verbose") == 0 || strcmp(k, "-v") == 0 ) { |
---|
60 | verbose++; |
---|
61 | } else if ( strcmp(k, "--help") == 0 || strcmp(k, "-h") == 0 ) { |
---|
62 | usage(); |
---|
63 | return 0; |
---|
64 | } else if ( file == NULL ) { |
---|
65 | file = argv[i]; |
---|
66 | } else { |
---|
67 | fprintf(stderr, "Error: unknown argument: %s\n", k); |
---|
68 | usage(); |
---|
69 | return 1; |
---|
70 | } |
---|
71 | } |
---|
72 | |
---|
73 | if ( file == NULL ) |
---|
74 | file = "/dev/stdin"; |
---|
75 | |
---|
76 | if ( (vss = roar_vs_new_from_file(server, "roarcatplay", file, &err)) == NULL ) { |
---|
77 | ROAR_ERR("Can not start playback: %s", roar_error2str(err)); |
---|
78 | return 1; |
---|
79 | } |
---|
80 | roar_vs_run(vss, NULL); |
---|
81 | roar_vs_sync(vss, ROAR_VS_WAIT, NULL); |
---|
82 | roar_vs_close(vss, ROAR_VS_FALSE, NULL); |
---|
83 | |
---|
84 | return 0; |
---|
85 | } |
---|
86 | |
---|
87 | //ll |
---|