From cac6206984f0b4141906fbb4b22b296cf5c49890 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Wed, 22 Jan 2025 13:48:13 +0300 Subject: [PATCH] engine: client: allocate everything related to sounds in the sound pool --- engine/client/s_dsp.c | 2 +- engine/client/s_main.c | 5 +++-- engine/client/s_vox.c | 2 +- engine/platform/linux/s_alsa.c | 2 +- engine/platform/sdl/s_sdl.c | 2 +- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/engine/client/s_dsp.c b/engine/client/s_dsp.c index d16d56c8..01cb7471 100644 --- a/engine/client/s_dsp.c +++ b/engine/client/s_dsp.c @@ -312,7 +312,7 @@ static int DLY_Init( int idelay, float delay ) cur = &rgsxdly[idelay]; cur->cdelaysamplesmax = ((int)(delay * idsp_dma_speed) << sxhires) + 1; - cur->lpdelayline = (int *)Z_Calloc( cur->cdelaysamplesmax * sizeof( int )); + cur->lpdelayline = (int *)Mem_Calloc( sndpool, cur->cdelaysamplesmax * sizeof( int )); cur->xfade = 0; // init modulation diff --git a/engine/client/s_main.c b/engine/client/s_main.c index a7c256ac..93a24492 100644 --- a/engine/client/s_main.c +++ b/engine/client/s_main.c @@ -1954,14 +1954,15 @@ qboolean S_Init( void ) Cmd_AddCommand( "spk", S_SayReliable_f, "reliable play a specified sententce" ); Cmd_AddCommand( "speak", S_Say_f, "playing a specified sententce" ); + sndpool = Mem_AllocPool( "Sound Zone" ); dma.backendName = "None"; - if( !SNDDMA_Init( ) ) + if( !SNDDMA_Init( )) { Con_Printf( "Audio: sound system can't be initialized\n" ); + Mem_FreePool( &sndpool ); return false; } - sndpool = Mem_AllocPool( "Sound Zone" ); soundtime = 0; paintedtime = 0; diff --git a/engine/client/s_vox.c b/engine/client/s_vox.c index e953e22c..76c649bd 100644 --- a/engine/client/s_vox.c +++ b/engine/client/s_vox.c @@ -557,7 +557,7 @@ static void VOX_ReadSentenceFile_( byte *buf, fs_offset_t size ) int index = cszrawsentences; int size = strlen( name ) + strlen( value ) + 2; - rgpszrawsentence[index] = Mem_Malloc( host.mempool, size ); + rgpszrawsentence[index] = Mem_Malloc( sndpool, size ); memcpy( rgpszrawsentence[index], name, size ); rgpszrawsentence[index][size - 1] = 0; cszrawsentences++; diff --git a/engine/platform/linux/s_alsa.c b/engine/platform/linux/s_alsa.c index 6875a0c0..54d17774 100644 --- a/engine/platform/linux/s_alsa.c +++ b/engine/platform/linux/s_alsa.c @@ -184,7 +184,7 @@ qboolean SNDDMA_Init( void ) return false; } - dma.buffer = Z_Malloc( samples * 2 ); //allocate pcm frame buffer + dma.buffer = Mem_Malloc( sndpool, samples * 2 ); //allocate pcm frame buffer dma.samplepos = 0; dma.samples = samples; dma.format.width = 2; diff --git a/engine/platform/sdl/s_sdl.c b/engine/platform/sdl/s_sdl.c index 2467b8b0..759cf193 100644 --- a/engine/platform/sdl/s_sdl.c +++ b/engine/platform/sdl/s_sdl.c @@ -175,7 +175,7 @@ qboolean SNDDMA_Init( void ) if( !samplecount ) samplecount = 0x8000; dma.samples = samplecount * obtained.channels; - dma.buffer = Z_Calloc( dma.samples * 2 ); + dma.buffer = Mem_Malloc( sndpool, dma.samples * 2 ); dma.samplepos = 0; sdl_format = obtained.format;