Updated documentation (Closes: #1014).
[ahxm.git] / out_esd.c
blob23873c6f594e542e3ec7d6a62eb41a37e28edb1d
1 /*
3 Ann Hell Ex Machina - Music Software
4 Copyright (C) 2003/2004 Angel Ortega <angel@triptico.com>
6 out_esd.c - Output driver for the Enlightened Sound Daemon
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License
10 as published by the Free Software Foundation; either version 2
11 of the License, or (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 http://www.triptico.com
26 #include "config.h"
27 #include <stdio.h>
28 #include "output.h"
30 #ifdef ESD
32 #include <unistd.h>
33 #include <esd.h>
34 #include "core.h"
36 /*******************
37 Data
38 ********************/
40 /* esd socket */
41 int _esd_fd;
43 #ifndef ESD_BUFFER_SIZE
44 #define ESD_BUFFER_SIZE 65536
45 #endif
48 /*******************
49 Code
50 ********************/
52 int _out_open_esd(char * file)
54 esd_format_t format;
56 /* ESD does not support more than stereo output */
57 if(_n_channels > 2)
58 _n_channels=2;
60 format = ESD_STREAM | ESD_PLAY | ESD_BITS16;
61 format |= _n_channels == 2 ? ESD_STEREO : ESD_MONO;
63 _esd_fd=esd_open_sound(file);
65 if(_esd_fd < 0)
66 return(-100);
68 _esd_fd=esd_play_stream_fallback(format, _frequency, NULL, "annhell");
70 if(_esd_fd < 0)
71 return(-101);
73 return(ESD_BUFFER_SIZE);
77 int _out_write_esd(short int * buffer, int size)
79 return(write(_esd_fd, buffer, size * sizeof(short int)));
83 int _out_close_esd(void)
85 esd_close(_esd_fd);
87 return(0);
90 /* driver */
92 struct _output_driver _out_driver_esd=
93 { "esd", NULL, _out_open_esd, _out_write_esd, _out_close_esd };
95 #else /* ESD */
97 struct _output_driver _out_driver_esd=
98 { "esd", NULL, NULL, NULL, NULL };
100 #endif /* ESD */