source: roaraudio/libroarsndio/para.c @ 2574:ec7d9af6f76b

Last change on this file since 2574:ec7d9af6f76b was 1584:f78a33614107, checked in by phi, 15 years ago

added a lot debug lions

File size: 3.9 KB
RevLine 
[1562]1//para.c:
[1559]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
[1571]33#define ROAR_USE_OWN_SNDIO_HDL
[1559]34#include "libroarsndio.h"
35
[1584]36//#ifndef DEBUG
37//#define DEBUG
38//#endif
39
[1562]40void   sio_initpar(struct sio_par * par) {
41 if ( par == NULL )
42  return;
43
44 memset(par, 0, sizeof(struct sio_par));
45
46 par->bits  = ROAR_BITS_DEFAULT;
47 par->sig   = 1;
48 par->le    = SIO_LE_NATIVE;
49 par->msb   = 1;
50 par->rchan = 0;
51 par->pchan = ROAR_CHANNELS_DEFAULT;
52 par->rate  = ROAR_RATE_DEFAULT;
53 par->bufsz = ROAR_BITS_DEFAULT * ROAR_CHANNELS_DEFAULT * ROAR_RATE_DEFAULT / 800.0;
54 par->round = 1;
55 par->xrun  = SIO_IGNORE;
56
57 return;
58}
59
60int    sio_setpar (struct sio_hdl * hdl, struct sio_par * par) {
[1584]61 if ( hdl == NULL || par == NULL ) {
62  ROAR_DBG("sio_setpar(*): Invalid handle or parameter pointer");
[1566]63  return 0;
[1584]64 }
[1566]65
[1584]66 if ( par->bits == 0 || par->bits > ROAR_BITS_MAX ) {
67  ROAR_DBG("sio_setpar(*): Invalid number of bits: %i Bit", par->bits);
[1566]68  return 0;
[1584]69 }
[1566]70
71 if ( par->bps == 0 )
72  par->bps = SIO_BPS(par->bits);
73
[1584]74 if ( par->bps > ROAR_BITS_MAX/8 ) {
75  ROAR_DBG("sio_setpar(*): Invalid number of bytes: %i Byte", par->bps);
[1566]76  return 0;
[1584]77 }
[1566]78
[1584]79 if ( SIO_BPS(par->bits) > par->bps ) {
80  ROAR_DBG("sio_setpar(*): Number of bits/8 > number of bytes: %i/8 > %i", par->bits, par->bps);
[1566]81  return 0;
[1584]82 }
[1566]83
84 hdl->info.bits = par->bps * 8;
85
86 switch ((par->sig << 4) | par->le) {
87  case 0x00:
88    hdl->info.codec = ROAR_CODEC_PCM_U_BE;
89   break;
90  case 0x01:
91    hdl->info.codec = ROAR_CODEC_PCM_U_LE;
92   break;
93  case 0x10:
94    hdl->info.codec = ROAR_CODEC_PCM_S_BE;
95   break;
96  case 0x11:
97    hdl->info.codec = ROAR_CODEC_PCM_S_LE;
98   break;
99  default:
[1584]100    ROAR_DBG("sio_setpar(*): Invalid codec: sig=%i, le=%i", par->sig, par->le);
[1566]101    return 0;
102 }
103
[1584]104 if ( par->msb == 0 ) {
105  ROAR_DBG("sio_setpar(*): LSM alignment not supported");
[1566]106  return 0;
[1584]107 }
[1566]108
[1584]109 if ( par->rchan != 0 ) { /* not supported yet */
110  ROAR_DBG("sio_setpar(*): Recording not supported");
[1566]111  return 0;
[1584]112 }
[1566]113
[1584]114 if ( par->pchan == 0 || par->pchan > ROAR_MAX_CHANNELS ) {
115  ROAR_DBG("sio_setpar(*): Invalid number of playback channels: %i", par->pchan);
[1566]116  return 0;
[1584]117 }
[1566]118
119 hdl->info.channels = par->pchan;
120
[1584]121 if ( par->rate == 0 ) {
122  ROAR_DBG("sio_setpar(*): Invalid sample rate: %iHz", par->rate);
[1566]123  return 0;
[1584]124 }
[1566]125
126 hdl->info.rate = par->rate;
127
[1584]128 if ( par->xrun != SIO_IGNORE ) {
129  ROAR_DBG("sio_setpar(*): Unsupported xrun mode: %i", par->xrun);
[1566]130  return 0;
[1584]131 }
[1566]132
[1576]133 memcpy(&(hdl->para), par, sizeof(struct sio_par));
134
[1566]135 return 1;
[1562]136}
137
138int    sio_getpar (struct sio_hdl * hdl, struct sio_par * par) {
[1576]139 if ( hdl == NULL || par == NULL )
140  return 0;
141
142 memcpy(par, &(hdl->para), sizeof(struct sio_par));
143
144 return 1;
[1562]145}
146
147int    sio_getcap (struct sio_hdl * hdl, struct sio_cap * cap) {
148 return 0;
149}
150
151
[1559]152//ll
Note: See TracBrowser for help on using the repository browser.