foxygit / doom Log in
commit da6a260461920d4cafd4c6d1d624aebf2d9b975c
Author:     Simon Howard <fraggle@gmail.com>
AuthorDate: Sun Mar 23 21:43:12 2014 -0400
Commit:     Simon Howard <fraggle@gmail.com>
CommitDate: Sun Mar 23 21:43:12 2014 -0400

    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.
---
 src/doom/d_main.c     | 2 ++
 src/doom/s_sound.c    | 3 ---
 src/heretic/d_main.c  | 5 ++++-
 src/heretic/s_sound.c | 1 -
 src/hexen/h2_main.c   | 2 ++
 src/hexen/s_sound.c   | 2 --
 src/strife/d_main.c   | 4 +++-
 src/strife/s_sound.c  | 3 ---
 8 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/src/doom/d_main.c b/src/doom/d_main.c
index 5f7e2051..b2566176 100644
--- a/src/doom/d_main.c
+++ b/src/doom/d_main.c
@@ -1470,6 +1470,8 @@ void D_DoomMain (void)
     I_CheckIsScreensaver();
     I_InitTimer();
     I_InitJoystick();
+    I_InitSound(true);
+    I_InitMusic();

 #ifdef FEATURE_MULTIPLAYER
     printf ("NET_Init: Init network subsystem.\n");
diff --git a/src/doom/s_sound.c b/src/doom/s_sound.c
index 12a55d8f..7b000e94 100644
--- a/src/doom/s_sound.c
+++ b/src/doom/s_sound.c
@@ -122,9 +122,6 @@ void S_Init(int sfxVolume, int musicVolume)
 {
     int i;

-    I_InitSound(true);
-    I_InitMusic();
-
     I_PrecacheSounds(S_sfx, NUMSFX);

     S_SetSfxVolume(sfxVolume);
diff --git a/src/heretic/d_main.c b/src/heretic/d_main.c
index 6af7dda1..178db2eb 100644
--- a/src/heretic/d_main.c
+++ b/src/heretic/d_main.c
@@ -1037,12 +1037,15 @@ void D_DoomMain(void)
         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
diff --git a/src/heretic/s_sound.c b/src/heretic/s_sound.c
index 755206b4..79e2d353 100644
--- a/src/heretic/s_sound.c
+++ b/src/heretic/s_sound.c
@@ -523,7 +523,6 @@ void S_UpdateSounds(mobj_t * listener)
 void S_Init(void)
 {
     soundCurve = Z_Malloc(MAX_SND_DIST, PU_STATIC, NULL);
-    I_InitSound(false);
     if (snd_Channels > 8)
     {
         snd_Channels = 8;
diff --git a/src/hexen/h2_main.c b/src/hexen/h2_main.c
index 07244417..0afdff24 100644
--- a/src/hexen/h2_main.c
+++ b/src/hexen/h2_main.c
@@ -325,6 +325,8 @@ void D_DoomMain(void)
     I_CheckIsScreensaver();
     I_InitTimer();
     I_InitJoystick();
+    I_InitSound(false);
+    I_InitMusic();

 #ifdef FEATURE_MULTIPLAYER
     ST_Message("NET_Init: Init networking subsystem.\n");
diff --git a/src/hexen/s_sound.c b/src/hexen/s_sound.c
index f6509d1c..3f1a1e76 100644
--- a/src/hexen/s_sound.c
+++ b/src/hexen/s_sound.c
@@ -796,8 +796,6 @@ void S_Init(void)
     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;
diff --git a/src/strife/d_main.c b/src/strife/d_main.c
index 855dae7d..7cd2387f 100644
--- a/src/strife/d_main.c
+++ b/src/strife/d_main.c
@@ -1640,8 +1640,10 @@ void D_DoomMain (void)
     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]
diff --git a/src/strife/s_sound.c b/src/strife/s_sound.c
index ec59f3a6..513ab62d 100644
--- a/src/strife/s_sound.c
+++ b/src/strife/s_sound.c
@@ -144,9 +144,6 @@ void S_Init(int sfxVolume, int musicVolume, int voiceVolume)
 {
     int i;

-    I_InitSound(true);
-    I_InitMusic();
-
     I_PrecacheSounds(S_sfx, NUMSFX);

     S_SetSfxVolume(sfxVolume);