updates licence and fix a memory leak (which was consuming iphone memory)
authorkoda
Sun, 12 Jul 2009 13:51:29 +0000
changeset 2257 7eb31efcfb9b
parent 2256 30797f3a4321
child 2258 3dd028604cfd
updates licence and fix a memory leak (which was consuming iphone memory)
hedgewars/uSound.pas
openalbridge/endianness.c
openalbridge/endianness.h
openalbridge/globals.h
openalbridge/loaders.c
openalbridge/loaders.h
openalbridge/oggvorbis.h
openalbridge/openalwrap.c
openalbridge/openalwrap.h
openalbridge/wrappers.c
openalbridge/wrappers.h
--- a/hedgewars/uSound.pas	Sun Jul 12 12:53:25 2009 +0000
+++ b/hedgewars/uSound.pas	Sun Jul 12 13:51:29 2009 +0000
@@ -59,7 +59,7 @@
 {*remember: LongInt = 32bit; integer = 16bit; byte = 8bit*}
 function openal_init		(memsize: LongInt)			: boolean; cdecl; external OpenALBridge;
 function openal_close							: boolean; cdecl; external OpenALBridge;
-function openal_loadfile	(filename: PChar)			: LongInt; cdecl; external OpenALBridge;
+function openal_loadfile	(const filename: PChar)			: LongInt; cdecl; external OpenALBridge;
 function openal_toggleloop	(index: LongInt)			: boolean; cdecl; external OpenALBridge;
 function openal_setvolume	(index: LongInt; percentage: byte)	: boolean; cdecl; external OpenALBridge;
 function openal_setglobalvolume	(percentage: byte)			: boolean; cdecl; external OpenALBridge;
--- a/openalbridge/endianness.c	Sun Jul 12 12:53:25 2009 +0000
+++ b/openalbridge/endianness.c	Sun Jul 12 13:51:29 2009 +0000
@@ -3,15 +3,15 @@
  * Copyright (c) 2009 Vittorio Giovara <vittorio.giovara@gmail.com>
  *
  * 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
+ * it under the terms of the GNU Lesser General Public License as published by
  * the Free Software Foundation; version 2 of the License
  *
  * 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.
+ * GNU Lesser General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License
+ * You should have received a copy of the GNU Lesser 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
  */
--- a/openalbridge/endianness.h	Sun Jul 12 12:53:25 2009 +0000
+++ b/openalbridge/endianness.h	Sun Jul 12 13:51:29 2009 +0000
@@ -3,15 +3,15 @@
  * Copyright (c) 2009 Vittorio Giovara <vittorio.giovara@gmail.com>
  *
  * 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
+ * it under the terms of the GNU Lesser General Public License as published by
  * the Free Software Foundation; version 2 of the License
  *
  * 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.
+ * GNU Lesser General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License
+ * You should have received a copy of the GNU Lesser 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
  */
--- a/openalbridge/globals.h	Sun Jul 12 12:53:25 2009 +0000
+++ b/openalbridge/globals.h	Sun Jul 12 13:51:29 2009 +0000
@@ -3,15 +3,15 @@
  * Copyright (c) 2009 Vittorio Giovara <vittorio.giovara@gmail.com>
  *
  * 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
+ * it under the terms of the GNU Lesser General Public License as published by
  * the Free Software Foundation; version 2 of the License
  *
  * 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.
+ * GNU Lesser General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License
+ * You should have received a copy of the GNU Lesser 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
  */
--- a/openalbridge/loaders.c	Sun Jul 12 12:53:25 2009 +0000
+++ b/openalbridge/loaders.c	Sun Jul 12 13:51:29 2009 +0000
@@ -3,15 +3,15 @@
  * Copyright (c) 2009 Vittorio Giovara <vittorio.giovara@gmail.com>
  *
  * 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
+ * it under the terms of the GNU Lesser General Public License as published by
  * the Free Software Foundation; version 2 of the License
  *
  * 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.
+ * GNU Lesser General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License
+ * You should have received a copy of the GNU Lesser 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
  */
@@ -22,7 +22,7 @@
 extern "C" {
 #endif 
 	
-	int load_WavPcm (const char *filename, ALenum *format, char ** data, ALsizei *bitsize, ALsizei *freq) {
+	int load_wavpcm (const char *filename, ALenum *format, char ** data, ALsizei *bitsize, ALsizei *freq) {
 		WAV_header_t WAVHeader;
 		FILE *wavfile;
 		int32_t t;
@@ -125,7 +125,8 @@
 		return AL_TRUE;
 	}
 	
-	int load_OggVorbis (const char *filename, ALenum *format, char **data, ALsizei *bitsize, ALsizei *freq) {
+    
+	int load_oggvorbis (const char *filename, ALenum *format, char **data, ALsizei *bitsize, ALsizei *freq) {
 		/*implementation inspired from http://www.devmaster.net/forums/showthread.php?t=1153 */
 		FILE			*oggFile;		/*ogg handle*/
 		OggVorbis_File  oggStream;		/*stream handle*/
@@ -139,11 +140,11 @@
 #endif
 		
 		oggFile = Fopen(filename, "rb");
-		result = ov_open(oggFile, &oggStream, NULL, 0);
-		/*TODO: check returning value of result*/
-		
+		result = ov_open(oggFile, &oggStream, NULL, 0);	/*TODO: check returning value of result*/
+                fclose(oggFile);
+            
 		vorbisInfo = ov_info(&oggStream, -1);
-		pcm_length = ov_pcm_total(&oggStream,-1) << vorbisInfo->channels;	
+		pcm_length = ov_pcm_total(&oggStream, -1) << vorbisInfo->channels;	
 		
 #ifdef DEBUG
 		vorbisComment = ov_comment(&oggStream, -1);
@@ -176,7 +177,7 @@
 			}
 		}
 		
-		while(size < pcm_length)	{
+		while(size < pcm_length) {
 			/*ov_read decodes the ogg stream and storse the pcm in data*/
 			result = ov_read (&oggStream, *data + size, pcm_length - size, 0, 2, 1, &section);
 			if(result > 0) {
@@ -193,7 +194,9 @@
 		
 		/*records the last fields*/
 		*bitsize = size;
-		*freq = vorbisInfo->rate;
+		*freq    = vorbisInfo->rate;
+            
+                ov_clear (&oggStream);
 		return AL_TRUE;
 	}
 	
--- a/openalbridge/loaders.h	Sun Jul 12 12:53:25 2009 +0000
+++ b/openalbridge/loaders.h	Sun Jul 12 13:51:29 2009 +0000
@@ -3,15 +3,15 @@
  * Copyright (c) 2009 Vittorio Giovara <vittorio.giovara@gmail.com>
  *
  * 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
+ * it under the terms of the GNU Lesser General Public License as published by
  * the Free Software Foundation; version 2 of the License
  *
  * 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.
+ * GNU Lesser General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License
+ * You should have received a copy of the GNU Lesser 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
  */
@@ -29,8 +29,8 @@
 extern "C" {
 #endif 
 		
-	int load_WavPcm		(const char *filename, ALenum *format, char **data, ALsizei *bitsize, ALsizei *freq);
-	int load_OggVorbis	(const char *filename, ALenum *format, char **data, ALsizei *bitsize, ALsizei *freq);
+	int load_wavpcm		(const char *filename, ALenum *format, char **data, ALsizei *bitsize, ALsizei *freq);
+	int load_oggvorbis	(const char *filename, ALenum *format, char **data, ALsizei *bitsize, ALsizei *freq);
 	
 #ifdef __CPLUSPLUS
 }
--- a/openalbridge/oggvorbis.h	Sun Jul 12 12:53:25 2009 +0000
+++ b/openalbridge/oggvorbis.h	Sun Jul 12 13:51:29 2009 +0000
@@ -212,5 +212,6 @@
 extern long ov_read(OggVorbis_File *vf,char *buffer,int length,int bigendianp,int word,int sgned,int *bitstream);
 extern vorbis_info *ov_info(OggVorbis_File *vf,int link);
 extern vorbis_comment *ov_comment(OggVorbis_File *f, int num);
+extern int ov_clear(OggVorbis_File *vf);
 
 #endif /*_OGGVORBIS_H*/
--- a/openalbridge/openalwrap.c	Sun Jul 12 12:53:25 2009 +0000
+++ b/openalbridge/openalwrap.c	Sun Jul 12 13:51:29 2009 +0000
@@ -3,15 +3,15 @@
  * Copyright (c) 2009 Vittorio Giovara <vittorio.giovara@gmail.com>
  *
  * 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
+ * it under the terms of the GNU Lesser General Public License as published by
  * the Free Software Foundation; version 2 of the License
  *
  * 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.
+ * GNU Lesser General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License
+ * You should have received a copy of the GNU Lesser 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
  */
@@ -32,10 +32,6 @@
 	ALuint *Buffers;
 	/*index for Sources and Buffers*/
 	ALuint globalindex, globalsize, increment;
-	/*Position of the source sound*/
-	ALfloat SourcePos[] = { 0.0, 0.0, 0.0 };
-	/*Velocity of the source sound*/
-	ALfloat SourceVel[] = { 0.0, 0.0, 0.0 };
 	
 	ALint openalReady = AL_FALSE;
 	
@@ -144,6 +140,8 @@
 	
 	int openal_loadfile (const char *filename){
 		/*Open a file, load into memory and allocate the Source buffer for playing*/
+                ALfloat SourcePos[] = { 0.0, 0.0, 0.0 }; /*Position of the source sound*/
+                ALfloat SourceVel[] = { 0.0, 0.0, 0.0 }; /*Velocity of the source sound*/
 		ALenum format;
 		ALsizei bitsize;
 		ALsizei freq;
@@ -188,10 +186,10 @@
 				
 		
 		if (fileformat == 0x5367674F) /*check if ogg*/
-			error = load_OggVorbis (filename, &format, &data, &bitsize, &freq);
+			error = load_oggvorbis (filename, &format, &data, &bitsize, &freq);
 		else {
 			if (fileformat == 0x46464952) /*check if wav*/
-				error = load_WavPcm (filename, &format, &data, &bitsize, &freq);
+				error = load_wavpcm (filename, &format, &data, &bitsize, &freq);
 			else {
 				fprintf(stderr, "ERROR: File format (%08X) not supported!\n", invert_endianness(fileformat));
 				return -5;
--- a/openalbridge/openalwrap.h	Sun Jul 12 12:53:25 2009 +0000
+++ b/openalbridge/openalwrap.h	Sun Jul 12 13:51:29 2009 +0000
@@ -3,15 +3,15 @@
  * Copyright (c) 2009 Vittorio Giovara <vittorio.giovara@gmail.com>
  *
  * 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
+ * it under the terms of the GNU Lesser General Public License as published by
  * the Free Software Foundation; version 2 of the License
  *
  * 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.
+ * GNU Lesser General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License
+ * You should have received a copy of the GNU Lesser 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
  */
--- a/openalbridge/wrappers.c	Sun Jul 12 12:53:25 2009 +0000
+++ b/openalbridge/wrappers.c	Sun Jul 12 13:51:29 2009 +0000
@@ -3,15 +3,15 @@
  * Copyright (c) 2009 Vittorio Giovara <vittorio.giovara@gmail.com>
  *
  * 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
+ * it under the terms of the GNU Lesser General Public License as published by
  * the Free Software Foundation; version 2 of the License
  *
  * 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.
+ * GNU Lesser General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License
+ * You should have received a copy of the GNU Lesser 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
  */
--- a/openalbridge/wrappers.h	Sun Jul 12 12:53:25 2009 +0000
+++ b/openalbridge/wrappers.h	Sun Jul 12 13:51:29 2009 +0000
@@ -3,15 +3,15 @@
  * Copyright (c) 2009 Vittorio Giovara <vittorio.giovara@gmail.com>
  *
  * 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
+ * it under the terms of the GNU Lesser General Public License as published by
  * the Free Software Foundation; version 2 of the License
  *
  * 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.
+ * GNU Lesser General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License
+ * You should have received a copy of the GNU Lesser 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
  */