Skip to content

Commit b2d87ee

Browse files
committed
Disable HRTF by default when using OpenAL
1 parent 7b88960 commit b2d87ee

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

src/lime/_internal/backend/native/NativeAudioSource.hx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class NativeAudioSource
2828

2929
#if lime_openalsoft
3030
private static var canQueryLatency:Null<Bool>;
31+
private static var hasDirectChannelsExt:Null<Bool>;
3132
#end
3233

3334
private var buffers:Array<ALBuffer>;
@@ -140,6 +141,20 @@ class NativeAudioSource
140141
}
141142
}
142143

144+
AL.sourcei(handle, 0, 0);
145+
146+
#if lime_openalsoft
147+
if (hasDirectChannelsExt == null)
148+
{
149+
hasDirectChannelsExt = AL.isExtensionPresent("AL_SOFT_direct_channels") && AL.isExtensionPresent("AL_SOFT_direct_channels_remix");
150+
}
151+
152+
if (hasDirectChannelsExt)
153+
{
154+
AL.sourcei(handle, AL.DIRECT_CHANNELS_SOFT, AL.REMIX_UNMATCHED_SOFT);
155+
}
156+
#end
157+
143158
samples = Std.int((dataLength * 8.0) / (parent.buffer.channels * parent.buffer.bitsPerSample));
144159
}
145160

src/lime/media/openal/AL.hx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,13 +233,21 @@ class AL
233233
public static inline var FILTER_LOWPASS:Int = 0x0001;
234234
public static inline var FILTER_HIGHPASS:Int = 0x0002;
235235
public static inline var FILTER_BANDPASS:Int = 0x0003;
236+
237+
#if lime_openalsoft
236238
/* AL_SOFT_source_latency extension */
237239
public static inline var SAMPLE_OFFSET_LATENCY_SOFT = 0x1200;
238240
public static inline var SEC_OFFSET_LATENCY_SOFT = 0x1201;
239241

240-
#if lime_openalsoft
241242
/* AL_SOFT_hold_on_disconnect extension */
242243
public static inline var STOP_SOURCES_ON_DISCONNECT_SOFT:Int = 0x19AB;
244+
245+
/* AL_SOFT_direct_channels extension */
246+
public static inline var DIRECT_CHANNELS_SOFT:Int = 0x1033;
247+
248+
/* AL_SOFT_direct_channels_remix extension */
249+
public static inline var DROP_UNMATCHED_SOFT:Int = 0x0001;
250+
public static inline var REMIX_UNMATCHED_SOFT:Int = 0x0002;
243251
#end
244252

245253
public static function removeDirectFilter(source:ALSource)

0 commit comments

Comments
 (0)