filename | src/drivers/audio_esd.c |
changeset | 697:479b8c213f61 |
prev | 643:653b0a70f173 |
next | 700:4650d0c7f6f9 |
author | nkeynes |
date | Sun Jun 22 04:01:27 2008 +0000 (15 years ago) |
permissions | -rw-r--r-- |
last change | Commit work-in-progress CoreAudio driver (along with various changes to the audio subsystem) |
view | annotate | diff | log | raw |
1 /**
2 * $Id$
3 *
4 * The esd (esound) audio driver
5 *
6 * Copyright (c) 2005 Nathan Keynes.
7 *
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.
12 *
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.
17 */
18 #include <stdio.h>
19 #include <unistd.h>
20 #include <esd.h>
21 #include "aica/audio.h"
22 #include "dream.h"
24 int esd_handle = -1;
25 int esd_sample_size = 1;
28 gboolean audio_esd_init()
29 {
30 int format = DEFAULT_SAMPLE_FORMAT;
31 int rate = DEFAULT_SAMPLE_RATE;
33 if( esd_handle != -1 ) {
34 esd_close(esd_handle);
35 }
36 esd_format_t esd_format = 0;
37 esd_sample_size = 1;
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;
43 }
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)" );
49 return FALSE;
50 }
51 return TRUE;
52 }
54 gboolean audio_esd_process_buffer( audio_buffer_t buffer )
55 {
56 if( esd_handle != -1 ) {
57 write( esd_handle, buffer->data, buffer->length );
58 return TRUE;
59 } else {
60 ERROR( "ESD not initialized" );
61 return FALSE;
62 }
63 }
65 gboolean audio_esd_shutdown()
66 {
67 close(esd_handle);
68 esd_handle = -1;
69 return TRUE;
70 }
72 struct audio_driver audio_esd_driver = { "esd",
73 DEFAULT_SAMPLE_RATE,
74 DEFAULT_SAMPLE_FORMAT,
75 audio_esd_init,
76 NULL,
77 audio_esd_process_buffer,
78 NULL,
79 audio_esd_shutdown};
.