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

Last change on this file since 3121:0ed0acfadd4f was 1405:37b39a2a8b95, checked in by phi, 15 years ago

corrected return values

File size: 2.7 KB
Line 
1//roarcatad.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*2)
28
29void usage (void) {
30 printf("roarcatad [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 char buf[BUFSIZE];
52 struct roar_connection con;
53 struct roar_stream     s;
54 struct roar_stream_info info;
55
56
57 for (i = 1; i < argc; i++) {
58  k = argv[i];
59
60  if ( strcmp(k, "--server") == 0 ) {
61   server = argv[++i];
62  } else if ( strcmp(k, "--rate") == 0 ) {
63   rate = atoi(argv[++i]);
64  } else if ( strcmp(k, "--bits") == 0 ) {
65   bits = atoi(argv[++i]);
66  } else if ( strcmp(k, "--channels") == 0 ) {
67   channels = atoi(argv[++i]);
68  } else if ( strcmp(k, "--help") == 0 ) {
69   usage();
70   return 0;
71  } else {
72   fprintf(stderr, "Error: unknown argument: %s\n", k);
73   usage();
74   return 1;
75  }
76 }
77
78 if ( roar_simple_connect(&con, server, "roarcatad") == -1 ) {
79  ROAR_DBG("roar_simple_play(*): roar_simple_connect() faild!");
80  return 1;
81 }
82
83 if ( roar_stream_new(&s, rate, channels, bits, codec) == -1 ) {
84  roar_disconnect(&con);
85  return 1;
86 }
87
88 if ( roar_stream_connect(&con, &s, ROAR_DIR_PLAY) == -1 ) {
89  roar_disconnect(&con);
90  return 1;
91 }
92
93 info.block_size = BUFSIZE;
94
95 roar_stream_get_info(&con, &s, &info);
96
97 if ( info.block_size > BUFSIZE )
98  info.block_size = BUFSIZE;
99
100 while((i = read(0, buf, info.block_size)))
101  if (roar_stream_add_data(&con, &s, buf, i) == -1)
102   break;
103
104 roar_disconnect(&con);
105
106 return 0;
107}
108
109//ll
Note: See TracBrowser for help on using the repository browser.