Search
lxdream.org :: lxdream/src/drivers/audio_esd.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/drivers/audio_esd.c
changeset 66:2ec5b6eb75e5
next73:0bb57e51ac9e
author nkeynes
date Tue Jan 10 13:56:54 2006 +0000 (14 years ago)
permissions -rw-r--r--
last change Go go gadget audio!
Slow, but it works :)
file annotate diff log raw
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/src/drivers/audio_esd.c Tue Jan 10 13:56:54 2006 +0000
1.3 @@ -0,0 +1,58 @@
1.4 +/**
1.5 + * $Id: audio_esd.c,v 1.1 2006-01-10 13:56:54 nkeynes Exp $
1.6 + *
1.7 + * The esd (esound) audio driver
1.8 + *
1.9 + * Copyright (c) 2005 Nathan Keynes.
1.10 + *
1.11 + * This program is free software; you can redistribute it and/or modify
1.12 + * it under the terms of the GNU General Public License as published by
1.13 + * the Free Software Foundation; either version 2 of the License, or
1.14 + * (at your option) any later version.
1.15 + *
1.16 + * This program is distributed in the hope that it will be useful,
1.17 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1.18 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1.19 + * GNU General Public License for more details.
1.20 + */
1.21 +#include <esd.h>
1.22 +#include "aica/audio.h"
1.23 +#include "dream.h"
1.24 +
1.25 +int esd_handle = -1;
1.26 +int esd_sample_size = 1;
1.27 +
1.28 +gboolean esd_audio_set_format( uint32_t rate, uint32_t format )
1.29 +{
1.30 + if( esd_handle != -1 ) {
1.31 + esd_close(esd_handle);
1.32 + }
1.33 + esd_format_t esd_format = 0;
1.34 + esd_sample_size = 1;
1.35 + if( format & AUDIO_FMT_16BIT ) {
1.36 + esd_format |= ESD_BITS16;
1.37 + esd_sample_size = 1;
1.38 + } else esd_format |= ESD_BITS8;
1.39 + if( format & AUDIO_FMT_STEREO ) {
1.40 + esd_format |= ESD_STEREO;
1.41 + esd_sample_size = esd_sample_size << 1 ;
1.42 + }
1.43 + else esd_format |= ESD_MONO;
1.44 +
1.45 + esd_handle = esd_play_stream( esd_format, rate, "localhost", "dreamon" );
1.46 + return TRUE;
1.47 +}
1.48 +
1.49 +gboolean esd_audio_process_buffer( audio_buffer_t buffer )
1.50 +{
1.51 + if( esd_handle != -1 ) {
1.52 + write( esd_handle, buffer->data, buffer->length * esd_sample_size );
1.53 + DEBUG("Wrote buffer" );
1.54 + } else {
1.55 + ERROR( "ESD not initialized" );
1.56 + }
1.57 + return TRUE;
1.58 +}
1.59 +
1.60 +struct audio_driver esd_audio_driver = { esd_audio_set_format, esd_audio_process_buffer };
1.61 +
.