source: roaraudio/roarclients/roarcatvio.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: 3.1 KB
Line 
1//roarcatvio.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("roarcatvio [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     = ROAR_RATE_DEFAULT;
46 int    bits     = ROAR_BITS_DEFAULT;
47 int    channels = ROAR_CHANNELS_DEFAULT;
48 int    codec    = ROAR_CODEC_DEFAULT;
49 char * server   = NULL;
50 char * k;
51 int    i;
52 char * name = "roarcatvio";
53 struct roar_vio_calls file, stream;
54 struct roar_vio_defaults def;
55 int file_opened = 0;
56
57 if ( roar_vio_open_fh(&file, ROAR_STDIN) == -1 )
58  return 1;
59
60 if ( roar_vio_dstr_init_defaults(&def, ROAR_VIO_DEF_TYPE_NONE, O_RDONLY, 0644) == -1 )
61  return 1;
62
63 for (i = 1; i < argc; i++) {
64  k = argv[i];
65
66  if ( !strcmp(k, "--server") || !strcmp(k, "-s") ) {
67   server = argv[++i];
68  } else if ( !strcmp(k, "-n") ) {
69   name = argv[++i];
70  } else if ( !strcmp(k, "--rate") || !strcmp(k, "-r") ) {
71   rate = atoi(argv[++i]);
72  } else if ( !strcmp(k, "--bits") ) {
73   bits = atoi(argv[++i]);
74  } else if ( !strcmp(k, "-b") ) {
75   bits = 8;
76  } else if ( !strcmp(k, "--channels") || !strcmp(k, "--chans") ) {
77   channels = atoi(argv[++i]);
78  } else if ( !strcmp(k, "-m") ) {
79   channels = 1;
80  } else if ( !strcmp(k, "--codec") ) {
81   codec = roar_str2codec(argv[++i]);
82  } else if ( !strcmp(k, "--help") ) {
83   usage();
84   return 0;
85  } else if ( !file_opened ) {
86   file_opened = 1;
87   if ( roar_vio_open_dstr(&file, k, &def, 1) == -1 ) {
88    fprintf(stderr, "Error: can not open file: %s: %s\n", k, strerror(errno));
89    return 1;
90   }
91  } else {
92   fprintf(stderr, "Error: unknown argument: %s\n", k);
93   usage();
94   return 1;
95  }
96 }
97
98 if ( roar_vio_simple_stream(&stream, rate, channels, bits, codec, server, ROAR_DIR_PLAY, name) == -1 ) {
99  fprintf(stderr, "Error: can not start playback\n");
100  return 1;
101 }
102
103 roar_vio_copy_data(&stream, &file);
104
105 roar_vio_close(&file);
106 roar_vio_close(&stream);
107
108 return 0;
109}
110
111//ll
Note: See TracBrowser for help on using the repository browser.