From e134b6609f4abab816dbcf3eeba00d9e04141ea1 Mon Sep 17 00:00:00 2001 From: zander3312 Date: Mon, 6 Oct 2025 20:12:59 +0000 Subject: [PATCH] Include voice in tabbed out audio settings (fixes #37) --- src/cvars.cpp | 4 ++++ src/d_clisrv.c | 6 +++--- src/s_sound.c | 5 ++++- src/sdl/i_video.cpp | 3 +++ 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/cvars.cpp b/src/cvars.cpp index 39593fd89..4f37b4feb 100644 --- a/src/cvars.cpp +++ b/src/cvars.cpp @@ -420,7 +420,11 @@ consvar_t cv_bgaudio = Player("bgaudio", "Nothing").onchange_noinit(BGAudio_OnCh {0, "Nothing"}, {1, "Music"}, {2, "Sounds"}, + {4, "Voices"}, {3, "Music&Sounds"}, + {5, "Music&Voices"}, + {6, "Sounds&Voices"}, + {7, "MusicSounds&Voices"} }); // Pause game upon window losing focus diff --git a/src/d_clisrv.c b/src/d_clisrv.c index ea80bcb16..d389b6077 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -5395,7 +5395,7 @@ static void PT_HandleVoiceClient(SINT8 node, boolean isserver) { continue; } - if (cv_voice_selfdeafen.value != 1 && playernum != g_localplayers[0]) + if (cv_voice_selfdeafen.value != 1 && playernum != g_localplayers[0] && !g_voice_disabled) { S_QueueVoiceFrameFromPlayer(playernum, (void*)decoded_out, decoded_samples * sizeof(float), false); } @@ -5409,7 +5409,7 @@ static void PT_HandleVoiceClient(SINT8 node, boolean isserver) return; } - if (cv_voice_selfdeafen.value != 1 && playernum != g_localplayers[0]) + if (cv_voice_selfdeafen.value != 1 && playernum != g_localplayers[0] && !g_voice_disabled) { S_QueueVoiceFrameFromPlayer(playernum, (void*)decoded_out, decoded_samples * sizeof(float), terminal); } @@ -7679,7 +7679,7 @@ void NetVoiceUpdate(void) continue; } - if (cv_voice_selfdeafen.value == 1) + if (cv_voice_selfdeafen.value == 1 || g_voice_disabled) { g_local_voice_buffer_len = 0; continue; diff --git a/src/s_sound.c b/src/s_sound.c index 134325dec..92f2361fe 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -2858,6 +2858,9 @@ void BGAudio_OnChange(void) if (window_notinfocus && !(cv_bgaudio.value & 2)) S_StopSounds(); + + if (window_notinfocus && !(cv_bgaudio.value & 4)) + g_voice_disabled = true; } @@ -2889,7 +2892,7 @@ void S_QueueVoiceFrameFromPlayer(INT32 playernum, void *data, UINT32 len, boolea { return; } - if (cv_voice_selfdeafen.value != 1) + if (cv_voice_selfdeafen.value != 1 && !g_voice_disabled) { I_QueueVoiceFrameFromPlayer(playernum, data, len, terminal); } diff --git a/src/sdl/i_video.cpp b/src/sdl/i_video.cpp index 4cac6d48d..7fa8e0c3f 100644 --- a/src/sdl/i_video.cpp +++ b/src/sdl/i_video.cpp @@ -523,6 +523,7 @@ static void Impl_HandleWindowEvent(SDL_WindowEvent evt) window_notinfocus = false; S_SetMusicVolume(); + g_voice_disabled = cv_voice_selfdeafen.value; if (!firsttimeonmouse) { @@ -537,6 +538,8 @@ static void Impl_HandleWindowEvent(SDL_WindowEvent evt) I_SetMusicVolume(0); if (!(cv_bgaudio.value & 2)) S_StopSounds(); + if (!(cv_bgaudio.value & 4)) + g_voice_disabled = true; G_ResetAllDeviceGameKeyDown(); G_ResetAllDeviceResponding();