summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Howard2009-11-19 21:49:13 +0000
committerSimon Howard2009-11-19 21:49:13 +0000
commit43b0dbd272da1d590797d2974e94413971131129 (patch)
treea4deab2b5fe6a50d66966a792a103563a4464103
parente62fdd771f01ef7b50fe3cb8f456eae5d7db3748 (diff)
downloadchocolate-doom-43b0dbd272da1d590797d2974e94413971131129.tar.gz
chocolate-doom-43b0dbd272da1d590797d2974e94413971131129.tar.bz2
chocolate-doom-43b0dbd272da1d590797d2974e94413971131129.zip
Rework the OS X MIDI disabling code, as SDL_mixer 1.2.11 fixes the
crash. Check and disable MIDI by default if using an older version of SDL on OS X. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1730
-rw-r--r--setup/Makefile.am3
-rw-r--r--setup/configfile.c18
-rw-r--r--setup/sound.c25
-rw-r--r--setup/sound.h14
-rw-r--r--src/i_sdlmusic.c32
-rw-r--r--src/m_config.c19
-rw-r--r--src/s_sound.c10
7 files changed, 76 insertions, 45 deletions
diff --git a/setup/Makefile.am b/setup/Makefile.am
index af80d525..92b4e394 100644
--- a/setup/Makefile.am
+++ b/setup/Makefile.am
@@ -1,7 +1,7 @@
gamesdir = $(prefix)/games
-AM_CFLAGS = -I../textscreen -I../src
+AM_CFLAGS = -I../textscreen -I../src @SDLMIXER_CFLAGS@
games_PROGRAMS = chocolate-setup
@@ -34,6 +34,7 @@ endif
chocolate_setup_LDADD = \
../wince/libc_wince.a \
../textscreen/libtextscreen.a \
+ @SDLMIXER_LIBS@ \
@LDFLAGS@
.rc.o:
diff --git a/setup/configfile.c b/setup/configfile.c
index fe3c13de..6d57a107 100644
--- a/setup/configfile.c
+++ b/setup/configfile.c
@@ -42,6 +42,8 @@
#include <sys/types.h>
#endif
+#include "SDL_mixer.h"
+
#include "config.h"
#include "doomfeatures.h"
@@ -721,5 +723,21 @@ void M_ApplyPlatformDefaults(void)
#ifdef _WIN32_WCE
M_ApplyWindowsCEDefaults();
#endif
+
+ // Before SDL_mixer version 1.2.11, MIDI music caused the game
+ // to crash when it looped. If this is an old SDL_mixer version,
+ // disable MIDI.
+
+#ifdef __MACOSX__
+ {
+ const SDL_version *v = Mix_Linked_Version();
+
+ if (SDL_VERSIONNUM(v->major, v->minor, v->patch)
+ < SDL_VERSIONNUM(1, 2, 11))
+ {
+ snd_musicdevice = SNDDEVICE_NONE;
+ }
+ }
+#endif
}
diff --git a/setup/sound.c b/setup/sound.c
index 72414c83..9e02aeec 100644
--- a/setup/sound.c
+++ b/setup/sound.c
@@ -27,20 +27,6 @@
#include "sound.h"
-enum
-{
- SNDDEVICE_NONE = 0,
- SNDDEVICE_PCSPEAKER = 1,
- SNDDEVICE_ADLIB = 2,
- SNDDEVICE_SB = 3,
- SNDDEVICE_PAS = 4,
- SNDDEVICE_GUS = 5,
- SNDDEVICE_WAVEBLASTER = 6,
- SNDDEVICE_SOUNDCANVAS = 7,
- SNDDEVICE_GENMIDI = 8,
- SNDDEVICE_AWE32 = 9,
-};
-
typedef enum
{
SFXMODE_DISABLED,
@@ -56,20 +42,11 @@ static char *sfxmode_strings[] =
"Digital",
};
-// Disable MIDI music on OSX: there are problems with the native
-// MIDI code in SDL_mixer.
-
-#ifdef __MACOSX__
-#define DEFAULT_MUSIC_DEVICE SNDDEVICE_NONE
-#else
-#define DEFAULT_MUSIC_DEVICE SNDDEVICE_SB
-#endif
-
int snd_sfxdevice = SNDDEVICE_SB;
int numChannels = 8;
int sfxVolume = 15;
-int snd_musicdevice = DEFAULT_MUSIC_DEVICE;
+int snd_musicdevice = SNDDEVICE_SB;
int musicVolume = 15;
int snd_samplerate = 22050;
diff --git a/setup/sound.h b/setup/sound.h
index 170dda0a..6c366151 100644
--- a/setup/sound.h
+++ b/setup/sound.h
@@ -22,6 +22,20 @@
#ifndef SETUP_SOUND_H
#define SETUP_SOUND_H
+enum
+{
+ SNDDEVICE_NONE = 0,
+ SNDDEVICE_PCSPEAKER = 1,
+ SNDDEVICE_ADLIB = 2,
+ SNDDEVICE_SB = 3,
+ SNDDEVICE_PAS = 4,
+ SNDDEVICE_GUS = 5,
+ SNDDEVICE_WAVEBLASTER = 6,
+ SNDDEVICE_SOUNDCANVAS = 7,
+ SNDDEVICE_GENMIDI = 8,
+ SNDDEVICE_AWE32 = 9,
+};
+
extern int snd_sfxdevice;
extern int numChannels;
extern int sfxVolume;
diff --git a/src/i_sdlmusic.c b/src/i_sdlmusic.c
index 81f492b5..7f9bd8ec 100644
--- a/src/i_sdlmusic.c
+++ b/src/i_sdlmusic.c
@@ -81,18 +81,28 @@ static boolean SDLIsInitialized(void)
// Initialize music subsystem
static boolean I_SDL_InitMusic(void)
-{
- // When trying to run with music enabled on OSX, display
- // a warning message.
-
-#ifdef __APPLE__
- printf("\n"
- " *** WARNING ***\n"
- " Music playback on OSX may cause crashes and\n"
- " is disabled by default.\n"
- "\n");
+{
+ // SDL_mixer prior to v1.2.11 has a bug that causes crashes
+ // with MIDI playback. Print a warning message if we are
+ // using an old version.
+
+#ifdef __MACOSX__
+ {
+ const SDL_version *v = Mix_Linked_Version();
+
+ if (SDL_VERSIONNUM(v->major, v->minor, v->patch)
+ < SDL_VERSIONNUM(1, 2, 11))
+ {
+ printf("\n"
+ " *** WARNING ***\n"
+ " You are using an old version of SDL_mixer.\n"
+ " Music playback on this version may cause crashes\n"
+ " under OS X and is disabled by default.\n"
+ "\n");
+ }
+ }
#endif
-
+
// If SDL_mixer is not initialized, we have to initialize it
// and have the responsibility to shut it down later on.
diff --git a/src/m_config.c b/src/m_config.c
index 4f789845..73f0da2c 100644
--- a/src/m_config.c
+++ b/src/m_config.c
@@ -36,6 +36,8 @@
#include <windows.h>
#endif
+#include "SDL_mixer.h"
+
#include "config.h"
#include "deh_main.h"
#include "doomdef.h"
@@ -53,6 +55,7 @@
#include "i_swap.h"
#include "i_system.h"
#include "i_video.h"
+#include "s_sound.h"
#include "v_video.h"
#include "hu_stuff.h"
@@ -1456,5 +1459,21 @@ void M_ApplyPlatformDefaults(void)
#ifdef _WIN32_WCE
M_ApplyWindowsCEDefaults();
#endif
+
+ // Before SDL_mixer version 1.2.11, MIDI music caused the game
+ // to crash when it looped. If this is an old SDL_mixer version,
+ // disable MIDI.
+
+#ifdef __MACOSX__
+ {
+ const SDL_version *v = Mix_Linked_Version();
+
+ if (SDL_VERSIONNUM(v->major, v->minor, v->patch)
+ < SDL_VERSIONNUM(1, 2, 11))
+ {
+ snd_musicdevice = SNDDEVICE_NONE;
+ }
+ }
+#endif
}
diff --git a/src/s_sound.c b/src/s_sound.c
index 9b4f71aa..1c56efb2 100644
--- a/src/s_sound.c
+++ b/src/s_sound.c
@@ -69,14 +69,6 @@
#define NORM_PRIORITY 64
#define NORM_SEP 128
-// Disable music on OSX by default; there are problems with SDL_mixer.
-
-#ifndef __APPLE__
-#define DEFAULT_MUSIC_DEVICE SNDDEVICE_SB
-#else
-#define DEFAULT_MUSIC_DEVICE SNDDEVICE_NONE
-#endif
-
typedef struct
{
// sound information (if null, channel avail.)
@@ -128,7 +120,7 @@ static musicinfo_t *mus_playing = NULL;
int numChannels = 8;
-int snd_musicdevice = DEFAULT_MUSIC_DEVICE;
+int snd_musicdevice = SNDDEVICE_SB;
int snd_sfxdevice = SNDDEVICE_SB;
// Sound modules