diff --git a/MonoGame.Framework/Platform/Native/Audio.Interop.cs b/MonoGame.Framework/Platform/Native/Audio.Interop.cs index 1c34951fc28..b953217d682 100644 --- a/MonoGame.Framework/Platform/Native/Audio.Interop.cs +++ b/MonoGame.Framework/Platform/Native/Audio.Interop.cs @@ -95,7 +95,7 @@ internal static unsafe partial class MGA #region Buffer [LibraryImport(MonoGameNativeDLL, EntryPoint = "MGA_Buffer_Create", StringMarshalling = StringMarshalling.Utf8)] - public static partial MGA_Buffer* Buffer_Create(); + public static partial MGA_Buffer* Buffer_Create(MGA_System* system); [LibraryImport(MonoGameNativeDLL, EntryPoint = "MGA_Buffer_Destroy", StringMarshalling = StringMarshalling.Utf8)] public static partial void Buffer_Destroy(MGA_Buffer* buffer); @@ -142,7 +142,7 @@ public static partial void Buffer_InitializeXact( #region Voice [LibraryImport(MonoGameNativeDLL, EntryPoint = "MGA_Voice_Create", StringMarshalling = StringMarshalling.Utf8)] - public static partial MGA_Voice* Voice_Create(); + public static partial MGA_Voice* Voice_Create(MGA_System* system); [LibraryImport(MonoGameNativeDLL, EntryPoint = "MGA_Voice_Destroy", StringMarshalling = StringMarshalling.Utf8)] public static partial void Voice_Destroy(MGA_Voice* voice); diff --git a/MonoGame.Framework/Platform/Native/DynamicSoundEffectInstance.Native.cs b/MonoGame.Framework/Platform/Native/DynamicSoundEffectInstance.Native.cs index cae32aa0757..2270927e7c1 100644 --- a/MonoGame.Framework/Platform/Native/DynamicSoundEffectInstance.Native.cs +++ b/MonoGame.Framework/Platform/Native/DynamicSoundEffectInstance.Native.cs @@ -11,7 +11,7 @@ public sealed partial class DynamicSoundEffectInstance : SoundEffectInstance { private unsafe void PlatformCreate() { - Voice = MGA.Voice_Create(); + Voice = MGA.Voice_Create(SoundEffect.System); } private unsafe int PlatformGetPendingBufferCount() diff --git a/MonoGame.Framework/Platform/Native/Graphics.Interop.cs b/MonoGame.Framework/Platform/Native/Graphics.Interop.cs index 3ba5cf28fe7..05cbe12a63f 100644 --- a/MonoGame.Framework/Platform/Native/Graphics.Interop.cs +++ b/MonoGame.Framework/Platform/Native/Graphics.Interop.cs @@ -31,9 +31,9 @@ [MGHandle] internal readonly struct MGG_OcclusionQuery { } [StructLayout(LayoutKind.Sequential)] internal struct MGG_DisplayMode { + public SurfaceFormat format; public int width; public int height; - public SurfaceFormat format; } [StructLayout(LayoutKind.Sequential)] diff --git a/MonoGame.Framework/Platform/Native/SoundEffect.Native.cs b/MonoGame.Framework/Platform/Native/SoundEffect.Native.cs index 9b748ad83c0..36ebbe830b8 100644 --- a/MonoGame.Framework/Platform/Native/SoundEffect.Native.cs +++ b/MonoGame.Framework/Platform/Native/SoundEffect.Native.cs @@ -69,7 +69,7 @@ private void PlatformLoadAudioStream(Stream s, out TimeSpan duration) unsafe { - Buffer = MGA.Buffer_Create(); + Buffer = MGA.Buffer_Create(System); MGA.Buffer_InitializeFormat(Buffer, headerData, waveData, waveData.Length, 0, 0); var milliseconds = MGA.Buffer_GetDuration(Buffer); @@ -80,13 +80,13 @@ private void PlatformLoadAudioStream(Stream s, out TimeSpan duration) private unsafe void PlatformInitializePcm(byte[] buffer, int offset, int count, int sampleBits, int sampleRate, AudioChannels channels, int loopStart, int loopLength) { - Buffer = MGA.Buffer_Create(); + Buffer = MGA.Buffer_Create(System); MGA.Buffer_InitializePCM(Buffer, buffer, offset, count, sampleBits, sampleRate, (int)channels, loopStart, loopLength); } private unsafe void PlatformInitializeFormat(byte[] header, byte[] buffer, int bufferSize, int loopStart, int loopLength) { - Buffer = MGA.Buffer_Create(); + Buffer = MGA.Buffer_Create(System); MGA.Buffer_InitializeFormat(Buffer, header, buffer, bufferSize, loopStart, loopLength); } @@ -96,7 +96,7 @@ private unsafe void PlatformInitializeXact(MiniFormatTag codec, byte[] buffer, i // This is only the platform specific non-streaming // Xact sound handling as PCM is already handled. - Buffer = MGA.Buffer_Create(); + Buffer = MGA.Buffer_Create(System); MGA.Buffer_InitializeXact(Buffer, (uint)codec, buffer, buffer.Length, sampleRate, blockAlignment, channels, loopStart, loopLength); var milliseconds = MGA.Buffer_GetDuration(Buffer); @@ -109,7 +109,7 @@ private unsafe void PlatformSetupInstance(SoundEffectInstance instance) // already have a valid voice assigned. if (instance.Voice == null) - instance.Voice = MGA.Voice_Create(); + instance.Voice = MGA.Voice_Create(System); MGA.Voice_SetBuffer(instance.Voice, Buffer); } diff --git a/native/monogame/faudio/MGA_faudio.cpp b/native/monogame/faudio/MGA_faudio.cpp index 9cd09abc35a..00d3783a58f 100644 --- a/native/monogame/faudio/MGA_faudio.cpp +++ b/native/monogame/faudio/MGA_faudio.cpp @@ -49,8 +49,9 @@ void MGA_System_SetReverbSettings(MGA_System* system, ReverbSettings& settings) assert(system != nullptr); } -MGA_Buffer* MGA_Buffer_Create() +MGA_Buffer* MGA_Buffer_Create(MGA_System* system) { + assert(system != nullptr); auto buffer = new MGA_Buffer(); return buffer; } @@ -90,8 +91,9 @@ mgulong MGA_Buffer_GetDuration(MGA_Buffer* buffer) return 0; } -MGA_Voice* MGA_Voice_Create() +MGA_Voice* MGA_Voice_Create(MGA_System* system) { + assert(system != nullptr); auto voice = new MGA_Voice(); return voice; } diff --git a/native/monogame/include/api_MGA.h b/native/monogame/include/api_MGA.h index 52d0a84b04b..3870c4573b7 100644 --- a/native/monogame/include/api_MGA.h +++ b/native/monogame/include/api_MGA.h @@ -20,13 +20,13 @@ MG_EXPORT MGA_System* MGA_System_Create(); MG_EXPORT void MGA_System_Destroy(MGA_System* system); MG_EXPORT mgint MGA_System_GetMaxInstances(); MG_EXPORT void MGA_System_SetReverbSettings(MGA_System* system, ReverbSettings& settings); -MG_EXPORT MGA_Buffer* MGA_Buffer_Create(); +MG_EXPORT MGA_Buffer* MGA_Buffer_Create(MGA_System* system); MG_EXPORT void MGA_Buffer_Destroy(MGA_Buffer* buffer); MG_EXPORT void MGA_Buffer_InitializeFormat(MGA_Buffer* buffer, mgbyte* waveHeader, mgbyte* waveData, mgint length, mgint loopStart, mgint loopLength); MG_EXPORT void MGA_Buffer_InitializePCM(MGA_Buffer* buffer, mgbyte* waveData, mgint offset, mgint length, mgint sampleBits, mgint sampleRate, mgint channels, mgint loopStart, mgint loopLength); MG_EXPORT void MGA_Buffer_InitializeXact(MGA_Buffer* buffer, mguint codec, mgbyte* waveData, mgint length, mgint sampleRate, mgint blockAlignment, mgint channels, mgint loopStart, mgint loopLength); MG_EXPORT mgulong MGA_Buffer_GetDuration(MGA_Buffer* buffer); -MG_EXPORT MGA_Voice* MGA_Voice_Create(); +MG_EXPORT MGA_Voice* MGA_Voice_Create(MGA_System* system); MG_EXPORT void MGA_Voice_Destroy(MGA_Voice* voice); MG_EXPORT mgint MGA_Voice_GetBufferCount(MGA_Voice* voice); MG_EXPORT void MGA_Voice_SetBuffer(MGA_Voice* voice, MGA_Buffer* buffer); diff --git a/native/monogame/include/api_enums.h b/native/monogame/include/api_enums.h index 87aed45377a..a878ece5a2d 100644 --- a/native/monogame/include/api_enums.h +++ b/native/monogame/include/api_enums.h @@ -67,6 +67,7 @@ enum class MGSurfaceFormat : mgint Srgb8A1Etc2 = 93, Rgba8Etc2 = 94, SRgb8A8Etc2 = 95, + Astc4X4Rgba = 96, }; enum class MGDepthFormat : mgint