aboutsummaryrefslogtreecommitdiff
path: root/src/library_openal.js
diff options
context:
space:
mode:
authorEhsan Akhgari <ehsan.akhgari@gmail.com>2013-03-14 19:41:04 -0400
committerAlon Zakai <alonzakai@gmail.com>2013-03-15 11:53:16 -0700
commitbe5bc3b617c7cca563f3b1cfe4ab3a5083318e67 (patch)
tree769c34b18f1421b6487bce991c3c871e2ccebb53 /src/library_openal.js
parent00a39d2658d7c473274d15ff4bd159f018a78d38 (diff)
Implement alGetSourcei
Diffstat (limited to 'src/library_openal.js')
-rw-r--r--src/library_openal.js55
1 files changed, 54 insertions, 1 deletions
diff --git a/src/library_openal.js b/src/library_openal.js
index e6400a29..2166a712 100644
--- a/src/library_openal.js
+++ b/src/library_openal.js
@@ -92,7 +92,7 @@ var LibraryOpenAL = {
gain: gain,
panner: panner,
paused: false,
- playTime: 0,
+ playTime: -1,
pausedTime: 0
});
{{{ makeSetValue('sources', 'i', 'AL.currentContext.src.length', 'i32') }}};
@@ -326,6 +326,59 @@ var LibraryOpenAL = {
}
},
+ alGetSourcei: function(source, param, value) {
+ if (!AL.currentContext) {
+ console.error("alGetSourcei called without a valid context");
+ return;
+ }
+ if (source > AL.currentContext.src.length) {
+ console.error("alGetSourcei called with an invalid source");
+ return;
+ }
+ switch (param) {
+ case 0x202 /* AL_SOURCE_RELATIVE */:
+ // Always return 1
+ {{{ makeSetValue('value', '0', '1', 'i32') }}};
+ break;
+ case 0x1009 /* AL_BUFFER */:
+ if (AL.currentContext.src[source - 1].buffer == null) {
+ {{{ makeSetValue('value', '0', '0', 'i32') }}};
+ } else {
+ var buf = AL.currentContext.src[source - 1].buffer;
+ for (var i = 0; i < AL.currentContext.buf.length; ++i) {
+ if (buf == AL.currentContext.buf[i].buf) {
+ {{{ makeSetValue('value', '0', 'i+1', 'i32') }}};
+ return;
+ }
+ }
+ {{{ makeSetValue('value', '0', '0', 'i32') }}};
+ }
+ break;
+ case 0x1010 /* AL_SOURCE_STATE */:
+ if ("src" in AL.currentContext.src[source - 1]) {
+ {{{ makeSetValue('value', '0', '0x1012', 'i32') }}} /* AL_PLAYING */;
+ } else if (AL.currentContext.src[source - 1].paused) {
+ {{{ makeSetValue('value', '0', '0x1013', 'i32') }}} /* AL_PAUSED */;
+ } else if (AL.currentContext.src[source - 1].playTime == -1) {
+ {{{ makeSetValue('value', '0', '0x1011', 'i32') }}} /* AL_INITIAL */;
+ } else {
+ {{{ makeSetValue('value', '0', '0x1014', 'i32') }}} /* AL_STOPPED */;
+ }
+ break;
+ case 0x1015 /* AL_BUFFERS_QUEUED */:
+ if (AL.currentContext.src[source - 1].buffer) {
+ {{{ makeSetValue('value', '0', '1', 'i32') }}}
+ } else {
+ {{{ makeSetValue('value', '0', '0', 'i32') }}}
+ }
+ break;
+ case 0x1016 /* AL_BUFFERS_PROCESSED */:
+ // Always return 1
+ {{{ makeSetValue('value', '0', '1', 'i32') }}}
+ break;
+ }
+ },
+
alDistanceModel: function(model) {
if (model != 0 /* AL_NONE */) {
console.log("Only alDistanceModel(AL_NONE) is currently supported");