source: roaraudio/libroarsndio/para.c @ 1566:952d80a40019

Last change on this file since 1566:952d80a40019 was 1566:952d80a40019, checked in by phi, 15 years ago

wrote a basic sio_setpar()

File size: 2.9 KB
Line 
1//para.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#include "libroarsndio.h"
34
35void   sio_initpar(struct sio_par * par) {
36 if ( par == NULL )
37  return;
38
39 memset(par, 0, sizeof(struct sio_par));
40
41 par->bits  = ROAR_BITS_DEFAULT;
42 par->sig   = 1;
43 par->le    = SIO_LE_NATIVE;
44 par->msb   = 1;
45 par->rchan = 0;
46 par->pchan = ROAR_CHANNELS_DEFAULT;
47 par->rate  = ROAR_RATE_DEFAULT;
48 par->bufsz = ROAR_BITS_DEFAULT * ROAR_CHANNELS_DEFAULT * ROAR_RATE_DEFAULT / 800.0;
49 par->round = 1;
50 par->xrun  = SIO_IGNORE;
51
52 return;
53}
54
55int    sio_setpar (struct sio_hdl * hdl, struct sio_par * par) {
56 if ( hdl == NULL )
57  return 0;
58
59 if ( par->bits == 0 || par->bits > ROAR_BITS_MAX )
60  return 0;
61
62 if ( par->bps == 0 )
63  par->bps = SIO_BPS(par->bits);
64
65 if ( par->bps > ROAR_BITS_MAX/8 )
66  return 0;
67
68 if ( SIO_BPS(par->bits) > par->bps )
69  return 0;
70
71 hdl->info.bits = par->bps * 8;
72
73 switch ((par->sig << 4) | par->le) {
74  case 0x00:
75    hdl->info.codec = ROAR_CODEC_PCM_U_BE;
76   break;
77  case 0x01:
78    hdl->info.codec = ROAR_CODEC_PCM_U_LE;
79   break;
80  case 0x10:
81    hdl->info.codec = ROAR_CODEC_PCM_S_BE;
82   break;
83  case 0x11:
84    hdl->info.codec = ROAR_CODEC_PCM_S_LE;
85   break;
86  default:
87    return 0;
88 }
89
90 if ( par->msb == 0 )
91  return 0;
92
93 if ( par->rchan != 0 ) /* not supported yet */
94  return 0;
95
96 if ( par->pchan == 0 || par->pchan > ROAR_MAX_CHANNELS )
97  return 0;
98
99 hdl->info.channels = par->pchan;
100
101 if ( par->rate == 0 )
102  return 0;
103
104 hdl->info.rate = par->rate;
105
106 if ( par->xrun != SIO_IGNORE )
107  return 0;
108
109 return 1;
110}
111
112int    sio_getpar (struct sio_hdl * hdl, struct sio_par * par) {
113 return 0;
114}
115
116int    sio_getcap (struct sio_hdl * hdl, struct sio_cap * cap) {
117 return 0;
118}
119
120
121//ll
Note: See TracBrowser for help on using the repository browser.