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 {
var parentObj = this;
var lazyEnableWA = function () {
var XAudioJSWebAudioDelayedEvent = 0;
this.userEventLatch.addEventListener("click", function () {
if (XAudioJSWebAudioDelayedEvent == 0) {
parentObj.setupWebAudio();
XAudioJSWebAudioDelayedEvent |= 1;
}
try {
this.userEventLatch.addEventListener("click", lazyEnableWA, false);
this.userEventLatch.addEventListener("touchstart", lazyEnableWA, false);
this.userEventLatch.addEventListener("touchend", lazyEnableWA, false);
}, false);
this.userEventLatch.addEventListener("touchstart", function () {
if (XAudioJSWebAudioDelayedEvent < 2) {
parentObj.setupWebAudio();
XAudioJSWebAudioDelayedEvent |= 2;
}
catch (e) {}
}, 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
//the samples in buffer before user driven event callback that actually starts WA.
this.resetCallbackAPIAudioBuffer(44100);