- ch->pos += paintedtime - ch->lastptime;
-
- // If the sound should have ended by then
- if ((unsigned int)ch->pos > sfx->total_length)
- {
- int loopstart;
-
- if (sfx->loopstart >= 0)
- loopstart = bound(0, sfx->loopstart, (int)sfx->total_length - 1);
- else
- {
- if (ch->flags & CHANNELFLAG_FORCELOOP)
- loopstart = 0;
- else
- loopstart = -1;
- }
-
- // If the sound is looped
- if (loopstart >= 0)
- ch->pos = (ch->pos - sfx->total_length) % (sfx->total_length - loopstart) + loopstart;
- else
- ch->pos = sfx->total_length;
- ch->end = paintedtime + sfx->total_length - ch->pos;
- }