summaryrefslogtreecommitdiff
path: root/ext/mixed/js/audio-system.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-04-10 16:38:53 -0400
committertoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-04-18 14:23:34 -0400
commit7eb7c88394ebb56936861b91e6b04525abb57490 (patch)
tree1bf7216c4947d26fa1489ab104ffc2c14bb31dee /ext/mixed/js/audio-system.js
parentf50aee1021179411322f67c5951eb35de81c5174 (diff)
Return index of the source instead of the source value
Diffstat (limited to 'ext/mixed/js/audio-system.js')
-rw-r--r--ext/mixed/js/audio-system.js10
1 files changed, 6 insertions, 4 deletions
diff --git a/ext/mixed/js/audio-system.js b/ext/mixed/js/audio-system.js
index 0ded3490..94885d34 100644
--- a/ext/mixed/js/audio-system.js
+++ b/ext/mixed/js/audio-system.js
@@ -85,13 +85,15 @@ class AudioSystem {
const cacheValue = this._cache.get(key);
if (typeof cacheValue !== 'undefined') {
const {audio, uri, source} = cacheValue;
- if (sources.includes(source)) {
- return {audio, uri, source};
+ const index = sources.indexOf(source);
+ if (index >= 0) {
+ return {audio, uri, index};
}
}
}
- for (const source of sources) {
+ for (let i = 0, ii = sources.length; i < ii; ++i) {
+ const source = sources[i];
const uri = await this._getAudioUri(definition, source, details);
if (uri === null) { continue; }
@@ -101,7 +103,7 @@ class AudioSystem {
this._cacheCheck();
this._cache.set(key, {audio, uri, source});
}
- return {audio, uri, source};
+ return {audio, uri, index: i};
} catch (e) {
// NOP
}