Skip to content

Commit 6e1c28e

Browse files
authored
Fix return code from alcMakeContextCurrent (#17591)
Fixes: #11708
1 parent 1092b06 commit 6e1c28e

File tree

3 files changed

+12
-16
lines changed

3 files changed

+12
-16
lines changed

src/library_openal.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2298,10 +2298,10 @@ var LibraryOpenAL = {
22982298
alcMakeContextCurrent: function(contextId) {
22992299
if (contextId === 0) {
23002300
AL.currentCtx = null;
2301-
return 0;
2301+
} else {
2302+
AL.currentCtx = AL.contexts[contextId];
23022303
}
2303-
AL.currentCtx = AL.contexts[contextId];
2304-
return 1;
2304+
return 1 /* ALC_TRUE */;
23052305
},
23062306

23072307
alcGetContextsDevice__proxy: 'sync',

test/openal_error.c

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,15 @@
88
#include <stdio.h>
99
#include <stdlib.h>
1010
#include <assert.h>
11-
#ifdef __EMSCRIPTEN__
12-
#include <emscripten.h>
1311
#include <AL/al.h>
1412
#include <AL/alc.h>
15-
#else
16-
#include "../system/include/AL/al.h"
17-
#include "../system/include/AL/alc.h"
18-
#endif
1913

2014
ALCdevice* device = NULL;
2115
ALCcontext* context = NULL;
2216

2317
int main(int argc, char* argv[]) {
18+
ALCboolean ret;
19+
2420
//
2521
// Setup the AL context.
2622
//
@@ -34,20 +30,20 @@ int main(int argc, char* argv[]) {
3430
assert(alcGetError(device) == ALC_NO_ERROR);
3531

3632
context = alcCreateContext(device, NULL);
37-
alcMakeContextCurrent(context);
33+
ret = alcMakeContextCurrent(context);
34+
assert(ret == ALC_TRUE);
3835

3936
// Request an invalid enum to generate an AL error
4037
alGetFloat(0);
4138
assert(alGetError() == AL_INVALID_ENUM);
4239
// Check that the error is reset after reading it.
4340
assert(alGetError() == AL_NO_ERROR);
4441

45-
alcMakeContextCurrent(NULL);
42+
ret = alcMakeContextCurrent(NULL);
43+
assert(ret == ALC_TRUE);
44+
4645
alcDestroyContext(context);
4746
alcCloseDevice(device);
48-
49-
#ifdef __EMSCRIPTEN__
50-
REPORT_RESULT(1);
51-
#endif
47+
return 0;
5248
}
5349

test/test_browser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2256,7 +2256,7 @@ def test_openal_error(self):
22562256
['--closure=1']
22572257
]:
22582258
print(args)
2259-
self.btest('openal_error.c', expected='1', args=args)
2259+
self.btest_exit('openal_error.c', args=args)
22602260

22612261
def test_openal_capture_sanity(self):
22622262
self.btest('openal_capture_sanity.c', expected='0')

0 commit comments

Comments
 (0)