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 433267e799ffcadf
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
     1.1 --- a/src/audio/alsa/SDL_alsa_audio.c	Tue Oct 13 09:24:05 2009 +0000
     1.2 +++ b/src/audio/alsa/SDL_alsa_audio.c	Tue Oct 13 09:35:37 2009 +0000
     1.3 @@ -306,16 +306,16 @@
     1.4  static void ALSA_PlayAudio(_THIS)
     1.5  {
     1.6  	int status;
     1.7 -	snd_pcm_uframes_t samps_left;
     1.8 +	snd_pcm_uframes_t frames_left;
     1.9  	const Uint8 *sample_buf = (const Uint8 *) mixbuf;
    1.10  	const int sample_size = ((int) (this->spec.format & 0xFF)) / 8;
    1.11  
    1.12  	swizzle_alsa_channels(this);
    1.13  
    1.14 -	samps_left = ((snd_pcm_uframes_t) this->spec.samples);
    1.15 +	frames_left = ((snd_pcm_uframes_t) this->spec.samples);
    1.16  
    1.17 -	while ( samps_left > 0 ) {
    1.18 -		status = SDL_NAME(snd_pcm_writei)(pcm_handle, sample_buf, samps_left);
    1.19 +	while ( frames_left > 0 ) {
    1.20 +		status = SDL_NAME(snd_pcm_writei)(pcm_handle, sample_buf, frames_left);
    1.21  		if ( status < 0 ) {
    1.22  			if ( status == -EAGAIN ) {
    1.23  				SDL_Delay(1);
    1.24 @@ -338,7 +338,7 @@
    1.25  			continue;
    1.26  		}
    1.27  		sample_buf += status * sample_size;
    1.28 -		samps_left -= status;
    1.29 +		frames_left -= status;
    1.30  	}
    1.31  }
    1.32