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. SDL-1.2
authorSam Lantinga <slouken@libsdl.org>
Tue, 13 Oct 2009 09:35:37 +0000
branchSDL-1.2
changeset 4332 67e799ffcadf
parent 4331 a24454ed4ac4
child 4333 55717a755897
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.
src/audio/alsa/SDL_alsa_audio.c
--- a/src/audio/alsa/SDL_alsa_audio.c	Tue Oct 13 09:24:05 2009 +0000
+++ b/src/audio/alsa/SDL_alsa_audio.c	Tue Oct 13 09:35:37 2009 +0000
@@ -306,16 +306,16 @@
 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 @@
 			continue;
 		}
 		sample_buf += status * sample_size;
-		samps_left -= status;
+		frames_left -= status;
 	}
 }