瀏覽代碼

Sound working with cmake

Thomas Buck 11 年之前
父節點
當前提交
842a2d2007
共有 1 個檔案被更改,包括 14 行新增4 行删除
  1. 14
    4
      src/Sound.cpp

+ 14
- 4
src/Sound.cpp 查看文件

60
     close(fd);
60
     close(fd);
61
 #endif
61
 #endif
62
 
62
 
63
-    alutInit(NULL, 0);
63
+    ALCdevice *Device = alcOpenDevice("OSS");
64
+    ALCcontext *Context = alcCreateContext(Device, NULL);
65
+    alcMakeContextCurrent(Context);
66
+
67
+    if (alutInitWithoutContext(NULL, NULL) == AL_FALSE) {
68
+        printf("Sound::Init> Could not initialize alut (%s)\n", alutGetErrorString(alutGetError()));
69
+        return -2;
70
+    }
64
 
71
 
65
     mInit = true;
72
     mInit = true;
66
     printf("Created OpenAL Context\n");
73
     printf("Created OpenAL Context\n");
129
     // is deprecated!
136
     // is deprecated!
130
     data = alutLoadMemoryFromFile(filename, &format, &size, &freq);
137
     data = alutLoadMemoryFromFile(filename, &format, &size, &freq);
131
 
138
 
132
-    if (alGetError() != AL_NO_ERROR)
139
+    if (alutGetError() != ALUT_ERROR_NO_ERROR)
133
     {
140
     {
134
         fprintf(stderr, "Could not load %s\n", filename);
141
         fprintf(stderr, "Could not load %s\n", filename);
135
         return -3;
142
         return -3;
158
     ALfloat freq;
165
     ALfloat freq;
159
     ALenum format;
166
     ALenum format;
160
     ALvoid *data;
167
     ALvoid *data;
168
+    int error = 0;
161
 
169
 
162
     if (!mInit || !wav || !source)
170
     if (!mInit || !wav || !source)
163
     {
171
     {
197
 
205
 
198
     data = alutLoadMemoryFromFileImage(wav, length, &format, &size, &freq);
206
     data = alutLoadMemoryFromFileImage(wav, length, &format, &size, &freq);
199
 
207
 
200
-    if ((alGetError() != AL_NO_ERROR) || (data == NULL)) {
201
-        fprintf(stderr, "Could not load wav buffer\n");
208
+    if (((error = alutGetError()) != ALUT_ERROR_NO_ERROR) || (data == NULL)) {
209
+        fprintf(stderr, "Could not load wav buffer (%s)\n", alutGetErrorString(error));
202
         return -3;
210
         return -3;
203
     }
211
     }
204
 
212
 
217
 
225
 
218
     *source = mNextBuffer;
226
     *source = mNextBuffer;
219
 
227
 
228
+    //! \fixme Should free alut buffer?
229
+
220
     return 0;
230
     return 0;
221
 }
231
 }
222
 
232
 

Loading…
取消
儲存