source: roaraudio/roarclients/roarmon.c @ 570:30d91a9ad1be

Last change on this file since 570:30d91a9ad1be was 570:30d91a9ad1be, checked in by phi, 16 years ago

added --codec and fixed error text

File size: 1.5 KB
Line 
1//roarcat.c:
2
3#include <roaraudio.h>
4
5#define BUFSIZE 1024
6
7void usage (void) {
8 printf("roarmon [OPTIONS]...\n");
9
10 printf("\nOptions:\n\n");
11
12 printf("  --server SERVER    - Set server hostname\n"
13        "  --rate   RATE      - Set sample rate\n"
14        "  --bits   BITS      - Set bits per sample\n"
15        "  --chans  CHANNELS  - Set number of channels\n"
16        "  --codec  CODEC     - Set the codec\n"
17        "  --help             - Show this help\n"
18       );
19
20}
21
22int main (int argc, char * argv[]) {
23 int    rate     = 44100;
24 int    bits     = 16;
25 int    channels = 2;
26 int    codec    = ROAR_CODEC_DEFAULT;
27 char * server   = NULL;
28 char * k;
29 int    fh;
30 int    i;
31 char buf[BUFSIZE];
32
33 for (i = 1; i < argc; i++) {
34  k = argv[i];
35
36  if ( strcmp(k, "--server") == 0 ) {
37   server = argv[++i];
38  } else if ( strcmp(k, "--rate") == 0 ) {
39   rate = atoi(argv[++i]);
40  } else if ( strcmp(k, "--bits") == 0 ) {
41   bits = atoi(argv[++i]);
42  } else if ( strcmp(k, "--channels") == 0 ) {
43   channels = atoi(argv[++i]);
44  } else if ( strcmp(k, "--codec") == 0 ) {
45   codec = roar_str2codec(argv[++i]);
46  } else if ( strcmp(k, "--help") == 0 ) {
47   usage();
48   return 0;
49  } else {
50   fprintf(stderr, "Error: unknown argument: %s\n", k);
51   usage();
52   return 1;
53  }
54 }
55
56 if ( (fh = roar_simple_monitor(rate, channels, bits, codec, server, "roarmon")) == -1 ) {
57  fprintf(stderr, "Error: can not start monetoring\n");
58  return 1;
59 }
60
61 while((i = read(fh, buf, BUFSIZE)))
62  if (write(1, buf, i) != i)
63   break;
64
65 roar_simple_close(fh);
66
67 return 0;
68}
69
70//ll
Note: See TracBrowser for help on using the repository browser.