[Change] Make sounds play fully.

This commit is contained in:
Allanis 2013-06-09 17:09:35 +01:00
parent 331cc86c98
commit 8976622b73

View File

@ -381,20 +381,31 @@ void sound_update(void) {
voice = voice_start; voice = voice_start;
do { do {
next = voice->next; 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. if(!voice_is(voice, VOICE_DONE)) { // Still working.
// Voice has a source. // Voice has a source.
if(voice->source != 0) { if(voice->source != 0) {
alGetSourcei(voice->source, AL_SOURCE_STATE, &stat);
// Update position.
alSource3f(voice->source, AL_POSITION, alSource3f(voice->source, AL_POSITION,
voice->px, voice->py, 0.); voice->px, voice->py, 0.);
/*alSource3f(voice->source, AL_VELOCITY, /*alSource3f(voice->source, AL_VELOCITY,
voice->vx, voice->vy, 0.);*/ voice->vx, voice->vy, 0.);*/
} }
prev = voice; // Only case where voice will stay. prev = voice;
} else // Delete them. }else {
voice_rm(prev, voice); // Delete them.
if(stat != AL_PLAYING)
voice_rm(prev, voice); // Do not set prev to voice.
else
prev = voice;
}
voice = next; voice = next;
} while(voice != NULL); } while(voice != NULL);