diff --git a/src/sound.c b/src/sound.c index 20d7c15..49c1a32 100644 --- a/src/sound.c +++ b/src/sound.c @@ -381,20 +381,31 @@ void sound_update(void) { voice = voice_start; do { next = voice->next; + + // Get status. + stat = -1; + if(voice->source != 0) + alGetSourcei(voice->source, AL_SOURCE_STATE, &stat); + if(!voice_is(voice, VOICE_DONE)) { // Still working. // Voice has a source. if(voice->source != 0) { - alGetSourcei(voice->source, AL_SOURCE_STATE, &stat); + // Update position. alSource3f(voice->source, AL_POSITION, voice->px, voice->py, 0.); /*alSource3f(voice->source, AL_VELOCITY, voice->vx, voice->vy, 0.);*/ } - prev = voice; // Only case where voice will stay. - } else // Delete them. - voice_rm(prev, voice); + prev = voice; + }else { + // Delete them. + if(stat != AL_PLAYING) + voice_rm(prev, voice); // Do not set prev to voice. + else + prev = voice; + } voice = next; } while(voice != NULL);