From c68af64fe56369768b499aa5d82b3acd8fe49f9e Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Wed, 10 Mar 2021 00:03:12 +0300 Subject: [PATCH] engine: platform: fix access to uninitialized audio subsystem when -nosound was passed --- engine/platform/linux/s_alsa.c | 3 +++ engine/platform/sdl/events.c | 6 +++--- engine/platform/sdl/s_sdl.c | 3 +++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/engine/platform/linux/s_alsa.c b/engine/platform/linux/s_alsa.c index 85a0332f..f3b5262c 100644 --- a/engine/platform/linux/s_alsa.c +++ b/engine/platform/linux/s_alsa.c @@ -376,6 +376,9 @@ between a deactivate and an activate. */ void SNDDMA_Activate( qboolean active ) { + if( !dma.initialized ) + return; + s_alsa.paused = !active; if( !s_alsa.paused ) diff --git a/engine/platform/sdl/events.c b/engine/platform/sdl/events.c index 5bcc4203..59c80192 100644 --- a/engine/platform/sdl/events.c +++ b/engine/platform/sdl/events.c @@ -340,8 +340,8 @@ static void SDLash_ActiveEvent( int gain ) if( gain ) { host.status = HOST_FRAME; - IN_ActivateMouse(true); - if( snd_mute_losefocus.value ) + IN_ActivateMouse( true ); + if( dma.initialized && snd_mute_losefocus.value ) { SNDDMA_Activate( true ); } @@ -361,7 +361,7 @@ static void SDLash_ActiveEvent( int gain ) #endif host.status = HOST_NOFOCUS; IN_DeactivateMouse(); - if( snd_mute_losefocus.value ) + if( dma.initialized && snd_mute_losefocus.value ) { SNDDMA_Activate( false ); } diff --git a/engine/platform/sdl/s_sdl.c b/engine/platform/sdl/s_sdl.c index 14782091..6de35fcd 100644 --- a/engine/platform/sdl/s_sdl.c +++ b/engine/platform/sdl/s_sdl.c @@ -264,6 +264,9 @@ between a deactivate and an activate. */ void SNDDMA_Activate( qboolean active ) { + if( !dma.initialized ) + return; + SDL_PauseAudioDevice( sdl_dev, !active ); } #endif // XASH_SOUND == SOUND_SDL