Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 21 additions & 13 deletions src/lib/libopenal.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ var LibraryOpenAL = {
QUEUE_INTERVAL: 25,
QUEUE_LOOKAHEAD: 100.0 / 1000.0,

#if MIN_SAFARI_VERSION < 140500
Comment thread
sbc100 marked this conversation as resolved.
AudioContext: globalThis.AudioContext ?? globalThis.webkitAudioContext,
#else
AudioContext: globalThis.AudioContext,
#endif

DEVICE_NAME: 'Emscripten OpenAL',
CAPTURE_DEVICE_NAME: 'Emscripten OpenAL capture',

Expand Down Expand Up @@ -1649,7 +1655,11 @@ var LibraryOpenAL = {
return 0;
}

var AudioContext = window.AudioContext || window.webkitAudioContext;
#if MIN_SAFARI_VERSION < 140500
// We depend on the global AudioContext for modern browsers, but
// old older safari versions we may still need to use webkitAudioContext.
var AudioContext = AL.AudioContext;
#endif

if (!AL.sharedCaptureAudioCtx) {
try {
Expand Down Expand Up @@ -2047,7 +2057,7 @@ var LibraryOpenAL = {
}
}

if (globalThis.AudioContext || globalThis.webkitAudioContext) {
if (AL.AudioContext) {
var deviceId = AL.newId();
AL.deviceRefCounts[deviceId] = 0;
return deviceId;
Expand Down Expand Up @@ -2077,7 +2087,7 @@ var LibraryOpenAL = {
return 0;
}

var options = null;
var options;
var attrs = [];
var hrtf = null;
pAttrList >>= 2;
Expand Down Expand Up @@ -2142,15 +2152,13 @@ var LibraryOpenAL = {
}
}

var AudioContext = window.AudioContext || window.webkitAudioContext;
var ac = null;
#if MIN_SAFARI_VERSION < 140500
var AudioContext = window.AudioContext ?? window.webkitAudioContext;
#endif

var ac;
try {
// Only try to pass options if there are any, for compat with browsers that don't support this
Comment thread
sbc100 marked this conversation as resolved.
if (options) {
ac = new AudioContext(options);
} else {
ac = new AudioContext();
}
ac = new AudioContext(options);
} catch (e) {
if (e.name === 'NotSupportedError') {
#if OPENAL_DEBUG
Expand Down Expand Up @@ -2372,14 +2380,14 @@ var LibraryOpenAL = {
ret = 'Out of Memory';
break;
case 0x1004 /* ALC_DEFAULT_DEVICE_SPECIFIER */:
if (globalThis.AudioContext || globalThis.webkitAudioContext) {
if (AL.AudioContext) {
ret = AL.DEVICE_NAME;
} else {
return 0;
}
break;
case 0x1005 /* ALC_DEVICE_SPECIFIER */:
if (globalThis.AudioContext || globalThis.webkitAudioContext) {
if (AL.AudioContext) {
ret = AL.DEVICE_NAME + '\0';
} else {
ret = '\0';
Expand Down
4 changes: 2 additions & 2 deletions test/codesize/test_codesize_hello_dylink_all.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"a.out.js": 267933,
"a.out.js": 267629,
"a.out.nodebug.wasm": 588309,
"total": 856242,
"total": 855938,
"sent": [
"IMG_Init",
"IMG_Load",
Expand Down
Loading