engine: platform: fix access to uninitialized audio subsystem when -nosound was passed

This commit is contained in:
Alibek Omarov 2021-03-10 00:03:12 +03:00
parent 3d9a4560d5
commit c68af64fe5
3 changed files with 9 additions and 3 deletions

View File

@ -376,6 +376,9 @@ between a deactivate and an activate.
*/ */
void SNDDMA_Activate( qboolean active ) void SNDDMA_Activate( qboolean active )
{ {
if( !dma.initialized )
return;
s_alsa.paused = !active; s_alsa.paused = !active;
if( !s_alsa.paused ) if( !s_alsa.paused )

View File

@ -340,8 +340,8 @@ static void SDLash_ActiveEvent( int gain )
if( gain ) if( gain )
{ {
host.status = HOST_FRAME; host.status = HOST_FRAME;
IN_ActivateMouse(true); IN_ActivateMouse( true );
if( snd_mute_losefocus.value ) if( dma.initialized && snd_mute_losefocus.value )
{ {
SNDDMA_Activate( true ); SNDDMA_Activate( true );
} }
@ -361,7 +361,7 @@ static void SDLash_ActiveEvent( int gain )
#endif #endif
host.status = HOST_NOFOCUS; host.status = HOST_NOFOCUS;
IN_DeactivateMouse(); IN_DeactivateMouse();
if( snd_mute_losefocus.value ) if( dma.initialized && snd_mute_losefocus.value )
{ {
SNDDMA_Activate( false ); SNDDMA_Activate( false );
} }

View File

@ -264,6 +264,9 @@ between a deactivate and an activate.
*/ */
void SNDDMA_Activate( qboolean active ) void SNDDMA_Activate( qboolean active )
{ {
if( !dma.initialized )
return;
SDL_PauseAudioDevice( sdl_dev, !active ); SDL_PauseAudioDevice( sdl_dev, !active );
} }
#endif // XASH_SOUND == SOUND_SDL #endif // XASH_SOUND == SOUND_SDL