regression of previous commit, stdint.h in use
authorkoda
Tue, 30 Jun 2009 15:59:02 +0000
changeset 2215 1d78579e06c2
parent 2214 eacb5b19d587
child 2216 82e7da49c26a
regression of previous commit, stdint.h in use
openalbridge/globals.h
openalbridge/loaders.c
openalbridge/openalwrap.c
openalbridge/openalwrap.h
--- a/openalbridge/globals.h	Tue Jun 30 14:59:25 2009 +0000
+++ b/openalbridge/globals.h	Tue Jun 30 15:59:02 2009 +0000
@@ -21,6 +21,7 @@
 
 #include <stdio.h>
 #include <stdlib.h>
+#include <stdint.h>
 
 #ifndef _WIN32
 #include <pthread.h>
@@ -76,19 +77,19 @@
 	/*data type for WAV header*/
 #pragma pack(1)
 	typedef struct _WAV_header_t {
-		int ChunkID;
-		int ChunkSize;
-		int Format;
-		int Subchunk1ID;
-		int Subchunk1Size;
-		short int AudioFormat;
-		short int NumChannels;
-		int SampleRate;
-		int ByteRate;
-		short int BlockAlign;
-		short int BitsPerSample;
-		int Subchunk2ID;
-		int Subchunk2Size;
+		uint32_t ChunkID;
+		uint32_t ChunkSize;
+		uint32_t Format;
+		uint32_t Subchunk1ID;
+		uint32_t Subchunk1Size;
+		uint16_t AudioFormat;
+		uint16_t NumChannels;
+		uint32_t SampleRate;
+		uint32_t ByteRate;
+		uint16_t BlockAlign;
+		uint16_t BitsPerSample;
+		uint32_t Subchunk2ID;
+		uint32_t Subchunk2Size;
 	} WAV_header_t;
 #pragma pack()
 	
--- a/openalbridge/loaders.c	Tue Jun 30 14:59:25 2009 +0000
+++ b/openalbridge/loaders.c	Tue Jun 30 15:59:02 2009 +0000
@@ -29,9 +29,9 @@
 		
 		wavfile = Fopen(filename, "rb");
 		
-		fread(&WAVHeader.ChunkID, sizeof(int), 1, wavfile);
-		fread(&WAVHeader.ChunkSize, sizeof(int), 1, wavfile);
-		fread(&WAVHeader.Format, sizeof(int), 1, wavfile);
+		fread(&WAVHeader.ChunkID, sizeof(uint32_t), 1, wavfile);
+		fread(&WAVHeader.ChunkSize, sizeof(uint32_t), 1, wavfile);
+		fread(&WAVHeader.Format, sizeof(uint32_t), 1, wavfile);
 		
 #ifdef DEBUG
 		fprintf(stderr, "ChunkID: %X\n", invert_endianness(WAVHeader.ChunkID));
@@ -39,14 +39,14 @@
 		fprintf(stderr, "Format: %X\n", invert_endianness(WAVHeader.Format));
 #endif
 		
-		fread(&WAVHeader.Subchunk1ID, sizeof(int), 1, wavfile);
-		fread(&WAVHeader.Subchunk1Size, sizeof(int), 1, wavfile);
-		fread(&WAVHeader.AudioFormat, sizeof(short int), 1, wavfile);
-		fread(&WAVHeader.NumChannels, sizeof(short int), 1, wavfile);
-		fread(&WAVHeader.SampleRate, sizeof(int), 1, wavfile);
-		fread(&WAVHeader.ByteRate, sizeof(int), 1, wavfile);
-		fread(&WAVHeader.BlockAlign, sizeof(short int), 1, wavfile);
-		fread(&WAVHeader.BitsPerSample, sizeof(short int), 1, wavfile);
+		fread(&WAVHeader.Subchunk1ID, sizeof(uint32_t), 1, wavfile);
+		fread(&WAVHeader.Subchunk1Size, sizeof(uint32_t), 1, wavfile);
+		fread(&WAVHeader.AudioFormat, sizeof(uint16_t), 1, wavfile);
+		fread(&WAVHeader.NumChannels, sizeof(uint16_t), 1, wavfile);
+		fread(&WAVHeader.SampleRate, sizeof(uint32_t), 1, wavfile);
+		fread(&WAVHeader.ByteRate, sizeof(uint32_t), 1, wavfile);
+		fread(&WAVHeader.BlockAlign, sizeof(uint16_t), 1, wavfile);
+		fread(&WAVHeader.BitsPerSample, sizeof(uint16_t), 1, wavfile);
 		
 #ifdef DEBUG
 		fprintf(stderr, "Subchunk1ID: %X\n", invert_endianness(WAVHeader.Subchunk1ID));
@@ -60,7 +60,7 @@
 #endif
 		
 		do { /*remove useless header chunks (plenty room for improvements)*/
-			t = fread(&WAVHeader.Subchunk2ID, sizeof(int), 1, wavfile);
+			t = fread(&WAVHeader.Subchunk2ID, sizeof(uint32_t), 1, wavfile);
 			if (invert_endianness(WAVHeader.Subchunk2ID) == 0x64617461)
 				break;
 			if (t <= 0) { /*eof*/
@@ -68,7 +68,7 @@
 				return AL_FALSE;
 			}
 		} while (1);
-		fread(&WAVHeader.Subchunk2Size, sizeof(int), 1, wavfile);
+		fread(&WAVHeader.Subchunk2Size, sizeof(uint32_t), 1, wavfile);
 		
 #ifdef DEBUG
 		fprintf(stderr, "Subchunk2ID: %X\n", invert_endianness(WAVHeader.Subchunk2ID));
@@ -79,7 +79,7 @@
 		
 		/*this could be improved*/
 		do {
-			n += fread(&((*data)[n]), sizeof(char), 1, wavfile);
+			n += fread(&((*data)[n]), sizeof(uint8_t), 1, wavfile);
 		} while (n < WAVHeader.Subchunk2Size);
 		
 		fclose(wavfile);	
--- a/openalbridge/openalwrap.c	Tue Jun 30 14:59:25 2009 +0000
+++ b/openalbridge/openalwrap.c	Tue Jun 30 15:59:02 2009 +0000
@@ -60,7 +60,7 @@
 	}
 	
 	
-	ALint openal_init(int memorysize) {	
+	ALint openal_init(uint32_t memorysize) {	
 		/*Initialize an OpenAL contex and allocate memory space for data and buffers*/
 		ALCcontext *context;
 		ALCdevice *device;
@@ -108,7 +108,7 @@
 	}
 	
 	
-	int helper_realloc (void) {
+	uint8_t helper_realloc (void) {
 		/*expands allocated memory when loading more sound files than expected*/
 		globalsize += increment;
 #ifdef DEBUG
@@ -121,14 +121,14 @@
 	}
 	
 	
-	int openal_loadfile (const char *filename){
+	uint32_t openal_loadfile (const char *filename){
 		/*Open a file, load into memory and allocate the Source buffer for playing*/
 		ALenum format;
 		ALsizei bitsize;
 		ALsizei freq;
 		char *data;
 		uint32_t fileformat;
-		int error;
+		ALenum error;
 		FILE *fp;
 		
 		
@@ -197,7 +197,7 @@
 	}
 	
 	
-	ALint openal_toggleloop (int index){
+	ALint openal_toggleloop (uint32_t index){
 		/*Set or unset looping mode*/
 		ALint loop;
 		
@@ -217,7 +217,7 @@
 	}
 	
 	
-	ALint openal_setvolume (int index, unsigned char percentage) {
+	ALint openal_setvolume (uint32_t index, uint8_t percentage) {
 		/*Set volume for sound number index*/
 		if (index >= globalindex) {
 			fprintf(stderr, "ERROR: index out of bounds (got %d, max %d)\n", index, globalindex);
@@ -236,7 +236,7 @@
 	}
 	
 	
-	ALint openal_setglobalvolume (unsigned char percentage) {
+	ALint openal_setglobalvolume (uint8_t percentage) {
 		/*Set volume for all sounds*/		
 		if (percentage > 100)
 			percentage = 100;
@@ -269,7 +269,7 @@
 	}
 	
 	
-	ALint openal_fade(int index, unsigned int quantity, char direction) {
+	ALint openal_fade(uint32_t index, uint16_t quantity, uint8_t direction) {
 		/*Fade in or out by calling a helper thread*/
 #ifndef _WIN32
 		pthread_t thread;
@@ -318,19 +318,19 @@
 	}
 
 	
-	ALint openal_fadeout(int index, unsigned int quantity) {
+	ALint openal_fadeout(uint32_t index, uint16_t quantity) {
 		/*wrapper for fadeout*/
 		return openal_fade(index, quantity, FADE_OUT);
 	}
 		
 		
-	ALint openal_fadein(int index, unsigned int quantity) {
+	ALint openal_fadein(uint32_t index, uint16_t quantity) {
 		/*wrapper for fadein*/
 		return openal_fade(index, quantity, FADE_IN);
 	}
 
 	
-	ALint openal_playsound(int index){
+	ALint openal_playsound(uint32_t index){
 		/*Play sound number index*/
 		if (index >= globalindex) {
 			fprintf(stderr, "ERROR: index out of bounds (got %d, max %d)\n", index, globalindex);
@@ -346,7 +346,7 @@
 	}
 	
 	
-	ALint openal_pausesound(int index){
+	ALint openal_pausesound(uint32_t index){
 		/*Pause sound number index*/
 		if (index >= globalindex) {
 			fprintf(stderr, "ERROR: index out of bounds (got %d, max %d)\n", index, globalindex);
@@ -360,7 +360,7 @@
 	}
 	
 	
-	ALint openal_stopsound(int index){
+	ALint openal_stopsound(uint32_t index){
 		/*Stop sound number index*/
 		if (index >= globalindex) {
 			fprintf(stderr, "ERROR: index out of bounds (got %d, max %d)\n", index, globalindex);
--- a/openalbridge/openalwrap.h	Tue Jun 30 14:59:25 2009 +0000
+++ b/openalbridge/openalwrap.h	Tue Jun 30 15:59:02 2009 +0000
@@ -24,19 +24,19 @@
 extern "C" {
 #endif 
 		
-	int openal_init				(int memorysize);
+	int openal_init				(unsigned int memorysize);
 	int openal_close			(void);
 	int openal_loadfile			(const char *filename);
-	int openal_toggleloop		(int index);
-	int openal_setvolume		(int index, unsigned char percentage);
+	int openal_toggleloop		(unsigned int index);
+	int openal_setvolume		(unsigned int index, unsigned char percentage);
 	int openal_setglobalvolume	(unsigned char percentage);
 	int openal_togglemute		(void);
-	int openal_fadeout			(int index, unsigned int quantity);
-	int openal_fadein			(int index, unsigned int quantity);
-	int openal_fade				(int index, unsigned int quantity, char direction);
-	int openal_playsound		(int index);	
-	int openal_pausesound		(int index);
-	int openal_stopsound		(int index);
+	int openal_fadeout			(unsigned int index, unsigned short int quantity);
+	int openal_fadein			(unsigned int index, unsigned short int quantity);
+	int openal_fade				(unsigned int index, unsigned short int quantity, unsigned char direction);
+	int openal_playsound		(unsigned int index);	
+	int openal_pausesound		(unsigned int index);
+	int openal_stopsound		(unsigned int index);
 	
 #ifdef __CPLUSPLUS
 }