Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenAL ReopenDevices extension doesn't work #1823

Closed
okaniku opened this issue Dec 4, 2023 · 4 comments · Fixed by #1824
Closed

OpenAL ReopenDevices extension doesn't work #1823

okaniku opened this issue Dec 4, 2023 · 4 comments · Fixed by #1824
Labels
area-OpenAL bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed

Comments

@okaniku
Copy link
Contributor

okaniku commented Dec 4, 2023

Summary

The OpenAL ReopenDevices extension doesn't seem to work.

Steps to reproduce

After setting a current context, and calling
reopenDevices.ReopenDevice(device, deviceName, attrList);
I get 'Native symbol not found (Symbol: alcReopenDeviceSOFT)'

Comments

I'm wondering whether it's because this is an ALC prefixed extension, and the extension class derives from NativeExtension<AL> rather than ContextExtensionBase.

Ref: https://github.com/dotnet/Silk.NET/blob/main/src/OpenAL/Extensions/Silk.NET.OpenAL.Extensions.Soft/ReopenDevices.cs

Interestingly, getting the extension in the first place works fine from the AL API:

al = AL.GetApi(true);
al.TryGetExtension(out ReopenDevices reopenDevices);

Is this a bug or something I'm doing wrong?

@okaniku okaniku added the bug Something isn't working label Dec 4, 2023
@Perksey
Copy link
Member

Perksey commented Dec 4, 2023

It would appear that this is a bug, this should be a context extension.

@Perksey Perksey added help wanted Extra attention is needed good first issue Good for newcomers area-OpenAL labels Dec 4, 2023
@Perksey Perksey linked a pull request Dec 5, 2023 that will close this issue
@okaniku
Copy link
Contributor Author

okaniku commented Dec 14, 2023

Unfortunately it's still not working, even after changing it to a context extension.

Strangely, I'm able to successfully call the underlying function by doing this:

using var alc = ALContext.GetApi(true);
var deviceName = string.Empty;
var dev = alc.OpenDevice(deviceName);
var ctx = alc.CreateContext(dev, null);
alc.MakeContextCurrent(ctx);

if (dev != null && alc.TryGetExtension(dev, out ReopenDevices ext))
{
    var maxName = SilkMarshal.GetMaxSizeOf(deviceName, NativeStringEncoding.UTF8);
    var nameNative = deviceName.Length > 256 ? new byte[maxName] : stackalloc byte[maxName];
    fixed (byte* namePtr = nameNative)
    {
        ((delegate* unmanaged[Cdecl]<Device*, byte*, int*, bool>) alc.GetProcAddress(dev, "alcReopenDeviceSOFT"))(dev, namePtr, null);
    }
}

@Perksey
Copy link
Member

Perksey commented Dec 16, 2023

@okaniku Can you compare the results of alc.Context.GetProcAddress("alcReopenDeviceSOFT") vs alc.GetProcAddress("alcReopenDeviceSOFT")

Relevant code:

https://github.com/dotnet/Silk.NET/blob/main/src/OpenAL/Silk.NET.OpenAL/ALC/ALContext.cs#L98

@okaniku
Copy link
Contributor Author

okaniku commented Dec 16, 2023

Calling alc.Context.GetProcAddress() throws the same error. NativeLibrary3.TryGetExport() returns false, stack trace:

Silk.NET.Core.Loader.LibraryLoader.NetNextNativeLibraryLoader.CoreLoadFunctionPointer(nint handle, string functionName)
Silk.NET.Core.Loader.LibraryLoader.LoadFunctionPointer(nint handle, string functionName)
Silk.NET.Core.Loader.UnmanagedLibrary.LoadFunction(string name)
Silk.NET.Core.Contexts.DefaultNativeContext.GetProcAddress(string proc, int? slot)
Silk.NET.Core.Contexts.MultiNativeContext.GetProcAddress(string proc, int? slot)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-OpenAL bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants