source: roaraudio/roard/driver_esd.c @ 3591:5519fe5c1e85

Last change on this file since 3591:5519fe5c1e85 was 3591:5519fe5c1e85, checked in by phi, 14 years ago

updated ESD driver

File size: 2.0 KB
Line 
1//driver_esd.c:
2
3/*
4 *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2010
5 *
6 *  This file is part of roard 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, 51 Franklin Street, Fifth Floor,
22 *  Boston, MA 02110-1301, USA.
23 *
24 */
25
26#include "roard.h"
27#ifdef ROAR_HAVE_ESD
28
29/*
30 We could use inst as our fh directly. But esd works with unsigned at 8 bits and
31 signed at 16 bits per sample. (why???) so we need to convert because we get signed at both,
32 8 and 16 bits per sample. so we use inst as an array of two ints: 0: fh, 1: are we in 8 bit mode?
33*/
34
35int driver_esd_open_vio(struct roar_vio_calls * inst, char * device, struct roar_audio_info * info, int fh, struct roar_stream_server * sstream) {
36 esd_format_t format = ESD_STREAM | ESD_PLAY;
37 char name[80] = "roard";
38
39 if ( fh != -1 )
40  return -1;
41
42 if ( info->bits >= 16 ) {
43  info->bits  = 16;
44  format     |= ESD_BITS16;
45  info->codec = ROAR_CODEC_PCM_S;
46 } else if ( info->bits < 16 ) {
47  info->bits  =  8;
48  format     |= ESD_BITS8;
49  info->codec = ROAR_CODEC_PCM_U;
50 }
51
52 if ( info->channels >= 2 ) {
53  info->channels  = 2;
54  format         |= ESD_STEREO;
55 } else {
56  info->channels  = 1;
57  format         |= ESD_MONO;
58 }
59
60 fh = esd_play_stream_fallback(format, info->rate, device, name);
61
62 shutdown(fh, SHUT_RD);
63
64 roar_vio_set_fh(inst, fh);
65
66 return 0;
67}
68
69
70#endif
71//ll
Note: See TracBrowser for help on using the repository browser.