shithub: choc

Download patch

ref: 08925d637e30eb12889129c19f53dddef9be6e2e
parent: 7b151f074e26aa398b3cbd4811e4e6edd8a7918c
author: Simon Howard <fraggle@gmail.com>
date: Mon Sep 5 16:32:18 EDT 2005

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

--- 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 @@
 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 @@
     return W_GetNumForName(namebuf);
 }
 
-static int soundtag = 0;
-
 //
 // Starting a sound means adding it
 //  to the current list of active sounds
@@ -213,6 +212,7 @@
 int
 I_StartSound
 ( int		id,
+  int           channel,
   int		vol,
   int		sep,
   int		pitch,
@@ -219,34 +219,11 @@
   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,20 +235,6 @@
 
 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);
 }
 
@@ -278,7 +241,6 @@
 
 int I_SoundIsPlaying(int handle)
 {
-    handle &= 0xff;
     return Mix_Playing(handle);
 }
 
@@ -325,16 +287,7 @@
   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;
--- 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_StartSound
 ( int		id,
+  int           channel,
   int		vol,
   int		sep,
   int		pitch,
@@ -118,6 +119,10 @@
 //-----------------------------------------------------------------------------
 //
 // $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
--- 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 @@
   // 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,