Search
lxdream.org :: lxdream :: r111:230243c2b520
lxdream 0.9.1
released Jun 29
Download Now
changeset111:230243c2b520
parent110:83a33da5ed06
child112:a3008ac0765a
authornkeynes
dateThu Mar 16 12:41:59 2006 +0000 (14 years ago)
Handle driver-unable-to-init case
src/aica/audio.c
src/aica/audio.h
src/drivers/audio_esd.c
src/main.c
1.1 --- a/src/aica/audio.c Wed Mar 15 13:17:40 2006 +0000
1.2 +++ b/src/aica/audio.c Thu Mar 16 12:41:59 2006 +0000
1.3 @@ -1,5 +1,5 @@
1.4 /**
1.5 - * $Id: audio.c,v 1.5 2006-03-14 12:45:53 nkeynes Exp $
1.6 + * $Id: audio.c,v 1.6 2006-03-16 12:41:59 nkeynes Exp $
1.7 *
1.8 * Audio mixer core. Combines all the active streams into a single sound
1.9 * buffer for output.
1.10 @@ -52,13 +52,23 @@
1.11 * output buffers, flushing any current data and reallocating as
1.12 * necessary.
1.13 */
1.14 -void audio_set_driver( audio_driver_t driver,
1.15 - uint32_t samplerate, int format )
1.16 +gboolean audio_set_driver( audio_driver_t driver,
1.17 + uint32_t samplerate, int format )
1.18 {
1.19 uint32_t bytes_per_sample = 1;
1.20 uint32_t samples_per_buffer;
1.21 int i;
1.22
1.23 + if( audio_driver == NULL || driver != NULL ) {
1.24 + if( driver == NULL )
1.25 + driver = &audio_null_driver;
1.26 + if( driver != audio_driver ) {
1.27 + if( !driver->set_output_format( samplerate, format ) )
1.28 + return FALSE;
1.29 + audio_driver = driver;
1.30 + }
1.31 + }
1.32 +
1.33 if( format & AUDIO_FMT_16BIT )
1.34 bytes_per_sample = 2;
1.35 if( format & AUDIO_FMT_STEREO )
1.36 @@ -81,10 +91,7 @@
1.37 audio.write_buffer = 0;
1.38 audio.read_buffer = 0;
1.39
1.40 - if( driver == NULL )
1.41 - driver = &audio_null_driver;
1.42 - audio_driver = driver;
1.43 - audio_driver->set_output_format( samplerate, format );
1.44 + return TRUE;
1.45 }
1.46
1.47 /**
2.1 --- a/src/aica/audio.h Wed Mar 15 13:17:40 2006 +0000
2.2 +++ b/src/aica/audio.h Thu Mar 16 12:41:59 2006 +0000
2.3 @@ -1,5 +1,5 @@
2.4 /**
2.5 - * $Id: audio.h,v 1.6 2006-03-14 12:45:53 nkeynes Exp $
2.6 + * $Id: audio.h,v 1.7 2006-03-16 12:41:59 nkeynes Exp $
2.7 *
2.8 * Audio engine, ie the part that does the actual work.
2.9 *
2.10 @@ -76,7 +76,7 @@
2.11 * output buffers, flushing any current data and reallocating as
2.12 * necessary. Must be called before attempting to generate any audio.
2.13 */
2.14 -void audio_set_driver( audio_driver_t driver, uint32_t samplerate,
2.15 +gboolean audio_set_driver( audio_driver_t driver, uint32_t samplerate,
2.16 int format );
2.17
2.18 /**
3.1 --- a/src/drivers/audio_esd.c Wed Mar 15 13:17:40 2006 +0000
3.2 +++ b/src/drivers/audio_esd.c Thu Mar 16 12:41:59 2006 +0000
3.3 @@ -1,5 +1,5 @@
3.4 /**
3.5 - * $Id: audio_esd.c,v 1.6 2006-03-14 12:45:53 nkeynes Exp $
3.6 + * $Id: audio_esd.c,v 1.7 2006-03-16 12:41:56 nkeynes Exp $
3.7 *
3.8 * The esd (esound) audio driver
3.9 *
3.10 @@ -40,6 +40,7 @@
3.11 esd_handle = esd_play_stream( esd_format, rate, "localhost", "dreamon" );
3.12 if( esd_handle == -1 ) {
3.13 ERROR( "Unable to open audio output (ESD)" );
3.14 + return FALSE;
3.15 }
3.16 return TRUE;
3.17 }
4.1 --- a/src/main.c Wed Mar 15 13:17:40 2006 +0000
4.2 +++ b/src/main.c Thu Mar 16 12:41:59 2006 +0000
4.3 @@ -1,5 +1,5 @@
4.4 /**
4.5 - * $Id: main.c,v 1.15 2006-03-14 12:45:50 nkeynes Exp $
4.6 + * $Id: main.c,v 1.16 2006-03-16 12:41:59 nkeynes Exp $
4.7 *
4.8 * Main program, initializes dreamcast and gui, then passes control off to
4.9 * the gtk main loop (currently).
4.10 @@ -116,7 +116,9 @@
4.11
4.12 for( i=0; audio_driver_list[i] != NULL; i++ ) {
4.13 if( strcasecmp( audio_driver_list[i]->name, audio_driver_name ) == 0 ) {
4.14 - audio_set_driver( audio_driver_list[i], 44100, AUDIO_FMT_16ST );
4.15 + if( audio_set_driver( audio_driver_list[i], 44100, AUDIO_FMT_16ST ) == FALSE ) {
4.16 + audio_set_driver( &audio_null_driver, 44100, AUDIO_FMT_16ST );
4.17 + }
4.18 break;
4.19 }
4.20
.