moved the check for stop out of the loop

In the callback, we should check to see if the stopped flag is true
whether or not we are processing audio.
This commit is contained in:
William Hubbs 2009-06-23 16:13:52 -05:00
commit 26ab109bd8

18
alsa.c
View file

@ -69,21 +69,21 @@ static int alsa_play_callback(short *audio, int numsamples,
int to_write;
snd_pcm_state_t state;
lock_audio_mutex();
if (stopped) {
snd_pcm_drop(handle);
stopped = 0;
unlock_audio_mutex();
return 1;
}
unlock_audio_mutex();
snd_pcm_status(handle, status);
state = snd_pcm_status_get_state(status);
if (state != SND_PCM_STATE_RUNNING)
snd_pcm_prepare(handle);
while (numsamples > 0) {
lock_audio_mutex();
if (stopped) {
snd_pcm_drop(handle);
stopped = 0;
unlock_audio_mutex();
return 1;
}
unlock_audio_mutex();
avail = snd_pcm_avail_update(handle);
if (avail <= 0)
continue;