Added an untested code path for snd_pcm_wait() SDL-1.2
authorSam Lantinga <slouken@libsdl.org>
Mon, 19 Oct 2009 05:59:07 +0000
branchSDL-1.2
changeset 4363028d26915548
parent 4362 e48a66bed093
child 4364 ae3d564e2716
Added an untested code path for snd_pcm_wait()
src/audio/alsa/SDL_alsa_audio.c
     1.1 --- a/src/audio/alsa/SDL_alsa_audio.c	Mon Oct 19 05:24:48 2009 +0000
     1.2 +++ b/src/audio/alsa/SDL_alsa_audio.c	Mon Oct 19 05:59:07 2009 +0000
     1.3 @@ -85,6 +85,7 @@
     1.4  static int (*SDL_NAME(snd_pcm_sw_params_set_start_threshold))(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_uframes_t val);
     1.5  static int (*SDL_NAME(snd_pcm_sw_params))(snd_pcm_t *pcm, snd_pcm_sw_params_t *params);
     1.6  static int (*SDL_NAME(snd_pcm_nonblock))(snd_pcm_t *pcm, int nonblock);
     1.7 +static int (*SDL_NAME(snd_pcm_wait))(snd_pcm_t *pcm, int timeout);
     1.8  #define snd_pcm_hw_params_sizeof SDL_NAME(snd_pcm_hw_params_sizeof)
     1.9  #define snd_pcm_sw_params_sizeof SDL_NAME(snd_pcm_sw_params_sizeof)
    1.10  
    1.11 @@ -120,6 +121,7 @@
    1.12  	{ "snd_pcm_sw_params_set_start_threshold",	(void**)(char*)&SDL_NAME(snd_pcm_sw_params_set_start_threshold)	},
    1.13  	{ "snd_pcm_sw_params",	(void**)(char*)&SDL_NAME(snd_pcm_sw_params)	},
    1.14  	{ "snd_pcm_nonblock",	(void**)(char*)&SDL_NAME(snd_pcm_nonblock)	},
    1.15 +	{ "snd_pcm_wait",	(void**)(char*)&SDL_NAME(snd_pcm_wait)	},
    1.16  };
    1.17  
    1.18  static void UnloadALSALibrary(void) {
    1.19 @@ -312,10 +314,13 @@
    1.20  	frames_left = ((snd_pcm_uframes_t) this->spec.samples);
    1.21  
    1.22  	while ( frames_left > 0 && this->enabled ) {
    1.23 +		/* This works, but needs more testing before going live */
    1.24 +		/*SDL_NAME(snd_pcm_wait)(pcm_handle, -1);*/
    1.25 +
    1.26  		status = SDL_NAME(snd_pcm_writei)(pcm_handle, sample_buf, frames_left);
    1.27  		if ( status < 0 ) {
    1.28  			if ( status == -EAGAIN ) {
    1.29 -				/* Apparently snd_pcm_recover() doesn't handle this. Foo. */
    1.30 +				/* Apparently snd_pcm_recover() doesn't handle this case - does it assume snd_pcm_wait() above? */
    1.31  				SDL_Delay(1);
    1.32  				continue;
    1.33  			}