Search
lxdream.org :: lxdream/src/drivers/audio_esd.c
lxdream 0.9.1
released Jun 29
Download Now
filename src/drivers/audio_esd.c
changeset 643:653b0a70f173
prev561:533f6b478071
next697:479b8c213f61
author nkeynes
date Sun Jun 01 00:47:45 2008 +0000 (15 years ago)
permissions -rw-r--r--
last change First cut of the Cocoa GUI implementation
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   return TRUE;
    31 }
    33 gboolean audio_esd_set_format( uint32_t rate, uint32_t format )
    34 {
    35     if( esd_handle != -1 ) {
    36 	esd_close(esd_handle);
    37     }
    38     esd_format_t esd_format = 0;
    39     esd_sample_size = 1;
    40     if( format & AUDIO_FMT_16BIT ) {
    41 	esd_format |= ESD_BITS16;
    42     } else esd_format |= ESD_BITS8;
    43     if( format & AUDIO_FMT_STEREO ) {
    44 	esd_format |= ESD_STEREO;
    45     }
    46     else esd_format |= ESD_MONO;
    48     esd_handle = esd_play_stream( esd_format, rate, "localhost", "lxdream" );
    49     if( esd_handle == -1 ) {
    50 	ERROR( "Unable to open audio output (ESD)" );
    51 	return FALSE;
    52     }
    53     return TRUE;
    54 }
    56 gboolean audio_esd_process_buffer( audio_buffer_t buffer )
    57 {
    58     if( esd_handle != -1 ) {
    59 	write( esd_handle, buffer->data, buffer->length );
    60 	return TRUE;
    61     } else {
    62 	ERROR( "ESD not initialized" );
    63 	return FALSE;
    64     }
    65 }
    67 gboolean audio_esd_close()
    68 {
    69   return TRUE;
    70 }
    72 struct audio_driver audio_esd_driver = { "esd", 
    73 					 audio_esd_init,
    74 					 audio_esd_set_format, 
    75 					 audio_esd_process_buffer,
    76                                          audio_esd_close};
.