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 424:421d68e78c46
prev180:e6dcf9b65658
next561:533f6b478071
author nkeynes
date Tue Oct 16 12:27:28 2007 +0000 (16 years ago)
permissions -rw-r--r--
last change Unbind the framebuffer after initialization
view annotate diff log raw
     1 /**
     2  * $Id: audio_esd.c,v 1.9 2007-10-07 05:42:25 nkeynes Exp $
     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;
    27 gboolean audio_esd_set_format( uint32_t rate, uint32_t format )
    28 {
    29     if( esd_handle != -1 ) {
    30 	esd_close(esd_handle);
    31     }
    32     esd_format_t esd_format = 0;
    33     esd_sample_size = 1;
    34     if( format & AUDIO_FMT_16BIT ) {
    35 	esd_format |= ESD_BITS16;
    36     } else esd_format |= ESD_BITS8;
    37     if( format & AUDIO_FMT_STEREO ) {
    38 	esd_format |= ESD_STEREO;
    39     }
    40     else esd_format |= ESD_MONO;
    42     esd_handle = esd_play_stream( esd_format, rate, "localhost", "lxdream" );
    43     if( esd_handle == -1 ) {
    44 	ERROR( "Unable to open audio output (ESD)" );
    45 	return FALSE;
    46     }
    47     return TRUE;
    48 }
    50 gboolean audio_esd_process_buffer( audio_buffer_t buffer )
    51 {
    52     if( esd_handle != -1 ) {
    53 	write( esd_handle, buffer->data, buffer->length );
    54 	return TRUE;
    55     } else {
    56 	ERROR( "ESD not initialized" );
    57 	return FALSE;
    58     }
    59 }
    61 struct audio_driver audio_esd_driver = { "esd", audio_esd_set_format, audio_esd_process_buffer };
.