ref: 2a026e12779b77b2aeabb78bdca3ea00e10d478a
parent: 991ef372d4acdf5f2fcae09cef05bfec12ce9b64
author: Simon Howard <fraggle@gmail.com>
date: Wed May 16 10:28:22 EDT 2007
Add FEATURE_SOUND. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 877
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -49,8 +49,6 @@
i_main.c \
info.c info.h \
i_scale.c i_scale.h \
-i_pcsound.c i_pcsound.h \
-i_sound.c i_sound.h \
i_swap.h \
i_system.c i_system.h \
i_timer.c i_timer.h \
@@ -63,7 +61,6 @@
m_misc.c m_misc.h \
md5.c md5.h \
memio.c memio.h \
-mus2mid.c mus2mid.h \
m_random.c m_random.h \
p_ceilng.c \
p_doors.c \
@@ -97,7 +94,6 @@
r_state.h \
r_things.c r_things.h \
sounds.c sounds.h \
-s_sound.c s_sound.h \
st_lib.c st_lib.h \
st_stuff.c st_stuff.h \
tables.c tables.h \
@@ -145,10 +141,19 @@
FEATURE_WAD_MERGE_SOURCE_FILES = \
w_merge.c w_merge.h
+# source files needed for FEATURE_SOUND
+
+FEATURE_SOUND_SOURCE_FILES = \
+i_pcsound.c i_pcsound.h \
+i_sound.c i_sound.h \
+mus2mid.c mus2mid.h \
+s_sound.c s_sound.h
+
SOURCE_FILES = $(MAIN_SOURCE_FILES) \
$(FEATURE_DEHACKED_SOURCE_FILES) \
$(FEATURE_MULTIPLAYER_SOURCE_FILES) \
- $(FEATURE_WAD_MERGE_SOURCE_FILES)
+ $(FEATURE_WAD_MERGE_SOURCE_FILES) \
+ $(FEATURE_SOUND_SOURCE_FILES)
if HAVE_WINDRES
chocolate_doom_SOURCES=$(SOURCE_FILES) chocolate-doom-res.rc
@@ -160,7 +165,8 @@
EXTRA_DIST = \
chocolate_doom_icon.c \
- chocolate-doom-screensaver.desktop
+ chocolate-doom-screensaver.desktop \
+ s_dummy.c
.rc.o:
$(WINDRES) $^ -o $@
--- a/src/deh_sound.c
+++ b/src/deh_sound.c
@@ -27,6 +27,7 @@
#include <stdlib.h>
#include "doomdef.h"
+#include "doomfeatures.h"
#include "doomtype.h"
#include "deh_defs.h"
#include "deh_main.h"
@@ -48,7 +49,6 @@
static void *DEH_SoundStart(deh_context_t *context, char *line)
{
int sound_number = 0;
- sfxinfo_t *sfx;
if (sscanf(line, "Sound %i", &sound_number) != 1)
{
@@ -67,10 +67,16 @@
DEH_Warning(context, "Attempt to modify SFX %i. This will problems "
"in Vanilla dehacked.", sound_number);
}
+
+#ifdef FEATURE_SOUND
- sfx = &S_sfx[sound_number];
-
- return sfx;
+ return &S_sfx[sound_number];
+
+#else
+
+ return NULL;
+
+#endif
}
static void DEH_SoundParseLine(deh_context_t *context, char *line, void *tag)
--- a/src/doomfeatures.h
+++ b/src/doomfeatures.h
@@ -39,6 +39,10 @@
#define FEATURE_MULTIPLAYER 1
+// Enables sound output
+
+#define FEATURE_SOUND 1
+
#endif /* #ifndef DOOM_FEATURES_H */
--- a/src/i_sound.c
+++ b/src/i_sound.c
@@ -43,6 +43,7 @@
#include "i_sound.h"
#include "i_swap.h"
#include "deh_main.h"
+#include "s_sound.h"
#include "m_argv.h"
#include "m_misc.h"
#include "w_wad.h"
@@ -53,23 +54,6 @@
#define MAXMIDLENGTH (96 * 1024)
-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 snd_musicdevice;
-
static boolean nosfxparm;
static boolean nomusicparm;
@@ -83,17 +67,6 @@
static Uint16 mixer_format;
static int mixer_channels;
-// 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,
// we can mark the sound data as CACHE to be freed back for other
// means.
@@ -506,6 +479,9 @@
Mix_CloseAudio();
SDL_QuitSubSystem(SDL_INIT_AUDIO);
+
+ sound_initialised = false;
+ music_initialised = false;
}
@@ -624,15 +600,6 @@
//
// MUSIC API.
//
-
-void I_InitMusic(void)
-{
-}
-
-void I_ShutdownMusic(void)
-{
- music_initialised = false;
-}
static boolean musicpaused = false;
static int currentMusicVolume;
--- a/src/i_system.c
+++ b/src/i_system.c
@@ -34,11 +34,12 @@
#include "deh_main.h"
#include "doomdef.h"
+#include "doomstat.h"
#include "m_argv.h"
#include "m_misc.h"
-#include "i_sound.h"
#include "i_timer.h"
#include "i_video.h"
+#include "s_sound.h"
#include "d_net.h"
#include "g_game.h"
@@ -113,8 +114,6 @@
void I_Init (void)
{
I_CheckIsScreensaver();
- I_InitSound();
- I_InitMusic();
I_InitTimer();
}
@@ -169,8 +168,7 @@
{
D_QuitNetGame ();
G_CheckDemoStatus();
- I_ShutdownSound();
- I_ShutdownMusic();
+ S_Shutdown();
if (!screensaver_mode)
{
--- /dev/null
+++ b/src/s_dummy.c
@@ -1,0 +1,180 @@
+// Emacs style mode select -*- C++ -*-
+//-----------------------------------------------------------------------------
+//
+// Copyright(C) 1993-1996 Id Software, Inc.
+// Copyright(C) 2005 Simon Howard
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+// 02111-1307, USA.
+//
+// DESCRIPTION: Dummy sound interface for running with FEATURE_SOUND
+// disabled.
+//
+//-----------------------------------------------------------------------------
+
+#include "doomtype.h"
+#include "s_sound.h"
+#include "p_mobj.h"
+#include "sounds.h"
+
+int snd_musicdevice = SNDDEVICE_NONE;
+int snd_sfxdevice = SNDDEVICE_NONE;
+
+// Maximum volume of a sound effect.
+// Internal default is max out of 0-15.
+int sfxVolume = 8;
+
+// Maximum volume of music.
+int musicVolume = 8;
+
+// number of channels available
+
+int numChannels = 8;
+
+//
+// Initializes sound stuff, including volume
+// Sets channels, SFX and music volume,
+// allocates channel buffer, sets S_sfx lookup.
+//
+void S_Init
+( int sfxVolume,
+ int musicVolume )
+{
+}
+
+void S_Shutdown(void)
+{
+}
+
+//
+// Per level startup code.
+// Kills playing sounds at start of level,
+// determines music if any, changes music.
+//
+void S_Start(void)
+{
+}
+
+void
+S_StartSoundAtVolume
+( void* origin_p,
+ int sfx_id,
+ int volume )
+{
+}
+
+void
+S_StartSound
+( void* origin,
+ int sfx_id )
+{
+}
+
+void S_StopSound(void *origin)
+{
+}
+
+//
+// Stop and resume music, during game PAUSE.
+//
+void S_PauseSound(void)
+{
+}
+
+void S_ResumeSound(void)
+{
+}
+
+
+//
+// Updates music & sounds
+//
+void S_UpdateSounds(void* listener_p)
+{
+}
+
+void S_SetMusicVolume(int volume)
+{
+}
+
+void S_SetSfxVolume(int volume)
+{
+}
+
+//
+// Starts some music with the music id found in sounds.h.
+//
+void S_StartMusic(int m_id)
+{
+}
+
+void
+S_ChangeMusic
+( int musicnum,
+ int looping )
+{
+}
+
+boolean S_MusicPlaying(void)
+{
+ return false;
+}
+
+
+void S_StopMusic(void)
+{
+}
+
+void S_StopChannel(int cnum)
+{
+}
+
+
+
+//
+// Changes volume, stereo-separation, and pitch variables
+// from the norm of a sound effect to be played.
+// If the sound is not audible, returns a 0.
+// Otherwise, modifies parameters and returns 1.
+//
+int
+S_AdjustSoundParams
+( mobj_t* listener,
+ mobj_t* source,
+ int* vol,
+ int* sep,
+ int* pitch )
+{
+ return 0;
+}
+
+
+
+
+//
+// S_getChannel :
+// If none available, return -1. Otherwise channel #.
+//
+int
+S_getChannel
+( void* origin,
+ sfxinfo_t* sfxinfo )
+{
+ return -1;
+}
+
+
+
+
--- a/src/s_sound.c
+++ b/src/s_sound.c
@@ -82,15 +82,16 @@
#define NA 0
#define S_NUMCHANNELS 2
+// Disable music on OSX by default; there are problems with SDL_mixer.
-// Current music/sfx card - index useless
-// w/o a reference LUT in a sound module.
-extern int snd_MusicDevice;
-extern int snd_SfxDevice;
-// Config file? Same disclaimer as above.
-extern int snd_DesiredMusicDevice;
-extern int snd_DesiredSfxDevice;
+#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;
typedef struct
@@ -169,6 +170,8 @@
{
int i;
+ I_InitSound();
+
// Whatever these did with DMX, these are rather dummies now.
I_SetChannels();
@@ -195,6 +198,10 @@
}
+void S_Shutdown(void)
+{
+ I_ShutdownSound();
+}
//
--- a/src/s_sound.h
+++ b/src/s_sound.h
@@ -29,9 +29,23 @@
#define __S_SOUND__
+typedef 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,
+} snddevice_t;
+extern int snd_sfxdevice;
+extern int snd_musicdevice;
-
//
// Initializes sound stuff, including volume
// Sets channels, SFX and music volume,
@@ -43,8 +57,12 @@
int musicVolume );
+// Shut down sound
+void S_Shutdown(void);
+
+
//
// Per level startup code.
// Kills playing sounds at start of level,
@@ -51,7 +69,6 @@
// determines music if any, changes music.
//
void S_Start(void);
-
//
// Start sound for thing at <origin>