Browse Source

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

pull/2/head
Alibek Omarov 4 years ago
parent
commit
c68af64fe5
  1. 3
      engine/platform/linux/s_alsa.c
  2. 6
      engine/platform/sdl/events.c
  3. 3
      engine/platform/sdl/s_sdl.c

3
engine/platform/linux/s_alsa.c

@ -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 )

6
engine/platform/sdl/events.c

@ -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 );
} }

3
engine/platform/sdl/s_sdl.c

@ -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

Loading…
Cancel
Save