-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Cleanup legacy browser support in libopenal.js. NFC #27435
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,6 +20,12 @@ var LibraryOpenAL = { | |
| QUEUE_INTERVAL: 25, | ||
| QUEUE_LOOKAHEAD: 100.0 / 1000.0, | ||
|
|
||
| #if MIN_SAFARI_VERSION < 140500 | ||
| AudioContext: globalThis.AudioContext ?? globalThis.webkitAudioContext, | ||
| #else | ||
| AudioContext: globalThis.AudioContext, | ||
| #endif | ||
|
|
||
| DEVICE_NAME: 'Emscripten OpenAL', | ||
| CAPTURE_DEVICE_NAME: 'Emscripten OpenAL capture', | ||
|
|
||
|
|
@@ -1650,7 +1656,11 @@ var LibraryOpenAL = { | |
| return 0; | ||
| } | ||
|
|
||
| var AudioContext = window.AudioContext || window.webkitAudioContext; | ||
| #if MIN_SAFARI_VERSION < 140500 | ||
| // We depend on the global AudioContext for modern browser, but | ||
| // old older safari versions we may still need to use webkitAudioContext. | ||
| var AudioContext = AL.AudioContext; | ||
| #endif | ||
|
|
||
| if (!AL.sharedCaptureAudioCtx) { | ||
| try { | ||
|
|
@@ -2048,7 +2058,7 @@ var LibraryOpenAL = { | |
| } | ||
| } | ||
|
|
||
| if (globalThis.AudioContext || globalThis.webkitAudioContext) { | ||
| if (AL.getAudioContext) { | ||
| var deviceId = AL.newId(); | ||
| AL.deviceRefCounts[deviceId] = 0; | ||
| return deviceId; | ||
|
|
@@ -2078,7 +2088,7 @@ var LibraryOpenAL = { | |
| return 0; | ||
| } | ||
|
|
||
| var options = null; | ||
| var options; | ||
| var attrs = []; | ||
| var hrtf = null; | ||
| pAttrList >>= 2; | ||
|
|
@@ -2143,15 +2153,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 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Which browser versions was this an issue for?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Its really hard to know for sure but some ancient version of However, since we already don't have this change in |
||
| if (options) { | ||
| ac = new AudioContext(options); | ||
| } else { | ||
| ac = new AudioContext(); | ||
| } | ||
| ac = new AudioContext(options); | ||
| } catch (e) { | ||
| if (e.name === 'NotSupportedError') { | ||
| #if OPENAL_DEBUG | ||
|
|
@@ -2382,14 +2390,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'; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MDN suggests 14.1, not 14.5?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think its 14.1 for Safari and maybe 14.5 for mobile safari? This is why we use 140500 elsewhere (e.g. libwebaudio.js).
AI seems to agree: Safari 14.1+ (Desktop) and iOS Safari 14.5+: Switched to standard window.AudioContext
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I verified 14.1/14.5 is on MDN.