Skip to content

Commit

Permalink
Add a hack for #1691
Browse files Browse the repository at this point in the history
  • Loading branch information
Perksey committed Oct 10, 2023
1 parent 1c8e290 commit 3ad600f
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/OpenAL/Silk.NET.OpenAL/AL/AL.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,26 @@ public AL(INativeContext ctx)
}

/// <inheritdoc />
public override partial bool IsExtensionPresent(string name);
public override unsafe bool IsExtensionPresent(string name)
{
if (name.StartsWith("ALC_"))
{
// extreme hack for ALC_EXT_EFX which does not have a standard AL variant
var maxName = SilkMarshal.GetMaxSizeOf(name, NativeStringEncoding.UTF8);
var nameNative = name.Length > 256 ? new byte[maxName] : stackalloc byte[maxName];
SilkMarshal.StringIntoSpan(name, nameNative, NativeStringEncoding.UTF8);
fixed (byte* namePtr = nameNative)
{
return ((delegate* unmanaged[Cdecl]<byte*, char>) Context.GetProcAddress("alcIsExtensionPresent"))
(namePtr) == 1;
}
}

return CoreIsExtensionPresent(name);
}

[NativeApi(EntryPoint = nameof(IsExtensionPresent))]
private partial bool CoreIsExtensionPresent(string name);

/// <inheritdoc />
public SearchPathContainer SearchPaths => _searchPaths ??= new OpenALLibraryNameContainer(_soft);
Expand Down

0 comments on commit 3ad600f

Please sign in to comment.