diff --git a/libs/audio/renderer/snd_mix.c b/libs/audio/renderer/snd_mix.c index 61cccb870..9e44bae7a 100644 --- a/libs/audio/renderer/snd_mix.c +++ b/libs/audio/renderer/snd_mix.c @@ -421,6 +421,10 @@ SND_PaintChannelFrom8 (channel_t *ch, sfxbuffer_t *sc, int count) byte *samps; pos = (ch->pos - sc->pos + sc->tail) % sc->length; + if (pos < 0) { // FIXME need a better way to handle shared streams + pos = sc->tail; + ch->pos = sc->pos; + } samps = sc->data + pos; if (pos + count > sc->length) { @@ -440,6 +444,10 @@ SND_PaintChannelFrom16 (channel_t *ch, sfxbuffer_t *sc, int count) short *samps; pos = (ch->pos - sc->pos + sc->tail) % sc->length; + if (pos < 0) { // FIXME need a better way to handle shared streams + pos = sc->tail; + ch->pos = sc->pos; + } samps = (short *) sc->data + pos; if (pos + count > sc->length) { @@ -459,6 +467,10 @@ SND_PaintChannelStereo8 (channel_t *ch, sfxbuffer_t *sc, int count) short *samps; pos = (ch->pos - sc->pos + sc->tail) % sc->length; + if (pos < 0) { // FIXME need a better way to handle shared streams + pos = sc->tail; + ch->pos = sc->pos; + } samps = (short *) sc->data + pos; if (pos + count > sc->length) { @@ -478,6 +490,10 @@ SND_PaintChannelStereo16 (channel_t *ch, sfxbuffer_t *sc, int count) int *samps; pos = (ch->pos - sc->pos + sc->tail) % sc->length; + if (pos < 0) { // FIXME need a better way to handle shared streams + pos = sc->tail; + ch->pos = sc->pos; + } samps = (int *) sc->data + pos; if (pos + count > sc->length) {