source: roaraudio/roarclients/roarphone.c @ 2128:acc3365dd9d5

Last change on this file since 2128:acc3365dd9d5 was 2128:acc3365dd9d5, checked in by phi, 15 years ago

connect a stream, added a dummy function to send the data

File size: 3.4 KB
Line 
1//roarbidir.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#include "driver.h"
27
28#define BUFSIZE 1024
29
30#define DRIVER  "oss"
31
32void usage (void) {
33 printf("roarcat [OPTIONS]...\n");
34
35 printf("\nOptions:\n\n");
36
37 printf("  --server SERVER    - Set server hostname\n"
38        "  --rate   RATE      - Set sample rate\n"
39        "  --bits   BITS      - Set bits per sample\n"
40        "  --chans  CHANNELS  - Set number of channels\n"
41        "  --codec  CODEC     - Set the codec\n"
42        "  --driver DRIVER    - Set the driver\n"
43        "  --device DEVICE    - Set the device\n"
44        "  --help             - Show this help\n"
45       );
46
47}
48
49int open_stream (struct roar_vio_calls * vio, char * server, struct roar_audio_info * info) {
50 return roar_vio_simple_stream(vio,
51                               info->rate, info->channels, info->bits, info->codec,
52                               server,
53                               ROAR_DIR_BIDIR,
54                               "roarphone");
55}
56
57int run_stream (struct roar_vio_calls * s0, struct roar_vio_calls * s1, struct roar_audio_info * info) {
58 return -1;
59}
60
61int main (int argc, char * argv[]) {
62 struct roar_audio_info info = {.rate     = ROAR_RATE_DEFAULT,
63                                .bits     = ROAR_BITS_DEFAULT,
64                                .channels = ROAR_CHANNELS_DEFAULT,
65                                .codec    = ROAR_CODEC_DEFAULT
66                               };
67 struct roar_vio_calls dvio, svio;
68 char * driver   = DRIVER;
69 char * device   = NULL;
70 char * server   = NULL;
71 char * k;
72 int    i;
73
74 for (i = 1; i < argc; i++) {
75  k = argv[i];
76
77  if ( strcmp(k, "--server") == 0 ) {
78   server = argv[++i];
79  } else if ( strcmp(k, "--rate") == 0 ) {
80   info.rate = atoi(argv[++i]);
81  } else if ( strcmp(k, "--bits") == 0 ) {
82   info.bits = atoi(argv[++i]);
83  } else if ( strcmp(k, "--channels") == 0 || strcmp(k, "--chans") == 0 ) {
84   info.channels = atoi(argv[++i]);
85  } else if ( strcmp(k, "--codec") == 0 ) {
86   info.codec = roar_str2codec(argv[++i]);
87  } else if ( strcmp(k, "--driver") == 0 ) {
88   driver = argv[++i];
89  } else if ( strcmp(k, "--device") == 0 ) {
90   device = argv[++i];
91  } else if ( strcmp(k, "--help") == 0 ) {
92   usage();
93   return 0;
94  } else {
95   fprintf(stderr, "Error: unknown argument: %s\n", k);
96   usage();
97   return 1;
98  }
99 }
100
101 if ( roar_cdriver_open(&dvio, driver, device, &info, ROAR_DIR_BIDIR) == -1 ) {
102  return 1;
103 }
104
105 if ( open_stream(&svio, server, &info) == -1 ) {
106  roar_vio_close(&dvio);
107  return 2;
108 }
109
110 run_stream(&svio, &dvio, &info);
111
112 roar_vio_close(&svio);
113 roar_vio_close(&dvio);
114
115 return 0;
116}
117
118//ll
Note: See TracBrowser for help on using the repository browser.