source: roaraudio/roarclients/roarphone.c @ 2126:3937527b4c96

Last change on this file since 2126:3937527b4c96 was 2126:3937527b4c96, checked in by phi, 15 years ago

open driver and directly close it again

File size: 2.6 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        "  --help             - Show this help\n"
43       );
44
45}
46
47int main (int argc, char * argv[]) {
48 struct roar_audio_info info = {.rate     = ROAR_RATE_DEFAULT,
49                                .bits     = ROAR_BITS_DEFAULT,
50                                .channels = ROAR_CHANNELS_DEFAULT,
51                                .codec    = ROAR_CODEC_DEFAULT
52                               };
53 struct roar_vio_calls dvio;
54 char * driver   = DRIVER;
55 char * device   = NULL;
56 char * server   = NULL;
57 char * k;
58 int    i;
59
60 for (i = 1; i < argc; i++) {
61  k = argv[i];
62
63  if ( strcmp(k, "--server") == 0 ) {
64   server = argv[++i];
65  } else if ( strcmp(k, "--rate") == 0 ) {
66   info.rate = atoi(argv[++i]);
67  } else if ( strcmp(k, "--bits") == 0 ) {
68   info.bits = atoi(argv[++i]);
69  } else if ( strcmp(k, "--channels") == 0 || strcmp(k, "--chans") == 0 ) {
70   info.channels = atoi(argv[++i]);
71  } else if ( strcmp(k, "--codec") == 0 ) {
72   info.codec = roar_str2codec(argv[++i]);
73  } else if ( strcmp(k, "--help") == 0 ) {
74   usage();
75   return 0;
76  } else {
77   fprintf(stderr, "Error: unknown argument: %s\n", k);
78   usage();
79   return 1;
80  }
81 }
82
83 if ( roar_cdriver_open(&dvio, driver, device, &info, ROAR_DIR_BIDIR) == -1 ) {
84  return 1;
85 }
86
87 roar_vio_close(&dvio);
88
89 return 0;
90}
91
92//ll
Note: See TracBrowser for help on using the repository browser.