Simplified the audio channel mix a bit
@@ -192,17 +192,18 @@ AUDIO_CHANNEL_mix(void* gChannel, float* stream, size_t totalSamples) {
*(writeCursor++) += *(readCursor++) * sin(pan) * currentVolume;
channel->current.position++;
- if (channel->current.loop && channel->current.position >= length) {
+ if (channel->current.position >= length) {
+ if (channel->current.loop) {
channel->current.position = 0;
readCursor = startReadCursor;
- }
- if (!channel->core.enabled) {
+ } else {
break;
}
}
+ }
channel->actualVolume = channel->current.volume;
channel->actualPan = channel->current.pan;
- channel->core.enabled = channel->core.enabled && (channel->current.loop || channel->current.position < length);
+ channel->core.enabled = (channel->current.loop || channel->current.position < length);
}
// audio callback function
@@ -461,7 +462,6 @@ AUDIO_ENGINE_unlock(AUDIO_ENGINE* engine) {
SDL_UnlockAudioDevice(engine->deviceId);
}
-
internal void
AUDIO_ENGINE_pushChannel(AUDIO_ENGINE* engine, GENERIC_CHANNEL* channel) {
CHANNEL_LIST* list = engine->pending;
