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.

--HG--
branch : SDL-1.2
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/branches/SDL-1.2%404079
This commit is contained in:
Sam Lantinga 2009-10-13 09:35:37 +00:00
parent ff4ec16bb6
commit 9786668dab

View file

@ -306,16 +306,16 @@ static __inline__ void swizzle_alsa_channels(_THIS)
static void ALSA_PlayAudio(_THIS)
{
int status;
snd_pcm_uframes_t samps_left;
snd_pcm_uframes_t frames_left;
const Uint8 *sample_buf = (const Uint8 *) mixbuf;
const int sample_size = ((int) (this->spec.format & 0xFF)) / 8;
swizzle_alsa_channels(this);
samps_left = ((snd_pcm_uframes_t) this->spec.samples);
frames_left = ((snd_pcm_uframes_t) this->spec.samples);
while ( samps_left > 0 ) {
status = SDL_NAME(snd_pcm_writei)(pcm_handle, sample_buf, samps_left);
while ( frames_left > 0 ) {
status = SDL_NAME(snd_pcm_writei)(pcm_handle, sample_buf, frames_left);
if ( status < 0 ) {
if ( status == -EAGAIN ) {
SDL_Delay(1);
@ -338,7 +338,7 @@ static void ALSA_PlayAudio(_THIS)
continue;
}
sample_buf += status * sample_size;
samps_left -= status;
frames_left -= status;
}
}