summaryrefslogtreecommitdiff
blob: ad2accb830ef0c69bd16b367a868150443be7622 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
--- configure
+++ configure
@@ -158,8 +158,8 @@
 ## set up other config.mak variables
 ######################################################################
 GL_LIBS="-lglpng -lGL -lGLU -lm"
-AL_LIBS="-L../support/openal/lib -lopenal -ldl" 
-AL_CFLAGS="-I../support/openal/linux/include -I../support/openal/include"
+AL_LIBS="-lopenal -lalut" 
+AL_CFLAGS=""
 
 ## write out config.mak
 ######################################################################

--- scripts/Makefile.all
+++ scripts/Makefile.all
@@ -1,5 +1,4 @@
 SUPPORT_DIRS	=	 \
-			./support/openal/ \
 			./support/glpng/src
 
 CHROMIUM_DIRS	=	\

--- scripts/Makefile.no-setup
+++ scripts/Makefile.no-setup
@@ -1,5 +1,4 @@
 SUPPORT_DIRS	=	 \
-			./support/openal/ \
 			./support/glpng/src
 
 CHROMIUM_DIRS	=	\

--- src/AudioOpenAL.cpp
+++ src/AudioOpenAL.cpp
@@ -43,8 +43,7 @@
 	//try to use OpenAL alc[GS]etAudioChannel extensions in linux...
 	#ifdef __linux__ 
 		#define CD_VOLUME 1
-//		#include <AL/alext.h>
-		#include <AL/alkludgetypes.h>
+		#include <AL/alext.h>
 	#endif //__linux__
 #endif //USE_SDL
 #else
@@ -52,8 +51,7 @@
 	//try to use OpenAL alc[GS]etAudioChannel extensions in linux...
 	#ifdef __linux__ 
 		#define CD_VOLUME 1
-//		#include <AL/alext.h>
-		#include <AL/alexttypes.h>
+		#include <AL/alext.h>
 	#endif //__linux__
 #endif //USE_SDL
 #endif
@@ -124,6 +122,7 @@
 			audioScale[0] = 0.5;
 			audioScale[1] = 0.3;
 			audioScale[2] = 0.3;
+			alDistanceModel(AL_NONE);
 		}
 
 		if(config->swapStereo())
@@ -235,6 +234,7 @@
 	printExtensions(stderr,  (const char*)alGetString( AL_EXTENSIONS ));
 	fprintf(stderr, "------------------------------------------------------------\n");
 
+	alutInitWithoutContext(NULL, NULL);
 	checkForExtensions();
 	
 	alListenerfv(AL_POSITION, pos);
@@ -310,7 +310,7 @@
 				
 	//-- check AttenuationScale extension
 	alAttenuationScale = (void (*)(ALfloat param))
-						alGetProcAddress((ALubyte *)"alAttenuationScale_LOKI");
+						alGetProcAddress("alAttenuationScale_LOKI");
 	if(alAttenuationScale == NULL) 
 		fprintf(stderr, "ATTENTION!! Could not load alAttenuationScale\n");
 	else
@@ -318,9 +318,9 @@
 	
 	//-- check Audio Channel extension
 	alcGetAudioChannel = (float (*)(ALuint channel))
-						alGetProcAddress((const ALubyte *)"alcGetAudioChannel_LOKI");
+						alGetProcAddress("alcGetAudioChannel_LOKI");
 	alcSetAudioChannel = (void (*)(ALuint channel, ALfloat volume))
-						alGetProcAddress((const ALubyte *)"alcSetAudioChannel_LOKI");
+						alGetProcAddress("alcSetAudioChannel_LOKI");
 #ifdef CD_VOLUME
 	if(alcGetAudioChannel)
 		origCDvolume = alcGetAudioChannel(ALC_CHAN_CD_LOKI);
@@ -328,10 +328,10 @@
 	
 	//-- check MP3 extension
 	alutLoadMP3 = (ALboolean (*)(ALuint, ALvoid *, ALint))
-		alGetProcAddress((const ALubyte *)"alutLoadMP3_LOKI");
+		alGetProcAddress("alutLoadMP3_LOKI");
 	//-- check Ogg/Vorbis extension
 	alutLoadVorbis = (ALboolean (*)(ALuint, ALvoid *, ALint))
-		alGetProcAddress((const ALubyte *)"alutLoadVorbis_LOKI");
+		alGetProcAddress("alutLoadVorbis_LOKI");
 
 #endif //_WIN32
 }
@@ -468,9 +468,6 @@
 void AudioOpenAL::loadSounds()
 {
 	int i;
-	ALsizei size, freq, bits;
-	ALenum format;
-	ALvoid *data;
 
 	for(i = 0; i < NumSoundTypes; i++)
 	{
@@ -481,9 +478,7 @@
 		else
 		{
 #ifndef _WIN32
-			alutLoadWAV(dataLoc(fileNames[i]), &data, &format, &size, &bits, &freq);
-			alBufferData (buffer[i], format, data, size, freq);
-			free(data);
+			buffer[i] = alutCreateBufferFromFile(dataLoc(fileNames[i]));
 #else //_WIN32
 			char nameBuffer[256];
 			sprintf(nameBuffer, "%s", dataLoc(fileNames[i]));
@@ -842,17 +837,8 @@
 	fprintf(stderr, "         PlayList support not compiled into Chromium (AudioOpenAL.cpp)\n");
 	return false;
 #else //USE_PLAYLIST
-	bool retVal;
-	ALsizei size, freq, bits;
-	ALenum format;
-	ALvoid *data;
-	retVal = alutLoadWAV(filename, &data, &format, &size, &bits, &freq);
-	if(retVal)
-	{
-		alBufferData (buffer[MusicGame], format, data, size, freq);
-		free(data);	
-	}
-	return retVal;
+	buffer[MusicGame] =	alutCreateBufferFromFile(filename);
+	return true;
 #endif//USE_PLAYLIST
 }
 
--- src/AudioOpenAL.h
+++ src/AudioOpenAL.h
@@ -16,6 +16,7 @@
 #include <openal.h>
 #else //macintosh
 #include <AL/al.h>
+#include <AL/alc.h>
 #endif //macintosh
 
 /**
@@ -89,7 +90,7 @@
 	
 	float	origCDvolume;
 	
-	void	*context_id;
+	ALCcontext	*context_id;
 	bool	initialized;
 	float	audioScale[3];
 	
--- src-setup/Audio.cpp
+++ src-setup/Audio.cpp
@@ -56,7 +56,7 @@
 {
 	fprintf(stderr, "stopping OpenAL...");
 	if(initialized)
-		alcDestroyContext(context_id);
+		alutExit();
 	initialized = false;
 	fprintf(stderr, "done.\n");	
 }
@@ -71,8 +71,7 @@
 	if(!initialized)
 	{
 		fprintf(stderr, "starting OpenAL...");
-		context_id = alcCreateContext(NULL);
-		initialized = (bool)context_id;
+		initialized = alutInit(NULL, NULL);
 		fprintf(stderr, "done.\n");
 
 		if(initialized)
@@ -81,21 +80,21 @@
 
 #ifndef _WIN32
 			alAttenuationScale = (void (*)(ALfloat param))
-				alGetProcAddress((const ALubyte *)"alAttenuationScale_LOKI");
+				alGetProcAddress("alAttenuationScale_LOKI");
 			if(alAttenuationScale == NULL) 
 				fprintf(stderr, "alAttenuationScale NOT present\n");
 			else
 				alAttenuationScale(1.0);
 
 			alutLoadMP3 = (ALboolean (*)(ALuint, ALvoid *, ALint))
-				alGetProcAddress((const ALubyte *)"alutLoadMP3_LOKI");
+				alGetProcAddress("alutLoadMP3_LOKI");
 			if(alutLoadMP3)
 				fprintf(stderr, "alutLoadMP3_LOKI present\n");
 			else
 				fprintf(stderr, "alutLoadMP3_LOKI NOT present\n");
 
 			alutLoadVorbis = (ALboolean (*)(ALuint, ALvoid *, ALint))
-				alGetProcAddress((const ALubyte *)"alutLoadVorbis_LOKI");
+				alGetProcAddress("alutLoadVorbis_LOKI");
 			if(alutLoadVorbis)
 				fprintf(stderr, "alutLoadVorbis_LOKI present\n");
 			else
@@ -271,12 +270,8 @@
 //----------------------------------------------------------
 bool Audio::loadWAV(const char *filename)
 {
-	bool retVal = false;
 	if(initialized)
 	{
-		ALsizei size, freq, bits;
-		ALenum format;
-		ALvoid *data;
 		struct	stat sbuf;
 		
 		if(stat(filename, &sbuf) == -1) 
@@ -286,19 +281,16 @@
 			return false;
 		}
 		
-		retVal = alutLoadWAV(filename, &data, &format, &size, &bits, &freq);
-		if(retVal)
-		{
-			alBufferData (buffer[MusicGame], format, data, size, freq);
-			free(data);	
-		}
-		else
+		alGetError();
+		buffer[MusicGame] = alutCreateBufferFromFile(filename);
+		if (buffer[MusicGame] == AL_NONE)
 		{
-			sprintf(errorBuffer, "ERROR: alutLoadWAV failed for\n\"%s\"\nin Audio::loadWAV", filename);
+			sprintf(errorBuffer, "ERROR: failed to load\n\"%s\"\nin Audio::loadWAV", filename);
 			fprintf(stderr, "%s\n", errorBuffer);
+			return false;
 		}
 	}
-	return retVal;
+	return true;
 }
 
 //----------------------------------------------------------

--- src-setup/Audio.h
+++ src-setup/Audio.h
@@ -46,7 +46,6 @@
 	ALuint	buffer[NumSoundTypes];
 	ALuint	source[NumSoundTypes];
 	
-	void	*context_id;
 	bool	initialized;
 	
 	char errorBuffer[512];