//"use strict";
var LibraryOpenAL = {
$AL__deps: ['$Browser'],
$AL: {
contexts: [],
currentContext: null,
stringCache: {},
alcStringCache: {},
QUEUE_INTERVAL: 25,
QUEUE_LOOKAHEAD: 100,
updateSources: function updateSources(context) {
for (var i = 0; i < context.src.length; i++) {
AL.updateSource(context.src[i]);
}
},
updateSource: function updateSource(src) {
#if OPENAL_DEBUG
var idx = AL.currentContext.src.indexOf(src);
#endif
if (src.state !== 0x1012 /* AL_PLAYING */) {
return;
}
var currentTime = AL.currentContext.ctx.currentTime;
var startTime = src.bufferPosition;
for (var i = src.buffersPlayed; i < src.queue.length; i++) {
var entry = src.queue[i];
var startOffset = startTime - currentTime;
var endTime = startTime + entry.buffer.duration;
// Clean up old buffers.
if (currentTime >= endTime) {
// Update our location in the queue.
src.bufferPosition = endTime;
src.buffersPlayed = i + 1;
// Stop / restart the source when we hit the end.
if (src.buffersPlayed >= src.queue.length) {
if (src.loop) {
AL.setSourceState(src, 0x1012 /* AL_PLAYING */);
} else {
AL.setSourceState(src, 0x1014 /* AL_STOPPED */);
}
}
}
// Process all buffers that'll be played before the next tick.
else if (startOffset < (AL.QUEUE_LOOKAHEAD /