Search
lxdream.org :: lxdream/src/aica/audio.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/aica/audio.c
changeset 111:230243c2b520
prev106:9048bac046c3
next242:04f5cdb68d8e
author nkeynes
date Thu Mar 16 12:41:59 2006 +0000 (15 years ago)
permissions -rw-r--r--
last change Handle driver-unable-to-init case
file annotate diff log raw
1.1 --- a/src/aica/audio.c Tue Mar 14 12:45:53 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 /**
.