diff --git a/SDL3-CS.SourceGeneration/UnfriendlyMethodFinder.cs b/SDL3-CS.SourceGeneration/UnfriendlyMethodFinder.cs index c9f87ab..960cc4b 100644 --- a/SDL3-CS.SourceGeneration/UnfriendlyMethodFinder.cs +++ b/SDL3-CS.SourceGeneration/UnfriendlyMethodFinder.cs @@ -15,7 +15,7 @@ namespace SDL.SourceGeneration { public readonly Dictionary> Methods = new Dictionary>(); - private static readonly string[] sdlPrefixes = ["SDL_", "TTF_", "IMG_", "Mix_"]; + private static readonly string[] sdlPrefixes = ["SDL_", "TTF_", "IMG_", "MIX_"]; /// /// Checks whether the method is from any SDL library. diff --git a/SDL3-CS.Tests/TestMixer.cs b/SDL3-CS.Tests/TestMixer.cs new file mode 100644 index 0000000..262007a --- /dev/null +++ b/SDL3-CS.Tests/TestMixer.cs @@ -0,0 +1,41 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using NUnit.Framework; +using static SDL.SDL3_mixer; +using static SDL.SDL3; + +namespace SDL.Tests +{ + [TestFixture] + public class TestMixer + { + [Test] + public unsafe void TestBasic() + { + SDL_Init(0); + + bool init = MIX_Init(); + + try + { + Assert.That(init, Is.True, SDL_GetError); + Assert.That(MIX_Version(), Is.EqualTo(SDL_MIXER_VERSION)); + + Assume.That(MIX_GetNumAudioDecoders() > 0); + string? name = MIX_GetAudioDecoder(0); + Assert.That(name, Is.Not.Null, SDL_GetError); + + Assume.That(@"C:\Windows\Media\Windows Logon.wav", Does.Exist); + var decoder = MIX_CreateAudioDecoder(@"C:\Windows\Media\Windows Logon.wav", 0); + Assert.That(decoder != null, SDL_GetError); + MIX_DestroyAudioDecoder(decoder); + } + finally + { + MIX_Quit(); + SDL_Quit(); + } + } + } +} diff --git a/SDL3-CS/generate_bindings.py b/SDL3-CS/generate_bindings.py index 1320960..60a165a 100644 --- a/SDL3-CS/generate_bindings.py +++ b/SDL3-CS/generate_bindings.py @@ -312,7 +312,6 @@ def run_clangsharp(command, header: Header): "--file", header.input_file(), "--output", header.output_file(), "--libraryPath", header.base, - "--methodClassName", header.base, ] @@ -374,6 +373,8 @@ def get_string_returning_functions(sdl_api): yield "TTF_GetFontFamilyName" yield "TTF_GetFontStyleName" + yield "MIX_GetAudioDecoder" + def should_skip(solo_headers: list[Header], header: Header): if len(solo_headers) == 0: diff --git a/SDL3_mixer-CS/SDL3_mixer/ClangSharp/SDL_mixer.g.cs b/SDL3_mixer-CS/SDL3_mixer/ClangSharp/SDL_mixer.g.cs index 0ccb55b..9ede6c5 100644 --- a/SDL3_mixer-CS/SDL3_mixer/ClangSharp/SDL_mixer.g.cs +++ b/SDL3_mixer-CS/SDL3_mixer/ClangSharp/SDL_mixer.g.cs @@ -79,9 +79,9 @@ namespace SDL [DllImport("SDL3_mixer", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern int MIX_GetNumAudioDecoders(); - [DllImport("SDL3_mixer", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + [DllImport("SDL3_mixer", CallingConvention = CallingConvention.Cdecl, EntryPoint = "MIX_GetAudioDecoder", ExactSpelling = true)] [return: NativeTypeName("const char *")] - public static extern byte* MIX_GetAudioDecoder(int index); + public static extern byte* Unsafe_MIX_GetAudioDecoder(int index); [DllImport("SDL3_mixer", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern MIX_Mixer* MIX_CreateMixerDevice(SDL_AudioDeviceID devid, [NativeTypeName("const SDL_AudioSpec *")] SDL_AudioSpec* spec);