Mercurial > sdl-ios-xcode
comparison src/audio/alsa/SDL_alsa_audio.c @ 4320:33d306630296 SDL-1.2
Corrected misuse of snd_pcm_writei() in ALSA driver.
Hopefully fixes Bugzilla #650.
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Mon, 12 Oct 2009 08:06:40 +0000 |
parents | 464126f4c7db |
children | c9a1de1eda57 |
comparison
equal
deleted
inserted
replaced
4319:edefeb52a627 | 4320:33d306630296 |
---|---|
302 } | 302 } |
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 int sample_len; | 308 snd_pcm_uframes_t frames_left; |
309 signed short *sample_buf; | 309 const Uint8 *sample_buf = (const Uint8 *) mixbuf; |
310 const int frame_size = ( ((int) this->spec.channels) * | |
311 ((int) (this->spec.format & 0xFF)) ); | |
310 | 312 |
311 swizzle_alsa_channels(this); | 313 swizzle_alsa_channels(this); |
312 | 314 |
313 sample_len = this->spec.samples; | 315 frames_left = ((snd_pcm_uframes_t) this->spec.samples) / this->spec.channels; |
314 sample_buf = (signed short *)mixbuf; | 316 |
315 | 317 while ( frames_left > 0 ) { |
316 while ( sample_len > 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, sample_len); | |
318 if ( status < 0 ) { | 319 if ( status < 0 ) { |
319 if ( status == -EAGAIN ) { | 320 if ( status == -EAGAIN ) { |
320 SDL_Delay(1); | 321 SDL_Delay(1); |
321 continue; | 322 continue; |
322 } | 323 } |
334 this->enabled = 0; | 335 this->enabled = 0; |
335 return; | 336 return; |
336 } | 337 } |
337 continue; | 338 continue; |
338 } | 339 } |
339 sample_buf += status * this->spec.channels; | 340 sample_buf += status * frame_size; |
340 sample_len -= status; | 341 frames_left -= status; |
341 } | 342 } |
342 } | 343 } |
343 | 344 |
344 static Uint8 *ALSA_GetAudioBuf(_THIS) | 345 static Uint8 *ALSA_GetAudioBuf(_THIS) |
345 { | 346 { |