]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - snd_sdl.c
implemented threaded audio mixing for SDL client (required some
[xonotic/darkplaces.git] / snd_sdl.c
index 032e57500fd14d35793f953b5b57f3e135a716be..4bcc0e7c392ea312ba6daa5db6e5d0a7694a95ac 100644 (file)
--- a/snd_sdl.c
+++ b/snd_sdl.c
@@ -39,6 +39,12 @@ static void Buffer_Callback (void *userdata, Uint8 *stream, int len)
 
        RequestedFrames = (unsigned int)len / factor;
 
+       if (snd_usethreadedmixing)
+       {
+               S_MixToBuffer(stream, RequestedFrames);
+               return;
+       }
+
        // Transfert up to a chunk of samples from snd_renderbuffer to stream
        MaxFrames = snd_renderbuffer->endframe - snd_renderbuffer->startframe;
        if (MaxFrames > RequestedFrames)
@@ -83,6 +89,8 @@ qboolean SndSys_Init (const snd_format_t* requested, snd_format_t* suggested)
        SDL_AudioSpec wantspec;
        SDL_AudioSpec obtainspec;
 
+       snd_threaded = false;
+
        Con_DPrint ("SndSys_Init: using the SDL module\n");
 
        // Init the SDL Audio subsystem
@@ -140,6 +148,8 @@ qboolean SndSys_Init (const snd_format_t* requested, snd_format_t* suggested)
                return false;
        }
 
+       snd_threaded = true;
+
        snd_renderbuffer = Snd_CreateRingBuffer(requested, 0, NULL);
        if (snd_channellayout.integer == SND_CHANNELLAYOUT_AUTO)
        {