浏览代码

Replced deprecated alutLoadWAVFile().

Thomas Buck 10 年前
父节点
当前提交
a02ade6a6a
共有 2 个文件被更改,包括 11 次插入12 次删除
  1. 3
    2
      deps.sh
  2. 8
    10
      src/Sound.cpp

+ 3
- 2
deps.sh 查看文件

1
 # Mongoose - This is a simple dep line generator
1
 # Mongoose - This is a simple dep line generator
2
+# modified by xythobuz
2
 #
3
 #
3
 # Call it passing CFLAGS and a source filename
4
 # Call it passing CFLAGS and a source filename
4
 # to generate a dep line
5
 # to generate a dep line
5
 
6
 
6
-cc -MM $@ > /dev/null
7
+cc -MM -w $@
7
 OUT=$?
8
 OUT=$?
8
 if [ $OUT -eq 0 ];then
9
 if [ $OUT -eq 0 ];then
9
     printf "\$(BUILDDIR)/"
10
     printf "\$(BUILDDIR)/"
10
-    cc -MM $@
11
+    cc -MM -w $@
11
     printf "\t \$(DO_CC)\n\n"
12
     printf "\t \$(DO_CC)\n\n"
12
 fi
13
 fi

+ 8
- 10
src/Sound.cpp 查看文件

24
 #include <OpenAL/al.h>
24
 #include <OpenAL/al.h>
25
 #include <OpenAL/alc.h>
25
 #include <OpenAL/alc.h>
26
 #include <AL/alut.h>
26
 #include <AL/alut.h>
27
-// Another dirty hack to get to use OpenAL and FreeALUT on Mac OS X
28
-#define AL_FORMAT_WAVE_EXT 0x10002
29
 #else
27
 #else
30
 #   include <AL/al.h>
28
 #   include <AL/al.h>
31
 #   include <AL/alc.h>
29
 #   include <AL/alc.h>
127
 int Sound::add(char *filename, int *source, unsigned int flags)
125
 int Sound::add(char *filename, int *source, unsigned int flags)
128
 {
126
 {
129
 #ifdef HAVE_OPENAL
127
 #ifdef HAVE_OPENAL
130
-   ALsizei size, freq;
128
+   ALsizei size;
129
+   ALfloat freq;
131
    ALenum format;
130
    ALenum format;
132
    ALvoid *data;
131
    ALvoid *data;
133
-   ALboolean err;
134
 #endif
132
 #endif
135
 
133
 
136
 
134
 
164
 	}
162
 	}
165
 
163
 
166
    // err = alutLoadWAV(filename, &data, &format, &size, &bits, &freq);
164
    // err = alutLoadWAV(filename, &data, &format, &size, &bits, &freq);
167
-   // DEPRECATED?! Dirty solution:
168
-   alutLoadWAVFile(filename, &format, &data, &size, &freq);
169
-   err = AL_TRUE;
165
+   // is deprecated!
166
+   data = alutLoadMemoryFromFile(filename, &format, &size, &freq);
170
 
167
 
171
-   if (err == AL_FALSE)
168
+   if (alGetError() != AL_NO_ERROR)
172
 	{
169
 	{
173
 	   fprintf(stderr, "Could not load %s\n", filename);
170
 	   fprintf(stderr, "Could not load %s\n", filename);
174
 	   return -3;
171
 	   return -3;
233
 		return -2;
230
 		return -2;
234
 	}
231
 	}
235
 
232
 
236
-	// AL_FORMAT_WAVE_EXT
237
-   alBufferData(mBuffer[mNextBuffer], AL_FORMAT_WAVE_EXT, data, size, freq);
233
+#warning "AL_FORMAT_WAVE_EXT does not exist on Mac!"
234
+   // alBufferData(mBuffer[mNextBuffer], AL_FORMAT_WAVE_EXT, data, size, freq);
235
+   alBufferData(mBuffer[mNextBuffer], 0x10002, data, size, freq);
238
 
236
 
239
    alSourcei(mSource[mNextSource], AL_BUFFER, mBuffer[mNextBuffer]);
237
    alSourcei(mSource[mNextSource], AL_BUFFER, mBuffer[mNextBuffer]);
240
 
238
 

正在加载...
取消
保存