@@ -92,7 +92,7 @@ var LibraryOpenAL = {
92
92
gain : gain ,
93
93
panner : panner ,
94
94
paused : false ,
95
- playTime : 0 ,
95
+ playTime : - 1 ,
96
96
pausedTime : 0
97
97
} ) ;
98
98
{ { { makeSetValue ( 'sources' , 'i' , 'AL.currentContext.src.length' , 'i32' ) } } } ;
@@ -326,6 +326,59 @@ var LibraryOpenAL = {
326
326
}
327
327
} ,
328
328
329
+ alGetSourcei : function ( source , param , value ) {
330
+ if ( ! AL . currentContext ) {
331
+ console . error ( "alGetSourcei called without a valid context" ) ;
332
+ return ;
333
+ }
334
+ if ( source > AL . currentContext . src . length ) {
335
+ console . error ( "alGetSourcei called with an invalid source" ) ;
336
+ return ;
337
+ }
338
+ switch ( param ) {
339
+ case 0x202 /* AL_SOURCE_RELATIVE */ :
340
+ // Always return 1
341
+ { { { makeSetValue ( 'value' , '0' , '1' , 'i32' ) } } } ;
342
+ break ;
343
+ case 0x1009 /* AL_BUFFER */ :
344
+ if ( AL . currentContext . src [ source - 1 ] . buffer == null ) {
345
+ { { { makeSetValue ( 'value' , '0' , '0' , 'i32' ) } } } ;
346
+ } else {
347
+ var buf = AL . currentContext . src [ source - 1 ] . buffer ;
348
+ for ( var i = 0 ; i < AL . currentContext . buf . length ; ++ i ) {
349
+ if ( buf == AL . currentContext . buf [ i ] . buf ) {
350
+ { { { makeSetValue ( 'value' , '0' , 'i+1' , 'i32' ) } } } ;
351
+ return ;
352
+ }
353
+ }
354
+ { { { makeSetValue ( 'value' , '0' , '0' , 'i32' ) } } } ;
355
+ }
356
+ break ;
357
+ case 0x1010 /* AL_SOURCE_STATE */ :
358
+ if ( "src" in AL . currentContext . src [ source - 1 ] ) {
359
+ { { { makeSetValue ( 'value' , '0' , '0x1012' , 'i32' ) } } } /* AL_PLAYING */ ;
360
+ } else if ( AL . currentContext . src [ source - 1 ] . paused ) {
361
+ { { { makeSetValue ( 'value' , '0' , '0x1013' , 'i32' ) } } } /* AL_PAUSED */ ;
362
+ } else if ( AL . currentContext . src [ source - 1 ] . playTime == - 1 ) {
363
+ { { { makeSetValue ( 'value' , '0' , '0x1011' , 'i32' ) } } } /* AL_INITIAL */ ;
364
+ } else {
365
+ { { { makeSetValue ( 'value' , '0' , '0x1014' , 'i32' ) } } } /* AL_STOPPED */ ;
366
+ }
367
+ break ;
368
+ case 0x1015 /* AL_BUFFERS_QUEUED */ :
369
+ if ( AL . currentContext . src [ source - 1 ] . buffer ) {
370
+ { { { makeSetValue ( 'value' , '0' , '1' , 'i32' ) } } }
371
+ } else {
372
+ { { { makeSetValue ( 'value' , '0' , '0' , 'i32' ) } } }
373
+ }
374
+ break ;
375
+ case 0x1016 /* AL_BUFFERS_PROCESSED */ :
376
+ // Always return 1
377
+ { { { makeSetValue ( 'value' , '0' , '1' , 'i32' ) } } }
378
+ break ;
379
+ }
380
+ } ,
381
+
329
382
alDistanceModel : function ( model ) {
330
383
if ( model != 0 /* AL_NONE */ ) {
331
384
console . log ( "Only alDistanceModel(AL_NONE) is currently supported" ) ;
0 commit comments