From: bones_was_here Date: Sat, 7 Oct 2023 03:40:26 +0000 (+1000) Subject: vid: move sound start/restart out of video start/restart X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=aba8f3439c072d627041e57ab96e4e88d877774c;p=xonotic%2Fdarkplaces.git vid: move sound start/restart out of video start/restart 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 --- diff --git a/cl_main.c b/cl_main.c index b7d4f148..d1887cb1 100644 --- 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 9a39d8bf..5ecf7972 100644 --- 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 diff --git a/snd_main.c b/snd_main.c index ebf84b9b..6f3bf31e 100644 --- a/snd_main.c +++ b/snd_main.c @@ -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(); } diff --git a/vid_shared.c b/vid_shared.c index aa34a1e3..ab55661a 100644 --- a/vid_shared.c +++ b/vid_shared.c @@ -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_)