foxygit / doom Log in
commit 502ff6a666729f7b854e9c406030af24bb16d55c
Author:     Simon Howard <fraggle@gmail.com>
AuthorDate: Tue Dec 26 15:43:16 2006 +0000
Commit:     Simon Howard <fraggle@gmail.com>
CommitDate: Tue Dec 26 15:43:16 2006 +0000

    On OSX, make MIDI music disabled by default. There are problems with the
    native MIDI code in SDL_mixer.

    Subversion-branch: /trunk/chocolate-doom
    Subversion-revision: 811
---
 setup/sound.c | 12 +++++++++++-
 src/i_sound.c | 26 ++++++++++++++++++++++++--
 2 files changed, 35 insertions(+), 3 deletions(-)

diff --git a/setup/sound.c b/setup/sound.c
index d5a61ac4..10ec823c 100644
--- a/setup/sound.c
+++ b/setup/sound.c
@@ -23,15 +23,25 @@

 #include <stdlib.h>

+#include "SDL.h"
 #include "textscreen.h"

 #include "sound.h"

+// Disable MIDI music on OSX: there are problems with the native
+// MIDI code in SDL_mixer.
+
+#ifdef __MACOSX__
+#define DEFAULT_MUSIC_DEVICE 0
+#else
+#define DEFAULT_MUSIC_DEVICE 3
+#endif
+
 int snd_sfxdevice = 3;
 int numChannels = 8;
 int sfxVolume = 15;

-int snd_musicdevice = 3;
+int snd_musicdevice = DEFAULT_MUSIC_DEVICE;
 int musicVolume = 15;

 static int snd_sfxenabled;
diff --git a/src/i_sound.c b/src/i_sound.c
index bdb82c53..ec3a68ad 100644
--- a/src/i_sound.c
+++ b/src/i_sound.c
@@ -28,7 +28,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include "SDL.h"
-#include <SDL_mixer.h>
+#include "SDL_mixer.h"

 #ifndef _WIN32
 #include <unistd.h>
@@ -78,7 +78,15 @@ static boolean music_initialised = false;
 static Mix_Chunk sound_chunks[NUMSFX];
 static int channels_playing[NUM_CHANNELS];

-int snd_musicdevice = SNDDEVICE_SB;
+// Disable music on OSX by default; there are problems with SDL_mixer.
+
+#ifndef __MACOSX__
+#define DEFAULT_MUSIC_DEVICE SNDDEVICE_SB
+#else
+#define DEFAULT_MUSIC_DEVICE SNDDEVICE_NONE
+#endif
+
+int snd_musicdevice = DEFAULT_MUSIC_DEVICE;
 int snd_sfxdevice = SNDDEVICE_SB;

 // When a sound stops, check if it is still playing.  If it is not,
@@ -475,6 +483,20 @@ I_InitSound()
         nosfxparm = true;
     }

+    // When trying to run with music enabled on OSX, display
+    // a warning message.
+
+#ifdef __MACOSX__
+    if (!nomusicparm)
+    {
+        printf("\n"
+               "                   *** WARNING ***\n"
+               "      Music playback on OSX may cause crashes and\n"
+               "      is disabled by default.\n"
+               "\n");
+    }
+#endif
+
     //!
     // Disable sound effects and music.
     //