From 97445f941a25df089c7bdf7d1b645faaf46e1654 Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Sun, 29 Oct 2017 01:09:34 -0400 Subject: [PATCH 1/7] Add command to restart the audio system --- src/d_netcmd.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index b5563f4e..247829c8 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -26,6 +26,7 @@ #include "p_local.h" #include "p_setup.h" #include "s_sound.h" +#include "i_sound.h" #include "m_misc.h" #include "am_map.h" #include "byteptr.h" @@ -128,6 +129,7 @@ static void Command_Playintro_f(void); static void Command_Displayplayer_f(void); static void Command_Tunes_f(void); +static void Command_RestartAudio_f(void); static void Command_ExitLevel_f(void); static void Command_Showmap_f(void); @@ -670,6 +672,7 @@ void D_RegisterClientCommands(void) COM_AddCommand("displayplayer", Command_Displayplayer_f); COM_AddCommand("tunes", Command_Tunes_f); + COM_AddCommand("restartaudio", Command_RestartAudio_f); CV_RegisterVar(&cv_resetmusic); // FIXME: not to be here.. but needs be done for config loading @@ -3909,6 +3912,20 @@ static void Command_Tunes_f(void) } } +static void Command_RestartAudio_f(void) +{ + I_ShutdownMusic(); + I_ShutdownSound(); + I_StartupSound(); + I_InitMusic(); + +// These must be called or everthing will be muted for the user until next volume change. + + I_SetSfxVolume(cv_soundvolume.value); + I_SetDigMusicVolume(cv_digmusicvolume.value); + I_SetMIDIMusicVolume(cv_midimusicvolume.value); +} + /** Quits a game and returns to the title screen. * */ From 4f8b91c770d35f12e3aeef08910cac88586002af Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Tue, 7 Nov 2017 16:26:45 -0500 Subject: [PATCH 2/7] Attempt to restart music --- src/d_netcmd.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 247829c8..501216b0 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -3914,16 +3914,21 @@ static void Command_Tunes_f(void) static void Command_RestartAudio_f(void) { + if (dedicated) // No point in doing anything game is a dedicated server. + return; + I_ShutdownMusic(); I_ShutdownSound(); I_StartupSound(); I_InitMusic(); -// These must be called or everthing will be muted for the user until next volume change. - +// These must be called or no sound and music untill manually set. + I_SetSfxVolume(cv_soundvolume.value); I_SetDigMusicVolume(cv_digmusicvolume.value); I_SetMIDIMusicVolume(cv_midimusicvolume.value); + if (Playing() && (!dedicated)) + P_RestoreMusic(displayplayer); } /** Quits a game and returns to the title screen. From c1405137ecf6464cb68eefd299955004e3147a86 Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Tue, 7 Nov 2017 23:48:03 -0500 Subject: [PATCH 3/7] Extra tab space to make the compiler happy --- src/d_netcmd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 501216b0..67a680c3 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -3915,7 +3915,7 @@ static void Command_Tunes_f(void) static void Command_RestartAudio_f(void) { if (dedicated) // No point in doing anything game is a dedicated server. - return; + return; I_ShutdownMusic(); I_ShutdownSound(); @@ -3928,7 +3928,7 @@ static void Command_RestartAudio_f(void) I_SetDigMusicVolume(cv_digmusicvolume.value); I_SetMIDIMusicVolume(cv_midimusicvolume.value); if (Playing() && (!dedicated)) - P_RestoreMusic(displayplayer); + P_RestoreMusic(displayplayer); } /** Quits a game and returns to the title screen. From 55c86f3e1558c6bf34de2de4a9b36cd9f9c12df4 Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Wed, 8 Nov 2017 14:48:05 -0500 Subject: [PATCH 4/7] Successful attempt at restarting the music --- src/d_netcmd.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 67a680c3..e433e3c5 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -3914,9 +3914,10 @@ static void Command_Tunes_f(void) static void Command_RestartAudio_f(void) { - if (dedicated) // No point in doing anything game is a dedicated server. + if (dedicated) { // No point in doing anything if game is a dedicated server. return; - +} + S_StopMusic(); I_ShutdownMusic(); I_ShutdownSound(); I_StartupSound(); @@ -3927,8 +3928,9 @@ static void Command_RestartAudio_f(void) I_SetSfxVolume(cv_soundvolume.value); I_SetDigMusicVolume(cv_digmusicvolume.value); I_SetMIDIMusicVolume(cv_midimusicvolume.value); - if (Playing() && (!dedicated)) - P_RestoreMusic(displayplayer); + if (Playing() && (!dedicated)) { // Gotta make sure the player is in a level + P_RestoreMusic(&players[displayplayer]); + } } /** Quits a game and returns to the title screen. From e61549d81fcef5fc26f7f45ef16a5253baedcdff Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Wed, 8 Nov 2017 14:50:27 -0500 Subject: [PATCH 5/7] Opps, forgot to change this. --- src/d_netcmd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index e433e3c5..041cb134 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -3929,7 +3929,7 @@ static void Command_RestartAudio_f(void) I_SetDigMusicVolume(cv_digmusicvolume.value); I_SetMIDIMusicVolume(cv_midimusicvolume.value); if (Playing() && (!dedicated)) { // Gotta make sure the player is in a level - P_RestoreMusic(&players[displayplayer]); + P_RestoreMusic(&players[consoleplayer]); } } From 38561656233229536fb5bf8e5488191e470c495e Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Wed, 27 Dec 2017 13:18:20 -0500 Subject: [PATCH 6/7] Indentation cleanup --- src/d_netcmd.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 041cb134..2abba77a 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -3914,23 +3914,23 @@ static void Command_Tunes_f(void) static void Command_RestartAudio_f(void) { - if (dedicated) { // No point in doing anything if game is a dedicated server. + if (dedicated) // No point in doing anything if game is a dedicated server. return; -} + S_StopMusic(); I_ShutdownMusic(); I_ShutdownSound(); I_StartupSound(); I_InitMusic(); -// These must be called or no sound and music untill manually set. +// These must be called or no sound and music until manually set. I_SetSfxVolume(cv_soundvolume.value); I_SetDigMusicVolume(cv_digmusicvolume.value); I_SetMIDIMusicVolume(cv_midimusicvolume.value); - if (Playing() && (!dedicated)) { // Gotta make sure the player is in a level + if (Playing() && (!dedicated)) // Gotta make sure the player is in a level P_RestoreMusic(&players[consoleplayer]); - } + } /** Quits a game and returns to the title screen. From 875446295b6abdd60731bb46be546cab413513c2 Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Wed, 27 Dec 2017 16:36:57 -0500 Subject: [PATCH 7/7] Remove redundant !dedicated check --- src/d_netcmd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 2abba77a..43b933cf 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -3928,7 +3928,7 @@ static void Command_RestartAudio_f(void) I_SetSfxVolume(cv_soundvolume.value); I_SetDigMusicVolume(cv_digmusicvolume.value); I_SetMIDIMusicVolume(cv_midimusicvolume.value); - if (Playing() && (!dedicated)) // Gotta make sure the player is in a level + if (Playing()) // Gotta make sure the player is in a level P_RestoreMusic(&players[consoleplayer]); }