Corrected my snd_pcm_writei fix. SDL-1.2
authorRyan C. Gordon <icculus@icculus.org>
Tue, 13 Oct 2009 08:27:28 +0000
branchSDL-1.2
changeset 43299716da353104
parent 4328 4abf24b03b1d
child 4330 33570eec2d4f
Corrected my snd_pcm_writei fix.

Apparently ALSA says "frames" but it means samples...you don't split this into
groups by number of channels.

The adventure continues.
src/audio/alsa/SDL_alsa_audio.c
     1.1 --- a/src/audio/alsa/SDL_alsa_audio.c	Tue Oct 13 06:45:02 2009 +0000
     1.2 +++ b/src/audio/alsa/SDL_alsa_audio.c	Tue Oct 13 08:27:28 2009 +0000
     1.3 @@ -305,17 +305,16 @@
     1.4  static void ALSA_PlayAudio(_THIS)
     1.5  {
     1.6  	int status;
     1.7 -	snd_pcm_uframes_t frames_left;
     1.8 +	snd_pcm_uframes_t samps_left;
     1.9  	const Uint8 *sample_buf = (const Uint8 *) mixbuf;
    1.10 -	const int frame_size = ( ((int) this->spec.channels) *
    1.11 -	                         (((int) (this->spec.format & 0xFF)) / 8) );
    1.12 +	const int sample_size = ((int) (this->spec.format & 0xFF)) / 8;
    1.13  
    1.14  	swizzle_alsa_channels(this);
    1.15  
    1.16 -	frames_left = ((snd_pcm_uframes_t) this->spec.samples) / this->spec.channels;
    1.17 +	samps_left = ((snd_pcm_uframes_t) this->spec.samples);
    1.18  
    1.19 -	while ( frames_left > 0 ) {
    1.20 -		status = SDL_NAME(snd_pcm_writei)(pcm_handle, sample_buf, frames_left);
    1.21 +	while ( samps_left > 0 ) {
    1.22 +		status = SDL_NAME(snd_pcm_writei)(pcm_handle, sample_buf, samps_left);
    1.23  		if ( status < 0 ) {
    1.24  			if ( status == -EAGAIN ) {
    1.25  				SDL_Delay(1);
    1.26 @@ -337,8 +336,8 @@
    1.27  			}
    1.28  			continue;
    1.29  		}
    1.30 -		sample_buf += status * frame_size;
    1.31 -		frames_left -= status;
    1.32 +		sample_buf += status * sample_size;
    1.33 +		samps_left -= status;
    1.34  	}
    1.35  }
    1.36