shithub: choc

Download patch

ref: da6a260461920d4cafd4c6d1d624aebf2d9b975c
parent: 84f136b51e07b4d9815c6b033e897ebaef4f16a7
author: Simon Howard <[email protected]>
date: Sun Mar 23 17:43:12 EDT 2014

Rearrange order of SDL sound startup.

Initialize low-level sound startup (calls to I_InitSound) separately
from the high-level sound startup (S_Init). In particular, make sure
that SDL sound is initialized before the textscreen multiplayer
waiting screen is shown. This is an attempt to fix a bug with sound in
multiplayer games on Windows; calling SDL_QuitSubSystem(SDL_INIT_VIDEO)
(on closedown of the textscreen library) causes subsequent attempts to
initialize audio to fail.

Big thanks go to Alexandre-Xavier (AXDOOMER) for working out a fix for
this bug and James Haley (Quasar) for giving some technical background
about the lack of separation between SDL subsystems. This (hopefully)
fixes #270.

--- a/src/doom/d_main.c
+++ b/src/doom/d_main.c
@@ -1470,6 +1470,8 @@
     I_CheckIsScreensaver();
     I_InitTimer();
     I_InitJoystick();
+    I_InitSound(true);
+    I_InitMusic();
 
 #ifdef FEATURE_MULTIPLAYER
     printf ("NET_Init: Init network subsystem.\n");
--- a/src/doom/s_sound.c
+++ b/src/doom/s_sound.c
@@ -122,9 +122,6 @@
 {  
     int i;
 
-    I_InitSound(true);
-    I_InitMusic();
-
     I_PrecacheSounds(S_sfx, NUMSFX);
 
     S_SetSfxVolume(sfxVolume);
--- a/src/heretic/d_main.c
+++ b/src/heretic/d_main.c
@@ -1037,12 +1037,15 @@
         testcontrols = true;
     }
 
+    I_InitTimer();
+    I_InitSound(false);
+    I_InitMusic();
+
 #ifdef FEATURE_MULTIPLAYER
     tprintf("NET_Init: Init network subsystem.\n", 1);
     NET_Init ();
 #endif
 
-    I_InitTimer();
     D_ConnectNetGame();
 
     // haleyjd: removed WATCOMC
--- a/src/heretic/s_sound.c
+++ b/src/heretic/s_sound.c
@@ -523,7 +523,6 @@
 void S_Init(void)
 {
     soundCurve = Z_Malloc(MAX_SND_DIST, PU_STATIC, NULL);
-    I_InitSound(false);
     if (snd_Channels > 8)
     {
         snd_Channels = 8;
--- a/src/hexen/h2_main.c
+++ b/src/hexen/h2_main.c
@@ -325,6 +325,8 @@
     I_CheckIsScreensaver();
     I_InitTimer();
     I_InitJoystick();
+    I_InitSound(false);
+    I_InitMusic();
 
 #ifdef FEATURE_MULTIPLAYER
     ST_Message("NET_Init: Init networking subsystem.\n");
--- a/src/hexen/s_sound.c
+++ b/src/hexen/s_sound.c
@@ -796,8 +796,6 @@
     SoundCurve = W_CacheLumpName("SNDCURVE", PU_STATIC);
 //      SoundCurve = Z_Malloc(MAX_SND_DIST, PU_STATIC, NULL);
 
-    I_InitSound(false);
-
     if (snd_Channels > 8)
     {
         snd_Channels = 8;
--- a/src/strife/d_main.c
+++ b/src/strife/d_main.c
@@ -1640,8 +1640,10 @@
     savegamedir = M_GetSaveGameDir("strife1.wad");
 
     // fraggle 20130405: I_InitTimer is needed here for the netgame
-    // startup.
+    // startup. Start low-level sound init here too.
     I_InitTimer();
+    I_InitSound(true);
+    I_InitMusic();
 
 #ifdef FEATURE_MULTIPLAYER
     if(devparm) // [STRIFE]
--- a/src/strife/s_sound.c
+++ b/src/strife/s_sound.c
@@ -144,9 +144,6 @@
 {  
     int i;
 
-    I_InitSound(true);
-    I_InitMusic();
-
     I_PrecacheSounds(S_sfx, NUMSFX);
 
     S_SetSfxVolume(sfxVolume);