source: roaraudio/libroarsndio/libroarsndio.c @ 2358:1a38bdcc3e4d

Last change on this file since 2358:1a38bdcc3e4d was 2357:9b4e7fe1368c, checked in by phi, 15 years ago

changed check for stream mode the way that we can add support for other DIRs, too.

File size: 2.4 KB
Line 
1//libroarsndio.c:
2
3/*
4 *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2009
5 *  The code (may) include prototypes and comments (and maybe
6 *  other code fragements) from EsounD.
7 *  They are mostly copyrighted by Eric B. Mitchell (aka 'Ricdude)
8 *  <ericmit@ix.netcom.com>. For more information see AUTHORS.esd.
9 *
10 *  This file is part of libroaresd a part of RoarAudio,
11 *  a cross-platform sound system for both, home and professional use.
12 *  See README for details.
13 *
14 *  This file is free software; you can redistribute it and/or modify
15 *  it under the terms of the GNU General Public License version 3
16 *  as published by the Free Software Foundation.
17 *
18 *  RoarAudio is distributed in the hope that it will be useful,
19 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
20 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21 *  GNU General Public License for more details.
22 *
23 *  You should have received a copy of the GNU General Public License
24 *  along with this software; see the file COPYING.  If not, write to
25 *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
26 *
27 *  NOTE for everyone want's to change something and send patches:
28 *  read README and HACKING! There a addition information on
29 *  the license of this document you need to read before you send
30 *  any patches.
31 */
32
33#define ROAR_USE_OWN_SNDIO_HDL
34#include "libroarsndio.h"
35
36struct sio_hdl * sio_open(char * name, unsigned mode, int nbio_flag) {
37 struct sio_hdl * hdl = NULL;
38
39 if ( (hdl = malloc(sizeof(struct sio_hdl))) == NULL )
40  return NULL;
41
42 memset(hdl, 0, sizeof(struct sio_hdl));
43
44 switch (mode) {
45  case SIO_PLAY:
46    hdl->dir = ROAR_DIR_PLAY;
47   break;
48  case MIO_OUT:
49  case MIO_IN:
50  case SIO_REC:
51  case SIO_PLAY|SIO_REC:
52  case MIO_OUT|MIO_IN:
53  default:
54    free(hdl);
55    return NULL;
56 }
57
58 if ( roar_simple_connect(&(hdl->con), name, "libroarsndio") == -1 ) {
59  free(hdl);
60  return NULL;
61 }
62
63 sio_initpar(&(hdl->para));
64
65 hdl->stream_opened = 0;
66
67 if ( name != NULL )
68  hdl->device = strdup(name);
69
70 return hdl;
71}
72
73void   sio_close  (struct sio_hdl * hdl) {
74 if ( hdl == NULL )
75  return;
76
77 sio_stop(hdl);
78
79 roar_disconnect(&(hdl->con));
80
81 free(hdl);
82}
83
84int    sio_eof    (struct sio_hdl * hdl) {
85 return 0;
86}
87
88void   sio_onmove (struct sio_hdl * hdl, void (*cb)(void * arg, int delta), void * arg) {
89 if ( hdl == NULL )
90  return;
91
92 hdl->on_move     = cb;
93 hdl->on_move_arg = arg;
94}
95
96//ll
Note: See TracBrowser for help on using the repository browser.