]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - snd_mix.c
The code works as intended! Change some names and comments in the meantime.
[xonotic/darkplaces.git] / snd_mix.c
index ec3de1b7b6961351e2d6c039d1ac32cd356fc294..6bba3c1ad8870912efc8788ce3aa45c693a13939 100644 (file)
--- a/snd_mix.c
+++ b/snd_mix.c
@@ -189,9 +189,9 @@ static qboolean SND_PaintChannel (channel_t *ch, portable_sampleframe_t *paint,
 
        // If this channel manages its own volume
        if (ch->flags & CHANNELFLAG_FULLVOLUME)
-               snd_vol = 256;
+               snd_vol = (int)(mastervolume.value * 256);
        else
-               snd_vol = (int)(volume.value * 256);
+               snd_vol = (int)(mastervolume.value * volume.value * 256);
 
        // calculate mixing volumes based on channel volumes and volume cvar
        // also limit the volumes to values that won't clip
@@ -467,8 +467,8 @@ void S_MixToBuffer(void *stream, unsigned int bufferframes)
                for (i = 0; i < total_channels ; i++, ch++)
                {
                        sfx_t *sfx;
-                       unsigned int ltime;
-                       unsigned int count;
+                       int ltime;
+                       int count;
 
                        sfx = ch->sfx;
                        if (sfx == NULL)
@@ -482,16 +482,16 @@ void S_MixToBuffer(void *stream, unsigned int bufferframes)
                        if (ch->pos < 0)
                        {
                                count = -ch->pos;
-                               count = min(count, frames - ltime);
+                               count = min(count, (int)frames - ltime);
                                ch->pos += count;
                                ltime += count;
                        }
 
-                       while (ltime < frames)
+                       while (ltime < (int)frames)
                        {
                                // paint up to end of buffer or of input, whichever is lower
                                count = sfx->total_length - ch->pos;
-                               count = bound(0, count, frames - ltime);
+                               count = bound(0, count, (int)frames - ltime);
                                if (count)
                                {
                                        SND_PaintChannel (ch, paintbuffer + ltime, count);