]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
vid: move sound start/restart out of video start/restart
authorbones_was_here <bones_was_here@xonotic.au>
Sat, 7 Oct 2023 03:40:26 +0000 (13:40 +1000)
committerbones_was_here <bones_was_here@xonotic.au>
Wed, 8 Nov 2023 17:27:06 +0000 (03:27 +1000)
According to the comments in S_Restart_f() we must not restart sound
while running a map, but `vid_restart` did do that...

Also simplified/consolidated code paths a little.

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
cl_main.c
host.c
snd_main.c
vid_shared.c

index b7d4f148d50101eb38da70369c95044f2d358032..d1887cb1ac360befe24a3fc81ec26a5871e40050 100644 (file)
--- a/cl_main.c
+++ b/cl_main.c
@@ -2797,7 +2797,6 @@ void CL_StartVideo(void)
                NetConn_UpdateSockets();
 #endif
                VID_Start();
-               CDAudio_Startup();
        }
 }
 
@@ -2973,7 +2972,6 @@ void CL_Shutdown (void)
                MR_Shutdown();
 #endif
 
-       CDAudio_Shutdown ();
        S_Terminate ();
        
        R_Modules_Shutdown();
@@ -2985,7 +2983,6 @@ void CL_Shutdown (void)
        CL_MeshEntities_Shutdown();
 
        Key_Shutdown();
-       S_Shutdown();
 
        Mem_FreePool (&cls.permanentmempool);
        Mem_FreePool (&cls.levelmempool);
@@ -3017,7 +3014,6 @@ void CL_Init (void)
                VID_Init();
                Render_Init();
                S_Init();
-               CDAudio_Init();
                Key_Init();
                V_Init();
 
diff --git a/host.c b/host.c
index 9a39d8bf5cff383ecbe5f5247ec28a02455cc7bf..5ecf7972fc6bd4bcc251f6497c8d392700a5aef3 100644 (file)
--- a/host.c
+++ b/host.c
@@ -503,6 +503,7 @@ static void Host_Init (void)
        {
                // put up the loading image so the user doesn't stare at a black screen...
                SCR_BeginLoadingPlaque(true);
+               S_Startup();
 #ifdef CONFIG_MENU
                MR_Init();
 #endif
index ebf84b9bfd599e29601877a9e12971fa4116b872..6f3bf31e1294bd9f313377db4c08ebd6b1c9c29e 100644 (file)
@@ -661,6 +661,8 @@ void S_Startup (void)
 #ifdef CONFIG_VIDEO_CAPTURE
        recording_sound = false;
 #endif
+
+       CDAudio_Startup();
 }
 
 void S_Shutdown(void)
@@ -668,6 +670,8 @@ void S_Shutdown(void)
        if (snd_renderbuffer == NULL)
                return;
 
+       CDAudio_Shutdown();
+
        oldpaintedtime = snd_renderbuffer->endframe;
 
        if (simsound)
@@ -824,6 +828,8 @@ void S_Init(void)
 #ifdef USEXMP
        XMP_OpenLibrary ();
 #endif
+
+       CDAudio_Init();
 }
 
 
index aa34a1e38ab54be17cea6b9cdf6799f76e049698..ab55661a6eff572af83f574e1c2f9f8be59b552a 100644 (file)
@@ -1464,20 +1464,6 @@ static int VID_Mode(int fullscreen, int width, int height, int bpp, float refres
                return false;
 }
 
-static void VID_OpenSystems(void)
-{
-       Key_ReleaseAll();
-       R_Modules_Start();
-       S_Startup();
-}
-
-static void VID_CloseSystems(void)
-{
-       S_Shutdown();
-       R_Modules_Shutdown();
-       Key_ReleaseAll();
-}
-
 qbool vid_commandlinecheck = true;
 extern qbool vid_opened;
 
@@ -1492,7 +1478,8 @@ void VID_Restart_f(cmd_state_t *cmd)
        Con_Printf("VID_Restart: changing from %s %dx%dx%dbpp%s, to %s %dx%dx%dbpp%s.\n",
                vid.mode.fullscreen ? "fullscreen" : "window", vid.mode.width, vid.mode.height, vid.mode.bitsperpixel, vid.mode.fullscreen && vid.mode.userefreshrate ? va(vabuf, sizeof(vabuf), "x%.2fhz", vid.mode.refreshrate) : "",
                vid_fullscreen.integer ? "fullscreen" : "window", vid_width.integer, vid_height.integer, vid_bitsperpixel.integer, vid_fullscreen.integer && vid_userefreshrate.integer ? va(vabuf, sizeof(vabuf), "x%.2fhz", vid_refreshrate.value) : "");
-       VID_CloseSystems();
+       SCR_DeferLoadingPlaque(false);
+       R_Modules_Shutdown();
        VID_Shutdown();
        if (!VID_Mode(vid_fullscreen.integer, vid_width.integer, vid_height.integer, vid_bitsperpixel.integer, vid_refreshrate.value, vid_stereobuffer.integer))
        {
@@ -1500,9 +1487,8 @@ void VID_Restart_f(cmd_state_t *cmd)
                if (!VID_Mode(vid.mode.fullscreen, vid.mode.width, vid.mode.height, vid.mode.bitsperpixel, vid.mode.refreshrate, vid.mode.stereobuffer))
                        Sys_Error("Unable to restore to last working video mode");
        }
-
-       SCR_DeferLoadingPlaque(false);
-       VID_OpenSystems();
+       R_Modules_Start();
+       Key_ReleaseAll();
 }
 
 const char *vidfallbacks[][2] =
@@ -1576,13 +1562,9 @@ void VID_Start(void)
                if (!success)
                        Sys_Error("Video modes failed");
        }
-       VID_OpenSystems();
-}
 
-void VID_Stop(void)
-{
-       VID_CloseSystems();
-       VID_Shutdown();
+       R_Modules_Start();
+       Key_ReleaseAll();
 }
 
 static int VID_SortModes_Compare(const void *a_, const void *b_)