src/audio/alsa/SDL_alsa_audio.c
branchSDL-1.2
changeset 4362 e48a66bed093
parent 4361 991e4bcfc7a8
child 4363 028d26915548
equal deleted inserted replaced
4361:991e4bcfc7a8 4362:e48a66bed093
   312 	frames_left = ((snd_pcm_uframes_t) this->spec.samples);
   312 	frames_left = ((snd_pcm_uframes_t) this->spec.samples);
   313 
   313 
   314 	while ( frames_left > 0 && this->enabled ) {
   314 	while ( frames_left > 0 && this->enabled ) {
   315 		status = SDL_NAME(snd_pcm_writei)(pcm_handle, sample_buf, frames_left);
   315 		status = SDL_NAME(snd_pcm_writei)(pcm_handle, sample_buf, frames_left);
   316 		if ( status < 0 ) {
   316 		if ( status < 0 ) {
       
   317 			if ( status == -EAGAIN ) {
       
   318 				/* Apparently snd_pcm_recover() doesn't handle this. Foo. */
       
   319 				SDL_Delay(1);
       
   320 				continue;
       
   321 			}
   317 			status = SDL_NAME(snd_pcm_recover)(pcm_handle, status, 0);
   322 			status = SDL_NAME(snd_pcm_recover)(pcm_handle, status, 0);
   318 			if ( status < 0 ) {
   323 			if ( status < 0 ) {
   319 				/* Hmm, not much we can do - abort */
   324 				/* Hmm, not much we can do - abort */
   320 				fprintf(stderr, "ALSA write failed (unrecoverable): %s", SDL_NAME(snd_strerror)(status));
   325 				fprintf(stderr, "ALSA write failed (unrecoverable): %s", SDL_NAME(snd_strerror)(status));
   321 				this->enabled = 0;
   326 				this->enabled = 0;