diff --git a/engine/client/s_main.c b/engine/client/s_main.c index 2feeb81b..28191b84 100644 --- a/engine/client/s_main.c +++ b/engine/client/s_main.c @@ -43,7 +43,7 @@ CVAR_DEFINE_AUTO( s_lerping, "0", FCVAR_ARCHIVE|FCVAR_FILTERABLE, "apply interpo static CVAR_DEFINE( s_ambient_level, "ambient_level", "0.3", FCVAR_ARCHIVE|FCVAR_FILTERABLE, "volume of environment noises (water and wind)" ); static CVAR_DEFINE( s_ambient_fade, "ambient_fade", "1000", FCVAR_ARCHIVE|FCVAR_FILTERABLE, "rate of volume fading when client is moving" ); static CVAR_DEFINE_AUTO( s_combine_sounds, "0", FCVAR_ARCHIVE|FCVAR_FILTERABLE, "combine channels with same sounds" ); -CVAR_DEFINE_AUTO( snd_mute_losefocus, "1", FCVAR_ARCHIVE|FCVAR_FILTERABLE, "silence the audio when game window loses focus" ); +static CVAR_DEFINE_AUTO( snd_mute_losefocus, "1", FCVAR_ARCHIVE|FCVAR_FILTERABLE, "silence the audio when game window loses focus" ); CVAR_DEFINE_AUTO( s_test, "0", 0, "engine developer cvar for quick testing new features" ); CVAR_DEFINE_AUTO( s_samplecount, "0", FCVAR_ARCHIVE|FCVAR_FILTERABLE, "sample count (0 for default value)" ); CVAR_DEFINE_AUTO( s_warn_late_precache, "0", FCVAR_ARCHIVE|FCVAR_FILTERABLE, "warn about late precached sounds on client-side" ); @@ -64,6 +64,12 @@ float S_GetMasterVolume( void ) { float scale = 1.0f; + if( host.status == HOST_NOFOCUS && snd_mute_losefocus.value != 0.0f ) + { + // we return zero volume to keep sounds running + return 0.0f; + } + if( !s_listener.inmenu && soundfade.percent != 0 ) { scale = bound( 0.0f, soundfade.percent / 100.0f, 1.0f ); diff --git a/engine/client/sound.h b/engine/client/sound.h index 7e581cbc..06bcc0d4 100644 --- a/engine/client/sound.h +++ b/engine/client/sound.h @@ -221,7 +221,6 @@ extern convar_t s_musicvolume; extern convar_t s_lerping; extern convar_t s_test; // cvar to testify new effects extern convar_t s_samplecount; -extern convar_t snd_mute_losefocus; extern convar_t s_warn_late_precache; void S_InitScaletable( void ); diff --git a/engine/platform/sdl/events.c b/engine/platform/sdl/events.c index 7e7f9b28..3c31eb84 100644 --- a/engine/platform/sdl/events.c +++ b/engine/platform/sdl/events.c @@ -374,14 +374,8 @@ static void SDLash_ActiveEvent( int gain ) { host.status = HOST_FRAME; if( cls.key_dest == key_game ) - { IN_ActivateMouse( ); - } - if( dma.initialized && snd_mute_losefocus.value ) - { - SNDDMA_Activate( true ); - } host.force_draw_version_time = host.realtime + FORCE_DRAW_VERSION_TIME; if( vid_fullscreen.value == WINDOW_MODE_FULLSCREEN ) VID_SetMode(); @@ -397,14 +391,8 @@ static void SDLash_ActiveEvent( int gain ) #endif host.status = HOST_NOFOCUS; if( cls.key_dest == key_game ) - { IN_DeactivateMouse(); - } - if( dma.initialized && snd_mute_losefocus.value ) - { - SNDDMA_Activate( false ); - } host.force_draw_version_time = host.realtime + 2.0; VID_RestoreScreenResolution(); }