source: roaraudio/roarclients/roarcatsendfile.c @ 3121:0ed0acfadd4f

Last change on this file since 3121:0ed0acfadd4f was 2292:0e4ee5724202, checked in by phi, 15 years ago

simple patches, mostly by Simon Matter (trivial by german law so no (c) notice)

File size: 2.6 KB
Line 
1//roarcatsendfile.c:
2
3/*
4 *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008, 2009
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("roarcatsendfile [OPTIONS]... [FILE]\n");
31
32 printf("\nOptions:\n\n");
33
34 printf("  --server SERVER    - Set server hostname\n"
35        "  --rate   RATE      - Set sample rate\n"
36        "  --bits   BITS      - Set bits per sample\n"
37        "  --chans  CHANNELS  - Set number of channels\n"
38        "  --codec  CODEC     - Set the codec\n"
39        "  --help             - Show this help\n"
40       );
41
42}
43
44int main (int argc, char * argv[]) {
45 int    rate     = 44100;
46 int    bits     = 16;
47 int    channels = 2;
48 int    codec    = ROAR_CODEC_DEFAULT;
49 char * server   = NULL;
50 char * k;
51 int    fh;
52 int    i;
53 int    in = -1;
54
55 for (i = 1; i < argc; i++) {
56  k = argv[i];
57
58  if ( strcmp(k, "--server") == 0 ) {
59   server = argv[++i];
60  } else if ( strcmp(k, "--rate") == 0 ) {
61   rate = atoi(argv[++i]);
62  } else if ( strcmp(k, "--bits") == 0 ) {
63   bits = atoi(argv[++i]);
64  } else if ( strcmp(k, "--channels") == 0 || strcmp(k, "--chans") == 0 ) {
65   channels = atoi(argv[++i]);
66  } else if ( strcmp(k, "--codec") == 0 ) {
67   codec = atoi(argv[++i]);
68  } else if ( strcmp(k, "--help") == 0 ) {
69   usage();
70   return 0;
71  } else if ( in == -1 ) {
72   if ( (in = open(k, O_RDONLY, 0644)) == -1 ) {
73    fprintf(stderr, "Error: can not open file: %s: %s\n", k, strerror(errno));
74    return 1;
75   }
76  } else {
77   fprintf(stderr, "Error: unknown argument: %s\n", k);
78   usage();
79   return 1;
80  }
81 }
82
83 if ( (fh = roar_simple_play(rate, channels, bits, codec, server, "roarcatsendfile")) == -1 ) {
84  fprintf(stderr, "Error: can not start playback\n");
85  return 1;
86 }
87
88 if ( in == -1 )
89  in = ROAR_STDIN;
90
91 roar_file_send_raw(fh, in);
92
93 roar_simple_close(fh);
94
95 close(in);
96
97 return 0;
98}
99
100//ll
Note: See TracBrowser for help on using the repository browser.