4 * The esd (esound) audio driver
6 * Copyright (c) 2005 Nathan Keynes.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (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.
21 #include "aica/audio.h"
24 static int esd_handle = -1;
25 static int esd_sample_size = 1;
28 static gboolean audio_esd_init()
30 int format = DEFAULT_SAMPLE_FORMAT;
31 int rate = DEFAULT_SAMPLE_RATE;
33 if( esd_handle != -1 ) {
34 esd_close(esd_handle);
36 esd_format_t esd_format = 0;
38 if( format & AUDIO_FMT_16BIT ) {
39 esd_format |= ESD_BITS16;
40 } else esd_format |= ESD_BITS8;
41 if( format & AUDIO_FMT_STEREO ) {
42 esd_format |= ESD_STEREO;
44 else esd_format |= ESD_MONO;
46 esd_handle = esd_play_stream( esd_format, rate, "localhost", "lxdream" );
47 if( esd_handle == -1 ) {
48 ERROR( "Unable to open audio output (ESD)" );
54 static gboolean audio_esd_process_buffer( audio_buffer_t buffer )
56 if( esd_handle != -1 ) {
57 write( esd_handle, buffer->data, buffer->length );
60 ERROR( "ESD not initialized" );
65 static gboolean audio_esd_shutdown()
72 static struct audio_driver audio_esd_driver = {
74 N_("Enlightened Sound Daemon driver"),
77 DEFAULT_SAMPLE_FORMAT,
80 audio_esd_process_buffer,
84 AUDIO_DRIVER( "esd", audio_esd_driver );
.