Commit c865dbf8 authored by Ryan C. Gordon's avatar Ryan C. Gordon

Corrected misuse of snd_pcm_writei() in ALSA driver.

  Hopefully fixes Bugzilla #650.

--HG--
branch : SDL-1.2
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/branches/SDL-1.2%404056
parent 56967065
...@@ -304,17 +304,18 @@ static __inline__ void swizzle_alsa_channels(_THIS) ...@@ -304,17 +304,18 @@ static __inline__ void swizzle_alsa_channels(_THIS)
static void ALSA_PlayAudio(_THIS) static void ALSA_PlayAudio(_THIS)
{ {
int status; int status;
int sample_len; snd_pcm_uframes_t frames_left;
signed short *sample_buf; const Uint8 *sample_buf = (const Uint8 *) mixbuf;
const int frame_size = ( ((int) this->spec.channels) *
((int) (this->spec.format & 0xFF)) );
swizzle_alsa_channels(this); swizzle_alsa_channels(this);
sample_len = this->spec.samples; frames_left = ((snd_pcm_uframes_t) this->spec.samples) / this->spec.channels;
sample_buf = (signed short *)mixbuf;
while ( sample_len > 0 ) { while ( frames_left > 0 ) {
status = SDL_NAME(snd_pcm_writei)(pcm_handle, sample_buf, sample_len); status = SDL_NAME(snd_pcm_writei)(pcm_handle, sample_buf, frames_left);
if ( status < 0 ) { if ( status < 0 ) {
if ( status == -EAGAIN ) { if ( status == -EAGAIN ) {
SDL_Delay(1); SDL_Delay(1);
...@@ -336,8 +337,8 @@ static void ALSA_PlayAudio(_THIS) ...@@ -336,8 +337,8 @@ static void ALSA_PlayAudio(_THIS)
} }
continue; continue;
} }
sample_buf += status * this->spec.channels; sample_buf += status * frame_size;
sample_len -= status; frames_left -= status;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment