comparison src/audio/alsa/SDL_alsa_audio.c @ 4329:9716da353104 SDL-1.2

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.
author Ryan C. Gordon <icculus@icculus.org>
date Tue, 13 Oct 2009 08:27:28 +0000
parents c9a1de1eda57
children a24454ed4ac4
comparison
equal deleted inserted replaced
4328:4abf24b03b1d 4329:9716da353104
303 303
304 304
305 static void ALSA_PlayAudio(_THIS) 305 static void ALSA_PlayAudio(_THIS)
306 { 306 {
307 int status; 307 int status;
308 snd_pcm_uframes_t frames_left; 308 snd_pcm_uframes_t samps_left;
309 const Uint8 *sample_buf = (const Uint8 *) mixbuf; 309 const Uint8 *sample_buf = (const Uint8 *) mixbuf;
310 const int frame_size = ( ((int) this->spec.channels) * 310 const int sample_size = ((int) (this->spec.format & 0xFF)) / 8;
311 (((int) (this->spec.format & 0xFF)) / 8) );
312 311
313 swizzle_alsa_channels(this); 312 swizzle_alsa_channels(this);
314 313
315 frames_left = ((snd_pcm_uframes_t) this->spec.samples) / this->spec.channels; 314 samps_left = ((snd_pcm_uframes_t) this->spec.samples);
316 315
317 while ( frames_left > 0 ) { 316 while ( samps_left > 0 ) {
318 status = SDL_NAME(snd_pcm_writei)(pcm_handle, sample_buf, frames_left); 317 status = SDL_NAME(snd_pcm_writei)(pcm_handle, sample_buf, samps_left);
319 if ( status < 0 ) { 318 if ( status < 0 ) {
320 if ( status == -EAGAIN ) { 319 if ( status == -EAGAIN ) {
321 SDL_Delay(1); 320 SDL_Delay(1);
322 continue; 321 continue;
323 } 322 }
335 this->enabled = 0; 334 this->enabled = 0;
336 return; 335 return;
337 } 336 }
338 continue; 337 continue;
339 } 338 }
340 sample_buf += status * frame_size; 339 sample_buf += status * sample_size;
341 frames_left -= status; 340 samps_left -= status;
342 } 341 }
343 } 342 }
344 343
345 static Uint8 *ALSA_GetAudioBuf(_THIS) 344 static Uint8 *ALSA_GetAudioBuf(_THIS)
346 { 345 {