source: roaraudio/roarclients/roarcatplay.c @ 765:131d502068f5

Last change on this file since 765:131d502068f5 was 765:131d502068f5, checked in by phi, 16 years ago

updated roarcatplay and added --simple and --pasive

File size: 2.5 KB
Line 
1//roarcat.c:
2
3/*
4 *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008
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, 675 Mass Ave, Cambridge, MA 02139, USA.
22 *
23 */
24
25#include <roaraudio.h>
26
27#define BUFSIZE 1024
28
29void usage (void) {
30 printf("roarcatplay [OPTIONS]... [FILE]\n");
31
32 printf("\nOptions:\n\n");
33
34 printf("  --server SERVER    - Set server hostname\n"
35        "  --simple           - Use the simple interface (default)\n"
36        "  --passive          - Use passiv playback (experimental, works only localy)\n"
37        "  --help             - Show this help\n"
38       );
39
40}
41
42#define MODE_SIMPLE  1
43#define MODE_PASSIVE 2
44
45int main (int argc, char * argv[]) {
46 char * server   = NULL;
47 char * k;
48 int    i;
49 char * file = NULL;
50 int    mode = MODE_SIMPLE;
51 struct roar_connection con[1];
52
53 for (i = 1; i < argc; i++) {
54  k = argv[i];
55
56  if ( strcmp(k, "--server") == 0 ) {
57   server = argv[++i];
58  } else if ( strcmp(k, "--simple") == 0 ) {
59   mode = MODE_SIMPLE;
60  } else if ( strcmp(k, "--passive") == 0 ) {
61   mode = MODE_PASSIVE;
62  } else if ( strcmp(k, "--help") == 0 ) {
63   usage();
64   return 0;
65  } else if ( file == NULL ) {
66   file = argv[i];
67  } else {
68   fprintf(stderr, "Error: unknown argument: %s\n", k);
69   usage();
70   return 1;
71  }
72 }
73
74
75 if ( file == NULL )
76  file = "/dev/stdin";
77
78 if ( mode == MODE_PASSIVE ) {
79  if ( roar_simple_connect(con, server, "roarcatplay") == -1 ) {
80   ROAR_ERR("Can not connect to server");
81   return 0;
82  }
83
84  if ( roar_file_play_full(con, file, 0, 1, NULL) == -1 ) {
85   ROAR_ERR("Can not start playback");
86   return 1;
87  }
88
89  sleep(10);
90
91  roar_disconnect(con);
92
93 } else { // MODE_SIMPLE
94  if ( roar_simple_play_file(file, server, "roarcatplay") == -1 ) {
95   ROAR_ERR("Can not start playback");
96   return 1;
97  }
98 }
99
100 return 0;
101}
102
103//ll
Note: See TracBrowser for help on using the repository browser.