]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - snd_mix.c
UNMERGE! Implement SDL2 AUDIO_F32 format and use it as the default, since it has...
[xonotic/darkplaces.git] / snd_mix.c
index 4ed38a88b633fde65875389fb622340cc3d4b12a..10da40047ec05355f7ccf85eff87d7b1a115344f 100644 (file)
--- a/snd_mix.c
+++ b/snd_mix.c
@@ -29,7 +29,7 @@ static portable_sampleframe_t paintbuffer_unswapped[PAINTBUFFER_SIZE];
 extern speakerlayout_t snd_speakerlayout; // for querying the listeners
 
 #ifdef CONFIG_VIDEO_CAPTURE
-static void S_CaptureAVISound(const portable_sampleframe_t *sampleframes, size_t length)
+static void S_CaptureAVISound(const portable_sampleframe_t *paintbuffer, size_t length)
 {
        size_t i;
        unsigned int j;
@@ -42,7 +42,7 @@ static void S_CaptureAVISound(const portable_sampleframe_t *sampleframes, size_t
        {
                unsigned int j0 = snd_speakerlayout.listeners[j].channel_unswapped;
                for(i = 0; i < length; ++i)
-                       paintbuffer_unswapped[i].sample[j0] = sampleframes[i].sample[j];
+                       paintbuffer_unswapped[i].sample[j0] = paintbuffer[i].sample[j];
        }
 
        SCR_CaptureVideo_SoundFrame(paintbuffer_unswapped, length);
@@ -127,67 +127,11 @@ static void S_SoftClipPaintBuffer(portable_sampleframe_t *painted_ptr, int nbfra
 
 static void S_ConvertPaintBuffer(portable_sampleframe_t *painted_ptr, void *rb_ptr, int nbframes, int width, int nchannels)
 {
-       int i;
-       if (width == 4)  // 32bit float
-       {
-               float *snd_out = (float*)rb_ptr;
-               if (nchannels == 8)  // 7.1 surround
-               {
-                       for (i = 0; i < nbframes; i++, painted_ptr++)
-                       {
-                               *snd_out++ = painted_ptr->sample[0];
-                               *snd_out++ = painted_ptr->sample[1];
-                               *snd_out++ = painted_ptr->sample[2];
-                               *snd_out++ = painted_ptr->sample[3];
-                               *snd_out++ = painted_ptr->sample[4];
-                               *snd_out++ = painted_ptr->sample[5];
-                               *snd_out++ = painted_ptr->sample[6];
-                               *snd_out++ = painted_ptr->sample[7];
-                       }
-               }
-               else if (nchannels == 6)  // 5.1 surround
-               {
-                       for (i = 0; i < nbframes; i++, painted_ptr++)
-                       {
-                               *snd_out++ = painted_ptr->sample[0];
-                               *snd_out++ = painted_ptr->sample[1];
-                               *snd_out++ = painted_ptr->sample[2];
-                               *snd_out++ = painted_ptr->sample[3];
-                               *snd_out++ = painted_ptr->sample[4];
-                               *snd_out++ = painted_ptr->sample[5];
-                       }
-               }
-               else if (nchannels == 4)  // 4.0 surround
-               {
-                       for (i = 0; i < nbframes; i++, painted_ptr++)
-                       {
-                               *snd_out++ = painted_ptr->sample[0];
-                               *snd_out++ = painted_ptr->sample[1];
-                               *snd_out++ = painted_ptr->sample[2];
-                               *snd_out++ = painted_ptr->sample[3];
-                       }
-               }
-               else if (nchannels == 2)  // 2.0 stereo
-               {
-                       for (i = 0; i < nbframes; i++, painted_ptr++)
-                       {
-                               *snd_out++ = painted_ptr->sample[0];
-                               *snd_out++ = painted_ptr->sample[1];
-                       }
-               }
-               else if (nchannels == 1)  // 1.0 mono
-               {
-                       for (i = 0; i < nbframes; i++, painted_ptr++)
-                       {
-                               *snd_out++ = painted_ptr->sample[0];
-                       }
-               }
+       int i, val;
 
-               // noise is really really annoying
-               if (cls.timedemo)
-                       memset(rb_ptr, 0, nbframes * nchannels * width);
-       }
-       else if (width == 2)  // 16bit
+       // FIXME: add 24bit and 32bit float formats
+       // FIXME: optimize with SSE intrinsics?
+       if (width == 2)  // 16bit
        {
                short *snd_out = (short*)rb_ptr;
                if (nchannels == 8)  // 7.1 surround