ref: 43b0dbd272da1d590797d2974e94413971131129
parent: e62fdd771f01ef7b50fe3cb8f456eae5d7db3748
author: Simon Howard <[email protected]>
date: Thu Nov 19 16:49:13 EST 2009
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
--- 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 @@
chocolate_setup_LDADD = \
../wince/libc_wince.a \
../textscreen/libtextscreen.a \
+ @SDLMIXER_LIBS@ \
@LDFLAGS@
.rc.o:
--- 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"
@@ -720,6 +722,22 @@
{
#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
}
--- 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 @@
"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;
--- 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;
--- a/src/i_sdlmusic.c
+++ b/src/i_sdlmusic.c
@@ -81,18 +81,28 @@
// Initialize music subsystem
static boolean I_SDL_InitMusic(void)
-{
- // When trying to run with music enabled on OSX, display
- // a warning message.
+{
+ // 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 __APPLE__
- printf("\n"
- " *** WARNING ***\n"
- " Music playback on OSX may cause crashes and\n"
- " is disabled by default.\n"
- "\n");
+#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.
--- 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"
@@ -1455,6 +1458,22 @@
{
#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
}
--- 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 @@
int numChannels = 8;
-int snd_musicdevice = DEFAULT_MUSIC_DEVICE;
+int snd_musicdevice = SNDDEVICE_SB;
int snd_sfxdevice = SNDDEVICE_SB;
// Sound modules