Parcourir la source

delay NATIVE_FREQ initialization (close #584)

Nicolas Cannasse il y a 6 ans
Parent
commit
fe160e9ff6
1 fichiers modifiés avec 9 ajouts et 3 suppressions
  1. 9 3
      hxd/snd/openal/Emulator.hx

+ 9 - 3
hxd/snd/openal/Emulator.hx

@@ -174,7 +174,13 @@ class Buffer {
 **/
 class Emulator {
 
-	public static var NATIVE_FREQ : Int = #if js @:privateAccess Std.int(NativeChannel.getContext() == null ? 44100 : NativeChannel.getContext().sampleRate) #else 44100 #end;
+	public static var NATIVE_FREQ(get,never) : Int;
+	static var CACHED_FREQ : Null<Int>;
+	static function get_NATIVE_FREQ() {
+		if( CACHED_FREQ == null )
+			CACHED_FREQ = #if js @:privateAccess Std.int(NativeChannel.getContext() == null ? 44100 : NativeChannel.getContext().sampleRate) #else 44100 #end;
+		return CACHED_FREQ;
+	}
 
 	// api
 
@@ -845,8 +851,8 @@ class EFX {
 	public static inline var METERS_PER_UNIT                       = 0x20004;
 
 	// Source properties.
-	public static inline var DIRECT_FILTER                         = 0x20005;	
+	public static inline var DIRECT_FILTER                         = 0x20005;
 	public static inline var FILTER_NULL                           = 0x0000;
-	
+
 }