Skip to content
Open
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
8 changes: 8 additions & 0 deletions src/lib/libwebaudio.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,12 @@ var LibraryWebAudio = {
// this avoids the user needing to manually add the dependency on the command line.
emscripten_create_audio_context__deps: ['$emscriptenRegisterAudioObject', '$emscriptenGetAudioObject'],
emscripten_create_audio_context: (options) => {
// Safari added unprefixed AudioContext support in Safari 14.5 on iOS: https://caniuse.com/audio-api
#if MIN_SAFARI_VERSION < 140500 || ENVIRONMENT_MAY_BE_NODE || ENVIRONMENT_MAY_BE_SHELL
var ctx = window.AudioContext || window.webkitAudioContext;
#if ASSERTIONS
if (!ctx) console.error('emscripten_create_audio_context failed! Web Audio is not supported.');
#endif
#endif

var opts = options ? {
Expand All @@ -69,7 +72,12 @@ var LibraryWebAudio = {
console.dir(opts);
#endif

#if MIN_SAFARI_VERSION < 140500 || ENVIRONMENT_MAY_BE_NODE || ENVIRONMENT_MAY_BE_SHELL
return ctx && emscriptenRegisterAudioObject(new ctx(opts));
#else
// We are targeting an environment where we assume that AudioContext() API unconditionally exists.
return emscriptenRegisterAudioObject(new AudioContext(opts));
#endif
},

emscripten_resume_audio_context_async: (contextHandle, callback, userData) => {
Expand Down
Loading