From: Carsten W. <ca...@us...> - 2012-04-12 22:01:27
|
Update of /cvsroot/jake2/jake2/src/jake2/sound/lwjgl In directory vz-cvs-3.sog:/tmp/cvs-serv9975/src/jake2/sound/lwjgl Modified Files: PlaySound.java Log Message: formatted Index: PlaySound.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/sound/lwjgl/PlaySound.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PlaySound.java 8 May 2005 13:37:46 -0000 1.2 --- PlaySound.java 12 Apr 2012 22:01:24 -0000 1.3 *************** *** 7,28 **** */ /* ! Copyright (C) 1997-2001 Id Software, Inc. ! 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. ! */ package jake2.sound.lwjgl; --- 7,28 ---- */ /* ! Copyright (C) 1997-2001 Id Software, Inc. ! 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. ! */ package jake2.sound.lwjgl; *************** *** 36,66 **** */ public class PlaySound { ! ! final static int MAX_PLAYSOUNDS = 128; ! ! // list with sentinel ! private static PlaySound freeList; ! private static PlaySound playableList; ! ! private static PlaySound[] backbuffer = new PlaySound[MAX_PLAYSOUNDS]; ! static { ! for (int i = 0; i < backbuffer.length; i++) { ! backbuffer[i] = new PlaySound(); } ! // init the sentinels ! freeList = new PlaySound(); ! playableList = new PlaySound(); ! // reset the lists ! reset(); ! } ! // sound attributes int type; ! int entnum; ! int entchannel; int bufferId; float volume; float attenuation; ! float[] origin = {0,0,0}; // begin time in ms --- 36,66 ---- */ public class PlaySound { ! ! final static int MAX_PLAYSOUNDS = 128; ! ! // list with sentinel ! private static PlaySound freeList; ! private static PlaySound playableList; ! ! private static PlaySound[] backbuffer = new PlaySound[MAX_PLAYSOUNDS]; ! static { ! for (int i = 0; i < backbuffer.length; i++) { ! backbuffer[i] = new PlaySound(); } ! // init the sentinels ! freeList = new PlaySound(); ! playableList = new PlaySound(); ! // reset the lists ! reset(); ! } ! // sound attributes int type; ! int entnum; ! int entchannel; int bufferId; float volume; float attenuation; ! float[] origin = { 0, 0, 0 }; // begin time in ms *************** *** 74,80 **** this.clear(); } ! private void clear() { ! type = bufferId = entnum = entchannel = -1; // volume = attenuation = beginTime = 0; attenuation = beginTime = 0; --- 74,80 ---- this.clear(); } ! private void clear() { ! type = bufferId = entnum = entchannel = -1; // volume = attenuation = beginTime = 0; attenuation = beginTime = 0; *************** *** 86,96 **** freeList.next = freeList.prev = freeList; playableList.next = playableList.prev = playableList; ! // concat the the freeList PlaySound ps; ! for (int i = 0; i < backbuffer.length; i++) { ! ps = backbuffer[i]; ! ps.clear(); ! ps.prev = freeList; ps.next = freeList.next; ps.prev.next = ps; --- 86,96 ---- freeList.next = freeList.prev = freeList; playableList.next = playableList.prev = playableList; ! // concat the the freeList PlaySound ps; ! for (int i = 0; i < backbuffer.length; i++) { ! ps = backbuffer[i]; ! ps.clear(); ! ps.prev = freeList; ps.next = freeList.next; ps.prev.next = ps; *************** *** 98,102 **** } } ! static PlaySound nextPlayableSound() { PlaySound ps = null; --- 98,102 ---- } } ! static PlaySound nextPlayableSound() { PlaySound ps = null; *************** *** 109,118 **** } } ! private static PlaySound get() { PlaySound ps = freeList.next; if (ps == freeList) return null; ! ps.prev.next = ps.next; ps.next.prev = ps.prev; --- 109,118 ---- } } ! private static PlaySound get() { PlaySound ps = freeList.next; if (ps == freeList) return null; ! ps.prev.next = ps.next; ps.next.prev = ps.prev; *************** *** 121,128 **** private static void add(PlaySound ps) { ! PlaySound sort = playableList.next; ! ! for (; sort != playableList && sort.beginTime < ps.beginTime; sort = sort.next); ps.next = sort; ps.prev = sort.prev; --- 121,129 ---- private static void add(PlaySound ps) { ! PlaySound sort = playableList.next; ! ! for (; sort != playableList && sort.beginTime < ps.beginTime; sort = sort.next) ! ; ps.next = sort; ps.prev = sort.prev; *************** *** 140,144 **** freeList.next = ps; } ! static void allocate(float[] origin, int entnum, int entchannel, int bufferId, float volume, float attenuation, float timeoffset) { --- 141,145 ---- freeList.next = ps; } ! static void allocate(float[] origin, int entnum, int entchannel, int bufferId, float volume, float attenuation, float timeoffset) { *************** *** 161,165 **** ps.volume = volume; ps.attenuation = attenuation; ! ps.beginTime = Globals.cl.time + (long)(timeoffset * 1000); PlaySound.add(ps); } else { --- 162,166 ---- ps.volume = volume; ps.attenuation = attenuation; ! ps.beginTime = Globals.cl.time + (long) (timeoffset * 1000); PlaySound.add(ps); } else { |