summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon Howard2005-09-05 20:32:18 +0000
committerSimon Howard2005-09-05 20:32:18 +0000
commit08925d637e30eb12889129c19f53dddef9be6e2e (patch)
tree66c75916d3f6932221ee8adb4ffc9ee9af93274e /src
parent7b151f074e26aa398b3cbd4811e4e6edd8a7918c (diff)
downloadchocolate-doom-08925d637e30eb12889129c19f53dddef9be6e2e.tar.gz
chocolate-doom-08925d637e30eb12889129c19f53dddef9be6e2e.tar.bz2
chocolate-doom-08925d637e30eb12889129c19f53dddef9be6e2e.zip
Use the system-nonspecific sound code to assign the channel number used
by SDL. Remove handle tagging stuff. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 73
Diffstat (limited to 'src')
-rw-r--r--src/i_sound.c61
-rw-r--r--src/i_sound.h7
-rw-r--r--src/s_sound.c12
3 files changed, 21 insertions, 59 deletions
diff --git a/src/i_sound.c b/src/i_sound.c
index 52294b2d..4cd1fcb0 100644
--- a/src/i_sound.c
+++ b/src/i_sound.c
@@ -1,7 +1,7 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
-// $Id: i_sound.c 53 2005-08-19 21:55:51Z fraggle $
+// $Id: i_sound.c 73 2005-09-05 20:32:18Z fraggle $
//
// Copyright(C) 1993-1996 Id Software, Inc.
// Copyright(C) 2005 Simon Howard
@@ -22,6 +22,10 @@
// 02111-1307, USA.
//
// $Log$
+// Revision 1.11 2005/09/05 20:32:18 fraggle
+// Use the system-nonspecific sound code to assign the channel number used
+// by SDL. Remove handle tagging stuff.
+//
// Revision 1.10 2005/08/19 21:55:51 fraggle
// Make sounds louder. Use the correct maximum of 15 when doing sound
// calculations.
@@ -63,7 +67,7 @@
//-----------------------------------------------------------------------------
static const char
-rcsid[] = "$Id: i_sound.c 53 2005-08-19 21:55:51Z fraggle $";
+rcsid[] = "$Id: i_sound.c 73 2005-09-05 20:32:18Z fraggle $";
#include <stdio.h>
#include <stdlib.h>
@@ -86,9 +90,6 @@ rcsid[] = "$Id: i_sound.c 53 2005-08-19 21:55:51Z fraggle $";
static int sound_initialised = 0;
static Mix_Chunk sound_chunks[NUMSFX];
-static int sounds_in_use[256];
-static int nextchannel = 0;
-
static byte *expand_sound_data(byte *data, int samplerate, int length)
{
byte *result = data;
@@ -196,8 +197,6 @@ int I_GetSfxLumpNum(sfxinfo_t* sfx)
return W_GetNumForName(namebuf);
}
-static int soundtag = 0;
-
//
// Starting a sound means adding it
// to the current list of active sounds
@@ -213,40 +212,18 @@ static int soundtag = 0;
int
I_StartSound
( int id,
+ int channel,
int vol,
int sep,
int pitch,
int priority )
{
Mix_Chunk *chunk = getsfx(id);
- int channel;
-
- // find a free channel, starting from the first after
- // the last channel we used
-
- channel = nextchannel;
-
- do
- {
- channel = (channel + 1) % NUM_CHANNELS;
-
- if (channel == nextchannel)
- {
- fprintf(stderr, "No free sound channels left.\n");
- return -1;
- }
- } while (Mix_Playing(channel));
-
- nextchannel = channel;
// play sound
Mix_PlayChannelTimed(channel, chunk, 0, -1);
- sounds_in_use[channel] = soundtag;
- channel |= soundtag << 8;
- soundtag++;
-
// set separation, etc.
I_UpdateSoundParams(channel, vol, sep, pitch);
@@ -258,27 +235,12 @@ I_StartSound
void I_StopSound (int handle)
{
- int tag = handle >> 8;
-
- handle &= 0xff;
-
- if (sounds_in_use[handle] != tag)
- {
- fprintf(stderr,
- "stopping wrong sound: %i != %i (%i)\n",
- sounds_in_use[handle], tag,
- handle);
- }
-
- sounds_in_use[handle] = -1;
-
Mix_HaltChannel(handle);
}
int I_SoundIsPlaying(int handle)
{
- handle &= 0xff;
return Mix_Playing(handle);
}
@@ -325,17 +287,8 @@ I_UpdateSoundParams
int sep,
int pitch)
{
- int tag = handle >> 8;
int left, right;
- handle &= 0xff;
-
- if (sounds_in_use[handle] != tag)
- {
- fprintf(stderr,
- "tag is wrong for playing sound: %i, %i\n", tag, handle);
- }
-
left = ((254 - sep) * vol) / 15;
right = ((sep) * vol) / 15;
diff --git a/src/i_sound.h b/src/i_sound.h
index 50aec5a9..e0162a77 100644
--- a/src/i_sound.h
+++ b/src/i_sound.h
@@ -1,7 +1,7 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
-// $Id: i_sound.h 39 2005-08-04 21:48:32Z fraggle $
+// $Id: i_sound.h 73 2005-09-05 20:32:18Z fraggle $
//
// Copyright(C) 1993-1996 Id Software, Inc.
// Copyright(C) 2005 Simon Howard
@@ -63,6 +63,7 @@ int I_GetSfxLumpNum (sfxinfo_t* sfxinfo );
int
I_StartSound
( int id,
+ int channel,
int vol,
int sep,
int pitch,
@@ -118,6 +119,10 @@ void I_UnRegisterSong(int handle);
//-----------------------------------------------------------------------------
//
// $Log$
+// Revision 1.4 2005/09/05 20:32:18 fraggle
+// Use the system-nonspecific sound code to assign the channel number used
+// by SDL. Remove handle tagging stuff.
+//
// Revision 1.3 2005/08/04 21:48:32 fraggle
// Turn on compiler optimisation and warning options
// Add SDL_mixer sound code
diff --git a/src/s_sound.c b/src/s_sound.c
index 0692db9b..90b8ac06 100644
--- a/src/s_sound.c
+++ b/src/s_sound.c
@@ -1,7 +1,7 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
-// $Id: s_sound.c 39 2005-08-04 21:48:32Z fraggle $
+// $Id: s_sound.c 73 2005-09-05 20:32:18Z fraggle $
//
// Copyright(C) 1993-1996 Id Software, Inc.
// Copyright(C) 2005 Simon Howard
@@ -22,6 +22,10 @@
// 02111-1307, USA.
//
// $Log$
+// Revision 1.5 2005/09/05 20:32:18 fraggle
+// Use the system-nonspecific sound code to assign the channel number used
+// by SDL. Remove handle tagging stuff.
+//
// Revision 1.4 2005/08/04 21:48:32 fraggle
// Turn on compiler optimisation and warning options
// Add SDL_mixer sound code
@@ -42,7 +46,7 @@
static const char
-rcsid[] = "$Id: s_sound.c 39 2005-08-04 21:48:32Z fraggle $";
+rcsid[] = "$Id: s_sound.c 73 2005-09-05 20:32:18Z fraggle $";
@@ -387,11 +391,11 @@ S_StartSoundAtVolume
// increase the usefulness
if (sfx->usefulness++ < 0)
sfx->usefulness = 1;
-
+
// Assigns the handle to one of the channels in the
// mix/output buffer.
channels[cnum].handle = I_StartSound(sfx_id,
- /*sfx->data,*/
+ cnum,
volume,
sep,
pitch,