source: roaraudio/roarclients/roarcat2sock.c @ 2875:5c14d2001848

Last change on this file since 2875:5c14d2001848 was 1405:37b39a2a8b95, checked in by phi, 15 years ago

corrected return values

File size: 2.4 KB
Line 
1//roarcat2sock.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("roarcat2sock [OPTIONS]...\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        "  --help             - Show this help\n"
39       );
40
41}
42
43int main (int argc, char * argv[]) {
44 int    rate     = 44100;
45 int    bits     = 16;
46 int    channels = 2;
47 int    codec    = ROAR_CODEC_DEFAULT;
48 char * server   = NULL;
49 char * k;
50 int    i;
51 int    fh;
52 char buf[BUFSIZE];
53 struct roar_connection con;
54
55
56 for (i = 1; i < argc; i++) {
57  k = argv[i];
58
59  if ( strcmp(k, "--server") == 0 ) {
60   server = argv[++i];
61  } else if ( strcmp(k, "--rate") == 0 ) {
62   rate = atoi(argv[++i]);
63  } else if ( strcmp(k, "--bits") == 0 ) {
64   bits = atoi(argv[++i]);
65  } else if ( strcmp(k, "--channels") == 0 ) {
66   channels = atoi(argv[++i]);
67  } else if ( strcmp(k, "--help") == 0 ) {
68   usage();
69   return 0;
70  } else {
71   fprintf(stderr, "Error: unknown argument: %s\n", k);
72   usage();
73   return 1;
74  }
75 }
76
77 if ( roar_simple_connect(&con, server, "roarcat2sock") == -1 ) {
78  ROAR_DBG("roar_simple_play(*): roar_simple_connect() faild!");
79  return 1;
80 }
81
82 if ( (fh = roar_simple_new_stream(&con, rate, channels, bits, codec, ROAR_DIR_PLAY)) == -1 ) {
83  roar_disconnect(&con);
84  return 1;
85 }
86
87 while((i = read(0, buf, BUFSIZE)))
88  write(fh, buf, i);
89
90 close(fh);
91
92 roar_disconnect(&con);
93
94 return 0;
95}
96
97//ll
Note: See TracBrowser for help on using the repository browser.