source: roaraudio/roarclients/roarcatad.c @ 6030:9dc3e59a3ac5

Last change on this file since 6030:9dc3e59a3ac5 was 5961:06e7fd9e4c25, checked in by phi, 10 years ago

Updates of copyright and license headers

File size: 2.8 KB
RevLine 
[0]1//roarcatad.c:
2
[669]3/*
[5961]4 *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2014
[669]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
[3517]21 *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
22 *  Boston, MA 02110-1301, USA.
[669]23 *
24 */
25
[0]26#include <roaraudio.h>
27
[288]28#define BUFSIZE (1024*2)
[0]29
30void usage (void) {
[287]31 printf("roarcatad [OPTIONS]...\n");
[0]32
33 printf("\nOptions:\n\n");
34
35 printf("  --server SERVER    - Set server hostname\n"
36        "  --rate   RATE      - Set sample rate\n"
37        "  --bits   BITS      - Set bits per sample\n"
38        "  --chans  CHANNELS  - Set number of channels\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;
[5534]49 const char * server   = NULL;
50 const char * k;
[0]51 int    i;
52 char buf[BUFSIZE];
53 struct roar_connection con;
54 struct roar_stream     s;
[488]55 struct roar_stream_info info;
[0]56
57
[5109]58 roar_debug_bin_obsolete(argv[0], "roarcat", NULL);
59
[0]60 for (i = 1; i < argc; i++) {
61  k = argv[i];
62
63  if ( strcmp(k, "--server") == 0 ) {
[58]64   server = argv[++i];
[0]65  } else if ( strcmp(k, "--rate") == 0 ) {
66   rate = atoi(argv[++i]);
67  } else if ( strcmp(k, "--bits") == 0 ) {
68   bits = atoi(argv[++i]);
69  } else if ( strcmp(k, "--channels") == 0 ) {
70   channels = atoi(argv[++i]);
71  } else if ( strcmp(k, "--help") == 0 ) {
72   usage();
73   return 0;
74  } else {
75   fprintf(stderr, "Error: unknown argument: %s\n", k);
76   usage();
77   return 1;
78  }
79 }
80
81 if ( roar_simple_connect(&con, server, "roarcatad") == -1 ) {
82  ROAR_DBG("roar_simple_play(*): roar_simple_connect() faild!");
[1405]83  return 1;
[0]84 }
85
86 if ( roar_stream_new(&s, rate, channels, bits, codec) == -1 ) {
87  roar_disconnect(&con);
[1405]88  return 1;
[0]89 }
90
[5238]91 if ( roar_stream_connect(&con, &s, ROAR_DIR_PLAY, -1) == -1 ) {
[0]92  roar_disconnect(&con);
[1405]93  return 1;
[0]94 }
95
[488]96 info.block_size = BUFSIZE;
97
98 roar_stream_get_info(&con, &s, &info);
99
100 if ( info.block_size > BUFSIZE )
101  info.block_size = BUFSIZE;
102
103 while((i = read(0, buf, info.block_size)))
[0]104  if (roar_stream_add_data(&con, &s, buf, i) == -1)
105   break;
106
107 roar_disconnect(&con);
108
109 return 0;
110}
111
112//ll
Note: See TracBrowser for help on using the repository browser.