[2292] | 1 | //roarcatplay.c: |
---|
[212] | 2 | |
---|
[669] | 3 | /* |
---|
[5823] | 4 | * Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2013 |
---|
[669] | 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 |
---|
[3517] | 21 | * the Free Software Foundation, 51 Franklin Street, Fifth Floor, |
---|
| 22 | * Boston, MA 02110-1301, USA. |
---|
[669] | 23 | * |
---|
| 24 | */ |
---|
| 25 | |
---|
[212] | 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" |
---|
[765] | 36 | " --simple - Use the simple interface (default)\n" |
---|
[999] | 37 | " --verbose - Use verbose output\n" |
---|
[212] | 38 | " --help - Show this help\n" |
---|
| 39 | ); |
---|
| 40 | |
---|
| 41 | } |
---|
| 42 | |
---|
| 43 | int main (int argc, char * argv[]) { |
---|
[5534] | 44 | const char * server = NULL; |
---|
| 45 | const char * k; |
---|
[212] | 46 | int i; |
---|
[5534] | 47 | const char * file = NULL; |
---|
[999] | 48 | int verbose = 0; |
---|
[5022] | 49 | roar_vs_t * vss; |
---|
| 50 | int err; |
---|
[212] | 51 | |
---|
| 52 | for (i = 1; i < argc; i++) { |
---|
| 53 | k = argv[i]; |
---|
| 54 | |
---|
[1635] | 55 | if ( strcmp(k, "--server") == 0 || strcmp(k, "-s") == 0 ) { |
---|
[212] | 56 | server = argv[++i]; |
---|
[765] | 57 | } else if ( strcmp(k, "--simple") == 0 ) { |
---|
[5221] | 58 | /* no op */ |
---|
[999] | 59 | } else if ( strcmp(k, "--verbose") == 0 || strcmp(k, "-v") == 0 ) { |
---|
| 60 | verbose++; |
---|
[1635] | 61 | } else if ( strcmp(k, "--help") == 0 || strcmp(k, "-h") == 0 ) { |
---|
[212] | 62 | usage(); |
---|
| 63 | return 0; |
---|
[214] | 64 | } else if ( file == NULL ) { |
---|
| 65 | file = argv[i]; |
---|
[212] | 66 | } else { |
---|
| 67 | fprintf(stderr, "Error: unknown argument: %s\n", k); |
---|
| 68 | usage(); |
---|
| 69 | return 1; |
---|
| 70 | } |
---|
| 71 | } |
---|
| 72 | |
---|
[214] | 73 | if ( file == NULL ) |
---|
[5813] | 74 | file = "fh:stdin"; |
---|
[212] | 75 | |
---|
[5221] | 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; |
---|
[765] | 79 | } |
---|
[5221] | 80 | roar_vs_run(vss, NULL); |
---|
| 81 | roar_vs_sync(vss, ROAR_VS_WAIT, NULL); |
---|
| 82 | roar_vs_close(vss, ROAR_VS_FALSE, NULL); |
---|
[212] | 83 | |
---|
| 84 | return 0; |
---|
| 85 | } |
---|
| 86 | |
---|
| 87 | //ll |
---|