Mercurial > sdl-ios-xcode
changeset 4329:9716da353104 SDL-1.2
Corrected my snd_pcm_writei fix.
Apparently ALSA says "frames" but it means samples...you don't split this into
groups by number of channels.
The adventure continues.
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Tue, 13 Oct 2009 08:27:28 +0000 |
parents | 4abf24b03b1d |
children | 33570eec2d4f |
files | src/audio/alsa/SDL_alsa_audio.c |
diffstat | 1 files changed, 7 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/src/audio/alsa/SDL_alsa_audio.c Tue Oct 13 06:45:02 2009 +0000 +++ b/src/audio/alsa/SDL_alsa_audio.c Tue Oct 13 08:27:28 2009 +0000 @@ -305,17 +305,16 @@ static void ALSA_PlayAudio(_THIS) { int status; - snd_pcm_uframes_t frames_left; + snd_pcm_uframes_t samps_left; const Uint8 *sample_buf = (const Uint8 *) mixbuf; - const int frame_size = ( ((int) this->spec.channels) * - (((int) (this->spec.format & 0xFF)) / 8) ); + const int sample_size = ((int) (this->spec.format & 0xFF)) / 8; swizzle_alsa_channels(this); - frames_left = ((snd_pcm_uframes_t) this->spec.samples) / this->spec.channels; + samps_left = ((snd_pcm_uframes_t) this->spec.samples); - while ( frames_left > 0 ) { - status = SDL_NAME(snd_pcm_writei)(pcm_handle, sample_buf, frames_left); + while ( samps_left > 0 ) { + status = SDL_NAME(snd_pcm_writei)(pcm_handle, sample_buf, samps_left); if ( status < 0 ) { if ( status == -EAGAIN ) { SDL_Delay(1); @@ -337,8 +336,8 @@ } continue; } - sample_buf += status * frame_size; - frames_left -= status; + sample_buf += status * sample_size; + samps_left -= status; } }