X-Git-Url: https://git.xonotic.org/?a=blobdiff_plain;f=snd_sdl.c;h=667d56b37fcb58c072c38ea17b082336743b43ba;hb=e2313a595cddf22b722d36ca1142e2bddb2fedff;hp=83538534dc8390f933b835b957297633141b9a0d;hpb=8d376b57de94bafd3bae224088b469649c853028;p=xonotic%2Fdarkplaces.git diff --git a/snd_sdl.c b/snd_sdl.c index 83538534..667d56b3 100644 --- a/snd_sdl.c +++ b/snd_sdl.c @@ -39,6 +39,14 @@ static void Buffer_Callback (void *userdata, Uint8 *stream, int len) RequestedFrames = (unsigned int)len / factor; + if (snd_usethreadedmixing) + { + S_MixToBuffer(stream, RequestedFrames); + if (snd_blocked) + memset(stream, snd_renderbuffer->format.width == 1 ? 0x80 : 0, len); + return; + } + // Transfert up to a chunk of samples from snd_renderbuffer to stream MaxFrames = snd_renderbuffer->endframe - snd_renderbuffer->startframe; if (MaxFrames > RequestedFrames) @@ -83,7 +91,9 @@ qboolean SndSys_Init (const snd_format_t* requested, snd_format_t* suggested) SDL_AudioSpec wantspec; SDL_AudioSpec obtainspec; - Con_DSPrint ("SndSys_Init: using the SDL module\n"); + snd_threaded = false; + + Con_DPrint ("SndSys_Init: using the SDL module\n"); // Init the SDL Audio subsystem if( SDL_InitSubSystem( SDL_INIT_AUDIO ) ) { @@ -91,7 +101,7 @@ qboolean SndSys_Init (const snd_format_t* requested, snd_format_t* suggested) return false; } - buffersize = (unsigned int)ceil((double)requested->speed / 20.0); + buffersize = (unsigned int)ceil((double)requested->speed / 25.0); // 2048 bytes on 24kHz to 48kHz // Init the SDL Audio subsystem wantspec.callback = Buffer_Callback; @@ -140,6 +150,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) {