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 1024:c67f2d61ab97
prev736:a02d1475ccfd
author nkeynes
date Sun May 24 19:46:06 2015 +1000 (8 years ago)
permissions -rw-r--r--
last change Remove static from gl_load_frame_buffer() - also needed by video_egl.c
Fix error location in gl_frame_buffer_to_tex
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 static int esd_handle = -1;
    25 static int esd_sample_size = 1;
    28 static 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 static 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 static gboolean audio_esd_shutdown()
    66 {
    67     close(esd_handle);
    68     esd_handle = -1;
    69     return TRUE;
    70 }
    72 static struct audio_driver audio_esd_driver = { 
    73         "esd",
    74         N_("Enlightened Sound Daemon driver"),
    75         30,
    76         DEFAULT_SAMPLE_RATE,
    77         DEFAULT_SAMPLE_FORMAT,
    78         audio_esd_init,
    79         NULL, 
    80         audio_esd_process_buffer,
    81         NULL,
    82         audio_esd_shutdown};
    84 AUDIO_DRIVER( "esd", audio_esd_driver );
.