Update XAudioServer.js

This commit is contained in:
jsemu 2019-04-27 03:50:29 -04:00
parent 6c15b6a834
commit b6c6d29c84

View file

@ -174,15 +174,25 @@ XAudioServer.prototype.initializeWebAudio = function () {
} }
else { else {
var parentObj = this; var parentObj = this;
var lazyEnableWA = function () { var XAudioJSWebAudioDelayedEvent = 0;
parentObj.setupWebAudio(); this.userEventLatch.addEventListener("click", function () {
} if (XAudioJSWebAudioDelayedEvent == 0) {
try { parentObj.setupWebAudio();
this.userEventLatch.addEventListener("click", lazyEnableWA, false); XAudioJSWebAudioDelayedEvent |= 1;
this.userEventLatch.addEventListener("touchstart", lazyEnableWA, false); }
this.userEventLatch.addEventListener("touchend", lazyEnableWA, false); }, false);
} this.userEventLatch.addEventListener("touchstart", function () {
catch (e) {} if (XAudioJSWebAudioDelayedEvent < 2) {
parentObj.setupWebAudio();
XAudioJSWebAudioDelayedEvent |= 2;
}
}, false);
this.userEventLatch.addEventListener("touchend", function () {
if (XAudioJSWebAudioDelayedEvent < 4) {
parentObj.setupWebAudio();
XAudioJSWebAudioDelayedEvent |= 4;
}
}, false);
//TODO: Restructure API to not have to potentially lie to end client about //TODO: Restructure API to not have to potentially lie to end client about
//the samples in buffer before user driven event callback that actually starts WA. //the samples in buffer before user driven event callback that actually starts WA.
this.resetCallbackAPIAudioBuffer(44100); this.resetCallbackAPIAudioBuffer(44100);