Search
lxdream.org :: lxdream/src/drivers/audio_alsa.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/drivers/audio_alsa.c
changeset 736:a02d1475ccfd
prev724:f2bc1c7cca14
next806:6ef1ce4a9dbc
author nkeynes
date Mon Jul 14 07:44:42 2008 +0000 (11 years ago)
permissions -rw-r--r--
last change Re-indent everything consistently
Fix include guards for consistency as well
file annotate diff log raw
1.1 --- a/src/drivers/audio_alsa.c Sun Jul 06 03:17:32 2008 +0000
1.2 +++ b/src/drivers/audio_alsa.c Mon Jul 14 07:44:42 2008 +0000
1.3 @@ -32,8 +32,8 @@
1.4
1.5
1.6 struct lxdream_config_entry alsa_config[] = {
1.7 - {"device", N_("Audio output device"), CONFIG_TYPE_FILE, "default"},
1.8 - {NULL, CONFIG_TYPE_NONE}
1.9 + {"device", N_("Audio output device"), CONFIG_TYPE_FILE, "default"},
1.10 + {NULL, CONFIG_TYPE_NONE}
1.11 };
1.12
1.13
1.14 @@ -51,12 +51,12 @@
1.15
1.16 // Open the device we were told to open.
1.17 err = snd_pcm_open( &_soundDevice, alsa_config[0].value,
1.18 - SND_PCM_STREAM_PLAYBACK, 0 );
1.19 + SND_PCM_STREAM_PLAYBACK, 0 );
1.20
1.21 // Check for error on open.
1.22 if ( err < 0 ) {
1.23 ERROR( "Init: cannot open audio device %s (%s)\n",
1.24 - alsa_config[0].value, snd_strerror( err ) );
1.25 + alsa_config[0].value, snd_strerror( err ) );
1.26 return FALSE;
1.27 } else {
1.28 DEBUG( "Audio device opened successfully." );
1.29 @@ -69,26 +69,26 @@
1.30 // Allocate the hardware parameter structure.
1.31 if ( ( err = snd_pcm_hw_params_malloc( &hw_params ) ) < 0 ) {
1.32 ERROR( "Init: cannot allocate hardware parameter structure (%s)\n",
1.33 - snd_strerror( err ) );
1.34 + snd_strerror( err ) );
1.35 return FALSE;
1.36 }
1.37
1.38 if ( ( err = snd_pcm_hw_params_any( _soundDevice, hw_params ) ) < 0 ) {
1.39 ERROR( "Init: cannot allocate hardware parameter structure (%s)\n",
1.40 - snd_strerror( err ) );
1.41 + snd_strerror( err ) );
1.42 return FALSE;
1.43 }
1.44 // Set access to RW interleaved.
1.45 if ( ( err = snd_pcm_hw_params_set_access( _soundDevice, hw_params,
1.46 - SND_PCM_ACCESS_RW_INTERLEAVED ) )
1.47 - < 0 ) {
1.48 + SND_PCM_ACCESS_RW_INTERLEAVED ) )
1.49 + < 0 ) {
1.50 ERROR( " Init: cannot set access type (%s)\n", snd_strerror( err ) );
1.51 return FALSE;
1.52 }
1.53
1.54 if ( ( err = snd_pcm_hw_params_set_format( _soundDevice, hw_params,
1.55 - SND_PCM_FORMAT_S16_LE ) ) <
1.56 - 0 ) {
1.57 + SND_PCM_FORMAT_S16_LE ) ) <
1.58 + 0 ) {
1.59 ERROR( "Init: cannot set sample format (%s)\n", snd_strerror( err ) );
1.60 return FALSE;
1.61 }
1.62 @@ -96,7 +96,7 @@
1.63 err = snd_pcm_hw_params_set_rate_near( _soundDevice, hw_params, &rate, 0 );
1.64 if ( err < 0 ) {
1.65 ERROR( "Init: Resampling setup failed for playback: %s\n",
1.66 - snd_strerror( err ) );
1.67 + snd_strerror( err ) );
1.68 return err;
1.69 }
1.70 // Set channels to stereo (2).
1.71 @@ -143,14 +143,14 @@
1.72 snd_pcm_sw_params_set_start_threshold( _soundDevice, sw_params, bufferSize/2 );
1.73 err = snd_pcm_sw_params( _soundDevice, sw_params );
1.74 if( err < 0 ) {
1.75 - ERROR("Unable to set sw params for alsa driver: %s\n", snd_strerror(err));
1.76 - return FALSE;
1.77 + ERROR("Unable to set sw params for alsa driver: %s\n", snd_strerror(err));
1.78 + return FALSE;
1.79 }
1.80
1.81 err = snd_pcm_prepare( _soundDevice );
1.82 if ( err < 0 ) {
1.83 ERROR( "Init: cannot prepare audio interface for use (%s)\n",
1.84 - snd_strerror( err ) );
1.85 + snd_strerror( err ) );
1.86 return FALSE;
1.87 }
1.88 return TRUE;
1.89 @@ -166,9 +166,9 @@
1.90
1.91 err = snd_pcm_writei( _soundDevice, buffer->data, length );
1.92 if( err == -EPIPE ) {
1.93 - snd_pcm_prepare( _soundDevice );
1.94 + snd_pcm_prepare( _soundDevice );
1.95 } else if( err == -ESTRPIPE ) {
1.96 - snd_pcm_resume( _soundDevice );
1.97 + snd_pcm_resume( _soundDevice );
1.98 }
1.99
1.100 return TRUE;
1.101 @@ -183,13 +183,13 @@
1.102
1.103
1.104 struct audio_driver audio_alsa_driver = {
1.105 - "alsa",
1.106 - N_("Linux ALSA system driver"),
1.107 - DEFAULT_SAMPLE_RATE,
1.108 - DEFAULT_SAMPLE_FORMAT,
1.109 - audio_alsa_init,
1.110 - NULL,
1.111 - audio_alsa_process_buffer,
1.112 - NULL,
1.113 - audio_alsa_shutdown
1.114 + "alsa",
1.115 + N_("Linux ALSA system driver"),
1.116 + DEFAULT_SAMPLE_RATE,
1.117 + DEFAULT_SAMPLE_FORMAT,
1.118 + audio_alsa_init,
1.119 + NULL,
1.120 + audio_alsa_process_buffer,
1.121 + NULL,
1.122 + audio_alsa_shutdown
1.123 };
.