Mercurial > sdl-ios-xcode
comparison src/audio/alsa/SDL_alsa_audio.c @ 4332:67e799ffcadf SDL-1.2
ALSA's idea of a "frame" is the same as SDL's idea of a "sample". The frame is a single sample on a single channel, and we've defined the frames for each channel as being interleaved.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Tue, 13 Oct 2009 09:35:37 +0000 |
parents | a24454ed4ac4 |
children | 55717a755897 |
comparison
equal
deleted
inserted
replaced
4331:a24454ed4ac4 | 4332:67e799ffcadf |
---|---|
304 | 304 |
305 | 305 |
306 static void ALSA_PlayAudio(_THIS) | 306 static void ALSA_PlayAudio(_THIS) |
307 { | 307 { |
308 int status; | 308 int status; |
309 snd_pcm_uframes_t samps_left; | 309 snd_pcm_uframes_t frames_left; |
310 const Uint8 *sample_buf = (const Uint8 *) mixbuf; | 310 const Uint8 *sample_buf = (const Uint8 *) mixbuf; |
311 const int sample_size = ((int) (this->spec.format & 0xFF)) / 8; | 311 const int sample_size = ((int) (this->spec.format & 0xFF)) / 8; |
312 | 312 |
313 swizzle_alsa_channels(this); | 313 swizzle_alsa_channels(this); |
314 | 314 |
315 samps_left = ((snd_pcm_uframes_t) this->spec.samples); | 315 frames_left = ((snd_pcm_uframes_t) this->spec.samples); |
316 | 316 |
317 while ( samps_left > 0 ) { | 317 while ( frames_left > 0 ) { |
318 status = SDL_NAME(snd_pcm_writei)(pcm_handle, sample_buf, samps_left); | 318 status = SDL_NAME(snd_pcm_writei)(pcm_handle, sample_buf, frames_left); |
319 if ( status < 0 ) { | 319 if ( status < 0 ) { |
320 if ( status == -EAGAIN ) { | 320 if ( status == -EAGAIN ) { |
321 SDL_Delay(1); | 321 SDL_Delay(1); |
322 continue; | 322 continue; |
323 } | 323 } |
336 return; | 336 return; |
337 } | 337 } |
338 continue; | 338 continue; |
339 } | 339 } |
340 sample_buf += status * sample_size; | 340 sample_buf += status * sample_size; |
341 samps_left -= status; | 341 frames_left -= status; |
342 } | 342 } |
343 } | 343 } |
344 | 344 |
345 static Uint8 *ALSA_GetAudioBuf(_THIS) | 345 static Uint8 *ALSA_GetAudioBuf(_THIS) |
346 { | 346 { |